From 7ddb90cb7960ee6e2b71e549360ead5870d17a30 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 31 May 2021 13:48:15 +0200 Subject: [PATCH] firmware: allow manual development override on business subscription In case the flavour is a directory location on the mirror containing a slash allow for manual flavour and type selection. --- .../OPNsense/Core/Api/FirmwareController.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php index 202ebd80b..67973e1e9 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php @@ -1028,11 +1028,14 @@ class FirmwareController extends ApiControllerBase if (!preg_match('/[a-z0-9]{8}(-[a-z0-9]{4}){3}-[a-z0-9]{12}/i', $selSubscription)) { $invalid_msgs[] = gettext('A valid subscription is required for this firmware mirror.'); } - if (!in_array($selectedFlavour, $validOptions['flavours_has_subscription'])) { - $invalid_msgs[] = sprintf(gettext('Subscription requires the following flavour: %s'), $validOptions['flavours'][$validOptions['flavours_has_subscription'][0]]); - } - if (!in_array($selectedType, $validOptions['families_has_subscription'])) { - $invalid_msgs[] = sprintf(gettext('Subscription requires the following type: %s'), $validOptions['families'][$validOptions['families_has_subscription'][0]]); + if (!preg_match('/\//', $selectedFlavour)) { + /* error when flat flavour is used, but not when directory location was selected */ + if (!in_array($selectedFlavour, $validOptions['flavours_has_subscription'])) { + $invalid_msgs[] = sprintf(gettext('Subscription requires the following flavour: %s'), $validOptions['flavours'][$validOptions['flavours_has_subscription'][0]]); + } + if (!in_array($selectedType, $validOptions['families_has_subscription'])) { + $invalid_msgs[] = sprintf(gettext('Subscription requires the following type: %s'), $validOptions['families'][$validOptions['families_has_subscription'][0]]); + } } } else { if (!empty($selSubscription)) {