security/acme-client: switch plugin detection

This commit is contained in:
Franco Fichtner
2017-02-17 09:15:35 +01:00
parent b0d2fd38ef
commit 7c9075f551
2 changed files with 2 additions and 40 deletions
@@ -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);
}
@@ -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)));
}
}