From 58f81a206406f2bf2dbda1ae5fe9ce9396fb57b3 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 29 Sep 2022 08:23:05 +0200 Subject: [PATCH] firmware: clear license file if no subscription key is set Tweak the external wording and position. Seems convenient to append to version, but ideally we add dynamic elements to the bottom. --- src/etc/inc/system.inc | 5 +++++ .../mvc/app/views/OPNsense/Core/firmware.volt | 12 ++++++------ src/www/widgets/api/plugins/system.inc | 9 ++++----- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 33485381d..8fb283657 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -770,6 +770,11 @@ function system_firmware_configure($verbose = false) /* rewrite the config via the defaults and possible arguments */ mwexec('/usr/local/sbin/opnsense-update -sd ' . join(' ', $args)); + /* clear the license file when no subscription key is set */ + if (empty(trim(shell_exec('/usr/local/sbin/opnsense-update -K')))) { + @unlink('/usr/local/opnsense/version/core.license'); + } + if ($verbose) { echo "done.\n"; } diff --git a/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt b/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt index 513274d01..d2a36b950 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt @@ -842,12 +842,6 @@ - - - {{ lang._('License valid to') }} - - - {{ lang._('Architecture') }} @@ -890,6 +884,12 @@ + + + {{ lang._('Licensed until') }} + + + diff --git a/src/www/widgets/api/plugins/system.inc b/src/www/widgets/api/plugins/system.inc index 13a1fd068..c47fec7ef 100644 --- a/src/www/widgets/api/plugins/system.inc +++ b/src/www/widgets/api/plugins/system.inc @@ -158,14 +158,13 @@ function system_api_versions($product) $result = []; $result[] = sprintf('%s %s-%s', $product['product_name'], $product['product_version'], $product['product_arch']); - - if (!empty($product['product_license']['valid_to'])) { - $result[] = sprintf(gettext('(licensed until %s)'), $product['product_license']['valid_to']); - } - $result[] = php_uname('s') . ' ' . php_uname('r'); $result[] = trim(shell_exec('/usr/local/bin/openssl version')); + if (!empty($product['product_license']['valid_to'])) { + $result[] = gettext('Licensed until') . ' ' . $product['product_license']['valid_to']; + } + return $result; }