From 7c9075f5516b42ed0372ffa26ed841a0e9553736 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 17 Feb 2017 09:15:35 +0100 Subject: [PATCH] security/acme-client: switch plugin detection --- .../AcmeClient/Api/SettingsController.php | 2 +- .../models/OPNsense/AcmeClient/AcmeClient.php | 40 +------------------ 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/security/acme-client/src/opnsense/mvc/app/controllers/OPNsense/AcmeClient/Api/SettingsController.php b/security/acme-client/src/opnsense/mvc/app/controllers/OPNsense/AcmeClient/Api/SettingsController.php index ea5083510..5e484f2f2 100644 --- a/security/acme-client/src/opnsense/mvc/app/controllers/OPNsense/AcmeClient/Api/SettingsController.php +++ b/security/acme-client/src/opnsense/mvc/app/controllers/OPNsense/AcmeClient/Api/SettingsController.php @@ -125,7 +125,7 @@ class SettingsController extends ApiMutableModelControllerBase $mdlAcme = $this->getModel(); // Check if the required plugin is installed - if ((string)$mdlAcme->isPluginInstalled('os-haproxy') != "1") { + if ((string)$mdlAcme->isPluginInstalled('haproxy') != "1") { $this->getLogger()->error("LE check: HAProxy plugin is NOT installed, skipping integration"); return($result); } diff --git a/security/acme-client/src/opnsense/mvc/app/models/OPNsense/AcmeClient/AcmeClient.php b/security/acme-client/src/opnsense/mvc/app/models/OPNsense/AcmeClient/AcmeClient.php index 09a07e485..70427ab5c 100644 --- a/security/acme-client/src/opnsense/mvc/app/models/OPNsense/AcmeClient/AcmeClient.php +++ b/security/acme-client/src/opnsense/mvc/app/models/OPNsense/AcmeClient/AcmeClient.php @@ -96,45 +96,7 @@ class AcmeClient extends BaseModel */ public function isPluginInstalled($name) { - // NOTE: Based on infoAction() from Core/Api/FirmwareController.php - // FIXME: Should be replaced by a Core function sooner or later. - $backend = new Backend(); - $keys = array('name', 'version', 'comment', 'flatsize', 'locked', 'license'); - $plugins = array(); - - // Only check local package data for performance reasons - $current = $backend->configdRun("firmware local"); - $current = explode("\n", trim($current)); - - foreach ($current as $line) { - /* package infos are flat lists with 3 pipes as delimiter */ - $expanded = explode('|||', $line); - $translated = array(); - $index = 0; - if (count($expanded) != count($keys)) { - continue; - } - foreach ($keys as $key) { - $translated[$key] = $expanded[$index++]; - } - - /* mark local packages as "installed" */ - $translated['installed'] = "1"; - - /* figure out local and remote plugins */ - $plugin = explode('-', $translated['name']); - if (count($plugin)) { - if ($plugin[0] == 'os' || $plugin[0] == 'ospriv') { - $plugins[$translated['name']] = $translated; - } - } - } - - if (isset($plugins[$name]) and $plugins[$name]['installed'] == "1") { - return 1; // TRUE, is installed - } else { - return 0; // FALSE, is not installed - } + return trim($backend->configdRun('firmware plugin ' . escapeshellarg($name))); } }