From a2f8d02b16bec815ce4d7996c9c2ff6b9bc62593 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Mon, 7 Mar 2022 18:40:31 +0100 Subject: [PATCH] fix installation for mariadb-10.5; fix warnings for not used feature; thx to Akecheta for the hints and testing Signed-off-by: Michael Kaufmann --- install/lib/class.FroxlorInstall.php | 31 +++++++++++++++++++++++++--- lib/Froxlor/Config/ConfigParser.php | 6 +++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/install/lib/class.FroxlorInstall.php b/install/lib/class.FroxlorInstall.php index 30855bfa..b0e5c4a2 100644 --- a/install/lib/class.FroxlorInstall.php +++ b/install/lib/class.FroxlorInstall.php @@ -550,16 +550,23 @@ class FroxlorInstall $this->_updateSetting($upd_stmt, 'error', 'system', 'errorlog_level'); } + /* + * not yet used in configfiles + * -> 0.11.x + * $distros = glob(\Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . '/lib/configfiles/') . '*.xml'); foreach ($distros as $_distribution) { 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); + } } } } + */ $this->_updateSetting($upd_stmt, $this->_data['activate_newsfeed'], 'admin', 'show_news_feed'); $this->_updateSetting($upd_stmt, dirname(dirname(dirname(__FILE__))), 'system', 'letsencryptchallengepath'); @@ -734,8 +741,26 @@ class FroxlorInstall private function _grantDbPrivilegesTo(&$db_root, $database, $username, $password, $access_host) { + // mariadb + if (version_compare($db_root->getAttribute(\PDO::ATTR_SERVER_VERSION), '10.0.0', '>=')) { + // create user + $stmt = $db_root->prepare(" + CREATE USER '" . $username . "'@'" . $access_host . "' IDENTIFIED BY :password + "); + $stmt->execute(array( + "password" => $password + )); + // grant privileges + $stmt = $db_root->prepare(" + GRANT ALL ON `" . $database . "`.* TO :username@:host + "); + $stmt->execute(array( + "username" => $username, + "host" => $access_host + )); + } // mysql8 compatibility - if (version_compare($db_root->getAttribute(\PDO::ATTR_SERVER_VERSION), '8.0.11', '>=')) { + elseif (version_compare($db_root->getAttribute(\PDO::ATTR_SERVER_VERSION), '8.0.11', '>=')) { // create user $stmt = $db_root->prepare(" CREATE USER '" . $username . "'@'" . $access_host . "' IDENTIFIED WITH mysql_native_password BY :password diff --git a/lib/Froxlor/Config/ConfigParser.php b/lib/Froxlor/Config/ConfigParser.php index c881bcdd..037eabe1 100644 --- a/lib/Froxlor/Config/ConfigParser.php +++ b/lib/Froxlor/Config/ConfigParser.php @@ -182,7 +182,7 @@ class ConfigParser } /** - * Parse the XML and populate $this->services + * Parse the XML and populate $this->defaults * * @return bool */ @@ -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