Commit b6af4c88 authored by Franco Fichtner's avatar Franco Fichtner

config: migration could be stripped, global vars are always global

(cherry picked from commit b306aaae)
(cherry picked from commit 0f551f09)
(cherry picked from commit 044d519f)
parent a0148151
......@@ -29,8 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
global $g; /* XXX make this a getter function for traceability */
/* XXX make this a getter function for traceability */
$g = json_decode(file_get_contents('/usr/local/opnsense/firmware-product'), true);
openlog($g['product_id'], LOG_ODELAY, LOG_USER);
......@@ -80,13 +79,8 @@ function load_config_from_file($filename)
* RESULT
* $config - array containing all configuration variables
******/
function parse_config($verbose = false)
function parse_config()
{
if ($verbose) {
echo 'Loading configuration...';
flush();
}
$cnf = OPNsense\Core\Config::getInstance();
// return config data as array, use old "listags" construction to mark certain elements as array (even if they're not recurring)
......@@ -95,10 +89,6 @@ function parse_config($verbose = false)
/* make alias table (for faster lookups) */
alias_make_table($config);
if ($verbose) {
echo "done.\n";
}
return $config;
}
......@@ -151,6 +141,10 @@ function convert_config($verbose = false)
} else {
mwexecf($mvc_migration);
}
/* reload the config as it was rewritten and saved in the script context */
OPNsense\Core\Config::getInstance()->forceReload();
$config = parse_config();
}
/****f* config/write_config
......
......@@ -2,7 +2,7 @@
<?php
/*
Copyright (C) 2014-2016 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2014-2017 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2004-2009 Scott Ullrich <sullrich@pfsense.org>.
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
Copyright (C) 2009 Erik Kristensen
......@@ -56,8 +56,12 @@ foreach ($inc_files as $inc_file) {
echo "done.\n";
global $config;
$config = parse_config(true);
/*
* If this was an import or restore or reset, once run
* the migration, but do not display the status here as
* otherwise this prints all the models that keep their
* current version level.
*/
convert_config();
/*
......
......@@ -37,10 +37,6 @@ require_once("system.inc");
require_once("services.inc");
require_once("interfaces.inc");
global $config;
$config = parse_config(true);
if (count($argv) > 1 && is_numeric($argv[1])) {
// starting delayed.
sleep($argv[1]);
......
......@@ -50,14 +50,14 @@ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($model_dir
$version_post = $mdl->getVersion();
if ($version_pre != $version_post) {
$version_pre = !empty($version_pre) ? $version_pre : ' <unversioned> ';
echo "migrated " . $mdl_class_info->getName() .
echo "Migrated " . $mdl_class_info->getName() .
" from " . $version_pre .
" to " . $version_post . "\n";
$executed_migration = true;
} elseif (!empty($version_post)) {
echo "keep version " . $mdl_class_info->getName() . " (".$version_post.")\n";
echo "Keep version " . $mdl_class_info->getName() . " (".$version_post.")\n";
} else {
echo "unversioned " . $mdl_class_info->getName() . "\n";
echo "Unversioned " . $mdl_class_info->getName() . "\n";
}
}
} catch (\ReflectionException $e) {
......
......@@ -34,9 +34,8 @@
require_once("config.inc");
require_once("certs.inc");
require_once("legacy_bindings.inc");
use OPNsense\Core\Config;
global $config;
use OPNsense\Core\Config;
// traverse captive portal zones
$configObj = Config::getInstance()->object();
......
......@@ -33,9 +33,8 @@
require_once("config.inc");
require_once("certs.inc");
require_once("legacy_bindings.inc");
use OPNsense\Core\Config;
global $config;
use OPNsense\Core\Config;
// Our template systems stores the ca certid into /usr/local/etc/squid/ca.pem.id
// Which makes it easier for the setup script to detect cert changes (which should flush the stored cache)
......
......@@ -58,7 +58,6 @@ function add_local_user($username, $userdn, $userfullname)
local_user_set($new_user);
}
global $config;
// attributes used in page
$ldap_users= array();
$ldap_is_connected = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment