From f37d9d000c3008e0f9c5e57b8e1aa23e34686680 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Tue, 15 Feb 2022 15:43:18 +0100 Subject: [PATCH] make selecting the used OS actually do something (load default-setting-adjustments required/needed; TBD) Signed-off-by: Michael Kaufmann --- install/froxlor.sql | 8 ++++---- install/lib/class.FroxlorInstall.php | 14 ++++++++++---- lib/Froxlor/Config/ConfigParser.php | 4 ++-- lib/Froxlor/UI/Panel/UI.php | 4 +--- lib/configfiles/bullseye.xml | 5 +++++ lib/init.php | 7 +++++-- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/install/froxlor.sql b/install/froxlor.sql index 5b5a8b0a..6a4b6bf0 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -388,7 +388,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('dkim', 'dkim_prefix', '/etc/postfix/dkim/'), ('dkim', 'dkim_domains', 'domains'), ('dkim', 'dkim_dkimkeys', 'dkim-keys.conf'), - ('dkim', 'dkimrestart_command', '/etc/init.d/dkim-filter restart'), + ('dkim', 'dkimrestart_command', 'service dkim-filter restart'), ('dkim', 'privkeysuffix', '.priv'), ('admin', 'show_news_feed', '0'), ('admin', 'show_version_login', '0'), @@ -526,7 +526,7 @@ opcache.validate_timestamps'), ('system', 'documentroot_prefix', '/var/customers/webs/'), ('system', 'logfiles_directory', '/var/customers/logs/'), ('system', 'ipaddress', 'SERVERIP'), - ('system', 'apachereload_command', '/etc/init.d/apache2 reload'), + ('system', 'apachereload_command', 'service apache2 reload'), ('system', 'last_traffic_run', '000000'), ('system', 'vmail_uid', '2000'), ('system', 'vmail_gid', '2000'), @@ -534,7 +534,7 @@ opcache.validate_timestamps'), ('system', 'vmail_maildirname', 'Maildir'), ('system', 'bind_enable', '0'), ('system', 'bindconf_directory', '/etc/bind/'), - ('system', 'bindreload_command', '/etc/init.d/bind9 reload'), + ('system', 'bindreload_command', 'service bind9 reload'), ('system', 'hostname', 'SERVERNAME'), ('system', 'mysql_access_host', 'localhost'), ('system', 'lastcronrun', ''), @@ -621,7 +621,7 @@ opcache.validate_timestamps'), ('system', 'mtaserver', 'postfix'), ('system', 'mailtraffic_enabled', '1'), ('system', 'cronconfig', '/etc/cron.d/froxlor'), - ('system', 'crondreload', '/etc/init.d/cron reload'), + ('system', 'crondreload', 'service cron reload'), ('system', 'croncmdline', '/usr/bin/nice -n 5 /usr/bin/php -q'), ('system', 'cron_allowautoupdate', '0'), ('system', 'dns_createhostnameentry', '0'), diff --git a/install/lib/class.FroxlorInstall.php b/install/lib/class.FroxlorInstall.php index 53bbde7a..00ac8973 100644 --- a/install/lib/class.FroxlorInstall.php +++ b/install/lib/class.FroxlorInstall.php @@ -153,6 +153,7 @@ class FroxlorInstall $this->_guessWebserver(); $this->_guessDistribution(); + $this->_getPostField('use_ssl', 1); $this->_getPostField('mysql_host', '127.0.0.1'); $this->_getPostField('mysql_database', 'froxlor'); $this->_getPostField('mysql_forcecreate', '0'); @@ -585,6 +586,9 @@ class FroxlorInstall $this->_updateSetting($upd_stmt, 'admin@' . $this->_data['servername'], 'panel', 'adminmail'); $this->_updateSetting($upd_stmt, $this->_data['serverip'], 'system', 'ipaddress'); + if ($this->_data['use_ssl']) { + $this->_updateSetting($upd_stmt, 1, 'system', 'use_ssl'); + } $this->_updateSetting($upd_stmt, $this->_data['servername'], 'system', 'hostname'); $this->_updateSetting($upd_stmt, $this->_languages[$this->_activelng], 'panel', 'standardlanguage'); $this->_updateSetting($upd_stmt, $this->_data['mysql_access_host'], 'system', 'mysql_access_host'); @@ -600,14 +604,14 @@ class FroxlorInstall $this->_updateSetting($upd_stmt, '/etc/lighttpd/conf-enabled/', 'system', 'apacheconf_vhost'); $this->_updateSetting($upd_stmt, '/etc/lighttpd/froxlor-diroptions/', 'system', 'apacheconf_diroptions'); $this->_updateSetting($upd_stmt, '/etc/lighttpd/froxlor-htpasswd/', 'system', 'apacheconf_htpasswddir'); - $this->_updateSetting($upd_stmt, '/etc/init.d/lighttpd reload', 'system', 'apachereload_command'); + $this->_updateSetting($upd_stmt, 'service lighttpd reload', 'system', 'apachereload_command'); $this->_updateSetting($upd_stmt, '/etc/lighttpd/lighttpd.pem', 'system', 'ssl_cert_file'); $this->_updateSetting($upd_stmt, '/var/run/lighttpd/', 'phpfpm', 'fastcgi_ipcdir'); } elseif ($this->_data['webserver'] == "nginx") { $this->_updateSetting($upd_stmt, '/etc/nginx/sites-enabled/', 'system', 'apacheconf_vhost'); $this->_updateSetting($upd_stmt, '/etc/nginx/sites-enabled/', 'system', 'apacheconf_diroptions'); $this->_updateSetting($upd_stmt, '/etc/nginx/froxlor-htpasswd/', 'system', 'apacheconf_htpasswddir'); - $this->_updateSetting($upd_stmt, '/etc/init.d/nginx reload', 'system', 'apachereload_command'); + $this->_updateSetting($upd_stmt, 'service nginx reload', 'system', 'apachereload_command'); $this->_updateSetting($upd_stmt, '/etc/nginx/nginx.pem', 'system', 'ssl_cert_file'); $this->_updateSetting($upd_stmt, '/var/run/', 'phpfpm', 'fastcgi_ipcdir'); $this->_updateSetting($upd_stmt, 'error', 'system', 'errorlog_level'); @@ -618,8 +622,10 @@ class FroxlorInstall if ($this->_data['distribution'] == str_replace(".xml", "", strtolower(basename($_distribution)))) { $dist = new \Froxlor\Config\ConfigParser($_distribution); $defaults = $dist->getDefaults(); - foreach ($defaults->property as $property) { - $this->_updateSetting($upd_stmt, $property->value, $property->settinggroup, $property->varname); + if (!empty($defaults)) { + foreach ($defaults as $property) { + $this->_updateSetting($upd_stmt, $property->attributes()->value, $property->attributes()->settinggroup, $property->attributes()->varname); + } } } } diff --git a/lib/Froxlor/Config/ConfigParser.php b/lib/Froxlor/Config/ConfigParser.php index c881bcdd..d78b0bc8 100644 --- a/lib/Froxlor/Config/ConfigParser.php +++ b/lib/Froxlor/Config/ConfigParser.php @@ -194,9 +194,9 @@ class ConfigParser } // Get all defaults - $defaults = $this->xml->xpath('//defaults'); + $defaults = $this->xml->xpath('//defaults/default'); foreach ($defaults as $default) { - $this->defaults = $default; + $this->defaults[] = $default; } // Switch flag to indicate we parsed our data diff --git a/lib/Froxlor/UI/Panel/UI.php b/lib/Froxlor/UI/Panel/UI.php index c072461a..e66475c4 100644 --- a/lib/Froxlor/UI/Panel/UI.php +++ b/lib/Froxlor/UI/Panel/UI.php @@ -72,11 +72,9 @@ class UI if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) { @date_default_timezone_set(@date_default_timezone_get()); } - - self::sendSslHeaders(); } - private static function sendSslHeaders() + public static function sendSslHeaders() { /** * If Froxlor was called via HTTPS -> enforce it for the next time by settings HSTS header according to settings diff --git a/lib/configfiles/bullseye.xml b/lib/configfiles/bullseye.xml index 45bcc26e..e5f575e4 100644 --- a/lib/configfiles/bullseye.xml +++ b/lib/configfiles/bullseye.xml @@ -2,6 +2,11 @@ + + + + + diff --git a/lib/init.php b/lib/init.php index a7577153..fa01bb8d 100644 --- a/lib/init.php +++ b/lib/init.php @@ -48,6 +48,9 @@ use voku\helper\AntiXSS; use Froxlor\PhpHelper; use Froxlor\UI\Panel\UI; +// include MySQL-tabledefinitions +require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php'; + UI::sendHeaders(); UI::initTwig(); @@ -118,8 +121,8 @@ if (!isset($sql) || !is_array($sql)) { 'phpExceptionHandler' ]); -// include MySQL-tabledefinitions -require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php'; +// send ssl-related headers (later than the others because we need a working database-connection and installation) +UI::sendSslHeaders(); // create a new idna converter $idna_convert = new \Froxlor\Idna\IdnaWrapper();