From 6799a56ba1960d04a74d381d470f689ee9484929 Mon Sep 17 00:00:00 2001 From: Patrik Kernstock Date: Tue, 31 Dec 2019 20:18:52 +0100 Subject: [PATCH 1/9] Allow using more advanced LogFormat Signed-off-by: Patrik Kernstock --- install/updates/froxlor/0.10/update_0.10.inc.php | 7 +++++++ lib/Froxlor/Cron/Http/Apache.php | 2 +- lib/Froxlor/Cron/Http/Nginx.php | 2 +- lng/english.lng.php | 2 +- lng/german.lng.php | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/install/updates/froxlor/0.10/update_0.10.inc.php b/install/updates/froxlor/0.10/update_0.10.inc.php index dc45add6..0a928293 100644 --- a/install/updates/froxlor/0.10/update_0.10.inc.php +++ b/install/updates/froxlor/0.10/update_0.10.inc.php @@ -530,3 +530,10 @@ if (\Froxlor\Froxlor::isDatabaseVersion('201912100')) { lastStepStatus(0); \Froxlor\Froxlor::updateToDbVersion('201912310'); } + +if (\Froxlor\Froxlor::isDatabaseVersion('201912311')) { + showUpdateStep("Migrate logfiles_format setting"); + Settings::Set('system.logfiles_format', '"' . Settings::Get('system.logfiles_format') . '"'); + lastStepStatus(0); + \Froxlor\Froxlor::updateToDbVersion('201912312'); +} diff --git a/lib/Froxlor/Cron/Http/Apache.php b/lib/Froxlor/Cron/Http/Apache.php index 70b8c4a7..80fc8cc9 100644 --- a/lib/Froxlor/Cron/Http/Apache.php +++ b/lib/Froxlor/Cron/Http/Apache.php @@ -760,7 +760,7 @@ class Apache extends HttpConfigBase $logtype = 'combined'; if (Settings::Get('system.logfiles_format') != '') { $logtype = 'frx_custom'; - $logfiles_text .= ' LogFormat "' . Settings::Get('system.logfiles_format') . '" ' . $logtype . "\n"; + $logfiles_text .= ' LogFormat ' . Settings::Get('system.logfiles_format') . ' ' . $logtype . "\n"; } if (Settings::Get('system.logfiles_type') == '2' && Settings::Get('system.logfiles_format') == '') { $logtype = 'vhost_combined'; diff --git a/lib/Froxlor/Cron/Http/Nginx.php b/lib/Froxlor/Cron/Http/Nginx.php index 678e6812..b2358dd1 100644 --- a/lib/Froxlor/Cron/Http/Nginx.php +++ b/lib/Froxlor/Cron/Http/Nginx.php @@ -71,7 +71,7 @@ class Nginx extends HttpConfigBase } $logtype = 'frx_custom'; - $this->nginx_data[$vhosts_filename] = 'log_format ' . $logtype . ' "' . Settings::Get('system.logfiles_format') . '";' . "\n"; + $this->nginx_data[$vhosts_filename] = 'log_format ' . $logtype . ' ' . Settings::Get('system.logfiles_format') . ';' . "\n"; } } diff --git a/lng/english.lng.php b/lng/english.lng.php index ec2fcea1..b73563af 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -339,7 +339,7 @@ $lng['serversettings']['logfiles_directory']['description'] = 'Where should all $lng['serversettings']['logfiles_script']['title'] = 'Custom script to pipe log-files to'; $lng['serversettings']['logfiles_script']['description'] = 'You can specify a script here and use the placeholders {LOGFILE}, {DOMAIN} and {CUSTOMER} if needed. In case you want to use it you will need to activate the Pipe webserver logfiles option too. No prefixed pipe-character is needed.'; $lng['serversettings']['logfiles_format']['title'] = 'Access-log format'; -$lng['serversettings']['logfiles_format']['description'] = 'Enter a custom log-format here according to your webservers specifications, leave empty for default'; +$lng['serversettings']['logfiles_format']['description'] = 'Enter a custom log-format here according to your webservers specifications, leave empty for default. Depending on your format the string must be quoted.
If used with nginx, it will look like log_format frx_custom {CONFIGURED_VALUE}.
If used with Apache, it will look like LogFormat {CONFIGURED_VALUE} frx_custom.
Attention: The code won\'t be checked for any errors. If it contains errors, webserver might not start again!'; $lng['serversettings']['logfiles_type']['title'] = 'Access-log type'; $lng['serversettings']['logfiles_type']['description'] = 'Choose between combined or vhost_combined here.'; $lng['serversettings']['logfiles_piped']['title'] = 'Pipe webserver logfiles to specified script (see above)'; diff --git a/lng/german.lng.php b/lng/german.lng.php index 41379319..6d816b7b 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -335,7 +335,7 @@ $lng['serversettings']['logfiles_directory']['description'] = 'Wo sollen die Log $lng['serversettings']['logfiles_script']['title'] = 'Eigenes Script zu dem Log-Files übergeben werden'; $lng['serversettings']['logfiles_script']['description'] = 'Hier kann ein Script an das die Loginhalte übergeben werden hinterlegt und die Platzhalter {LOGFILE}, {DOMAIN} und {CUSTOMER} genutzt werden, sofern nötig. Falls ein Script angegeben wird, muss die Option Webserver Logdateien umleiten gesetzt werden'; $lng['serversettings']['logfiles_format']['title'] = 'Access-Log Format'; -$lng['serversettings']['logfiles_format']['description'] = 'Hier kann ein angepasstes Log-format entsprechend der Webserver-Dokumentation angegeben werden, leer lassen für Standard'; +$lng['serversettings']['logfiles_format']['description'] = 'Hier kann ein angepasstes Log-format entsprechend der Webserver-Dokumentation angegeben werden, leer lassen für Standard. Abhängig vom LogFormat muss die Angabe unter Anführungszeichen stehen.
Wenn verwendet mit nginx, so kann es wie folgt aussehen: log_format frx_custom {EINGESTELLTES_FORMAT}.
Wenn verwendet mit Apache, so kann es wie folgt aussehen: LogFormat {EINGESTELLTES_FORMAT} frx_custom.
ACHTUNG: Der Code wird nicht auf Fehler geprüft. Etwaige Fehler werden auch übernommen und der Webserver könnte nicht mehr starten!'; $lng['serversettings']['logfiles_type']['title'] = 'Access-Log Typ'; $lng['serversettings']['logfiles_type']['description'] = 'Wähle zwischen combined oder vhost_combined.'; $lng['serversettings']['logfiles_piped']['title'] = 'Webserver Logdateien zu eigenem Script umleiten (siehe oben)'; From 7f83ad31f47afe3c1296aeaffdb7a75c005752a1 Mon Sep 17 00:00:00 2001 From: Patrik Kernstock Date: Tue, 31 Dec 2019 22:30:54 +0100 Subject: [PATCH 2/9] Fixed dbversion in SQL/Froxlor.php Signed-off-by: Patrik Kernstock --- install/froxlor.sql | 2 +- lib/Froxlor/Froxlor.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install/froxlor.sql b/install/froxlor.sql index 6dfb60ff..db97f103 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -703,7 +703,7 @@ opcache.interned_strings_buffer'), ('panel', 'customer_hide_options', ''), ('panel', 'is_configured', '0'), ('panel', 'version', '0.10.10'), - ('panel', 'db_version', '201912310'); + ('panel', 'db_version', '201912312'); DROP TABLE IF EXISTS `panel_tasks`; diff --git a/lib/Froxlor/Froxlor.php b/lib/Froxlor/Froxlor.php index 4c398bec..d62bc786 100644 --- a/lib/Froxlor/Froxlor.php +++ b/lib/Froxlor/Froxlor.php @@ -10,7 +10,7 @@ final class Froxlor const VERSION = '0.10.10'; // Database version (YYYYMMDDC where C is a daily counter) - const DBVERSION = '201912310'; + const DBVERSION = '201912312'; // Distribution branding-tag (used for Debian etc.) const BRANDING = ''; From b4dedca3db21ae57de9849aaad7dfeadb0c48a46 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 2 Jan 2020 13:53:22 +0100 Subject: [PATCH 3/9] Update README.md --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index affecf3e..51b9d3d8 100644 --- a/README.md +++ b/README.md @@ -53,14 +53,21 @@ https://files.froxlor.org/releases/froxlor-latest.tar.gz [MD5](https://files.fro [HowTo](https://github.com/Froxlor/Froxlor/wiki/Install-froxlor-on-debian) -/etc/apt/sources.list.d/froxlor.list -> deb http://debian.froxlor.org {stretch|buster} main +``` +apt-get -y install apt-transport-https lsb-release ca-certificates +wget -O - https://deb.froxlor.org/froxlor.gpg | apt-key add - +echo "deb https://deb.froxlor.org/debian $(lsb_release -sc) main" > /etc/apt/sources.list.d/froxlor.list +``` -### Gentoo repository +### Ubuntu repository -[HowTo](https://github.com/Froxlor/Froxlor/wiki/Install-froxlor-on-gentoo) +[HowTo](https://github.com/Froxlor/Froxlor/wiki/Install-froxlor-on-ubuntu) -https://files.froxlor.org/gentoo/repositories.xml +``` +apt-get -y install apt-transport-https lsb-release ca-certificates +wget -O - https://deb.froxlor.org/froxlor.gpg | apt-key add - +echo "deb https://deb.froxlor.org/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/froxlor.list +``` ## Contributing From 25d0bbb7665c8f97eb0ab390c04bcbad49da91de Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 3 Jan 2020 12:48:01 +0100 Subject: [PATCH 4/9] switch from algo26-matthias/idna-covert to our own fork as we cannot update to >2.1 without having a minimum requirement for php-7.2 but we need a few fixes for php-7.4 support later on Signed-off-by: Michael Kaufmann --- composer.json | 2 +- composer.lock | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 731e9bf4..b6445f0a 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "phpmailer/phpmailer": "~6.0", "monolog/monolog": "^1.24", "robthree/twofactorauth": "^1.6", - "algo26-matthias/idna-convert": "^2.1" + "froxlor/idna-convert-legacy": "^2.1" }, "require-dev": { "phpunit/phpunit": "8.4.1", diff --git a/composer.lock b/composer.lock index 57aeced7..12069d86 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5699c65bbdcd2a61a9ced0ac7be84d64", + "content-hash": "a7ba15333ffb4a758ea65039b589545b", "packages": [ { - "name": "algo26-matthias/idna-convert", - "version": "v2.1.0", + "name": "froxlor/idna-convert-legacy", + "version": "v2.1.2", "source": { "type": "git", - "url": "https://github.com/algo26-matthias/idna-convert.git", - "reference": "2717d05713454991936bc581d068c6cea0d84e3b" + "url": "https://github.com/Froxlor/idna-convert-legacy.git", + "reference": "09c1db623ba19e1ed8f2f9dabc15eeda9dc713b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/algo26-matthias/idna-convert/zipball/2717d05713454991936bc581d068c6cea0d84e3b", - "reference": "2717d05713454991936bc581d068c6cea0d84e3b", + "url": "https://api.github.com/repos/Froxlor/idna-convert-legacy/zipball/09c1db623ba19e1ed8f2f9dabc15eeda9dc713b7", + "reference": "09c1db623ba19e1ed8f2f9dabc15eeda9dc713b7", "shasum": "" }, "require": { @@ -43,6 +43,11 @@ "name": "Matthias Sommerfeld", "email": "matthias.sommerfeld@algo26.de", "role": "Developer" + }, + { + "name": "Michael Kaufmann (d00p)", + "email": "d00p@froxlor.org", + "role": "Developer" } ], "description": "A library for encoding and decoding internationalized domain names", @@ -52,7 +57,7 @@ "idna", "php" ], - "time": "2019-03-04T17:07:46+00:00" + "time": "2019-12-31T12:16:30+00:00" }, { "name": "monolog/monolog", From dd2782771aa8d94cdb88b2eb4c458c5269038ca4 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 3 Jan 2020 13:24:31 +0100 Subject: [PATCH 5/9] set version to 0.10.11 for upcoming maintenance release Signed-off-by: Michael Kaufmann --- install/froxlor.sql | 2 +- install/updates/froxlor/0.10/update_0.10.inc.php | 5 +++++ lib/Froxlor/Froxlor.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/install/froxlor.sql b/install/froxlor.sql index cdac2384..99bac462 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -702,7 +702,7 @@ opcache.interned_strings_buffer'), ('panel', 'password_special_char', '!?<>§$%+#=@'), ('panel', 'customer_hide_options', ''), ('panel', 'is_configured', '0'), - ('panel', 'version', '0.10.10'), + ('panel', 'version', '0.10.11'), ('panel', 'db_version', '201912311'); diff --git a/install/updates/froxlor/0.10/update_0.10.inc.php b/install/updates/froxlor/0.10/update_0.10.inc.php index de6e9609..9b76e7df 100644 --- a/install/updates/froxlor/0.10/update_0.10.inc.php +++ b/install/updates/froxlor/0.10/update_0.10.inc.php @@ -537,3 +537,8 @@ if (\Froxlor\Froxlor::isDatabaseVersion('201912310')) { lastStepStatus(0); \Froxlor\Froxlor::updateToDbVersion('201912311'); } + +if (\Froxlor\Froxlor::isFroxlorVersion('0.10.10')) { + showUpdateStep("Updating from 0.10.10 to 0.10.11", false); + \Froxlor\Froxlor::updateToVersion('0.10.11'); +} diff --git a/lib/Froxlor/Froxlor.php b/lib/Froxlor/Froxlor.php index 9eb2ea76..7a96a6f7 100644 --- a/lib/Froxlor/Froxlor.php +++ b/lib/Froxlor/Froxlor.php @@ -7,7 +7,7 @@ final class Froxlor { // Main version variable - const VERSION = '0.10.10'; + const VERSION = '0.10.11'; // Database version (YYYYMMDDC where C is a daily counter) const DBVERSION = '201912311'; From a5287726a44b4ec4644e55a52a937b836df50969 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 3 Jan 2020 23:24:58 +0100 Subject: [PATCH 6/9] fix issue in PhpHelper::trimArray() returning an empty array, fixes #751 Signed-off-by: Michael Kaufmann --- lib/Froxlor/PhpHelper.php | 2 +- lib/Froxlor/Settings/Store.php | 6 ++++-- tests/Mysqls/MysqlsTest.php | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/Froxlor/PhpHelper.php b/lib/Froxlor/PhpHelper.php index 2f4c4289..90b30478 100644 --- a/lib/Froxlor/PhpHelper.php +++ b/lib/Froxlor/PhpHelper.php @@ -374,7 +374,7 @@ class PhpHelper $returnval = array(); if (is_array($source)) { $source = array_map('trim', $source); - $source = array_filter($source, function ($value) { + $returnval = array_filter($source, function ($value) { return $value !== ''; }); } else { diff --git a/lib/Froxlor/Settings/Store.php b/lib/Froxlor/Settings/Store.php index 1f4f2a4a..9a578c96 100644 --- a/lib/Froxlor/Settings/Store.php +++ b/lib/Froxlor/Settings/Store.php @@ -242,8 +242,8 @@ class Store $mysql_access_host_array = array_map('trim', explode(',', Settings::Get('system.mysql_access_host'))); $mysql_access_host_array[] = $newfieldvalue; $mysql_access_host_array = array_unique(\Froxlor\PhpHelper::arrayTrim($mysql_access_host_array)); - $mysql_access_host = implode(',', $mysql_access_host_array); \Froxlor\Database\DbManager::correctMysqlUsers($mysql_access_host_array); + $mysql_access_host = implode(',', $mysql_access_host_array); Settings::Set('system.mysql_access_host', $mysql_access_host); } @@ -293,9 +293,11 @@ class Store 'cleanMySQLAccessHost' ), $mysql_access_host_array); - $mysql_access_host_array = array_unique($mysql_access_host_array); + $mysql_access_host_array = array_unique(\Froxlor\PhpHelper::arrayTrim($mysql_access_host_array)); $newfieldvalue = implode(',', $mysql_access_host_array); \Froxlor\Database\DbManager::correctMysqlUsers($mysql_access_host_array); + $mysql_access_host = implode(',', $mysql_access_host_array); + Settings::Set('system.mysql_access_host', $mysql_access_host); } return $returnvalue; diff --git a/tests/Mysqls/MysqlsTest.php b/tests/Mysqls/MysqlsTest.php index 160efcb9..8d521452 100644 --- a/tests/Mysqls/MysqlsTest.php +++ b/tests/Mysqls/MysqlsTest.php @@ -1,10 +1,12 @@ 'serversettings.ipaddress', + 'settinggroup' => 'system', + 'varname' => 'ipaddress' + ); + Store::storeSettingIpAddress('system_system_ipaddress', $fielddata, '82.149.225.47'); + + $mysql_access_hosts = Settings::Get('system.mysql_access_host'); + $this->assertTrue(strpos($mysql_access_hosts, '82.149.225.47') !== false); + } + + /** + * + * @depends testStoreSettingIpAddress + */ public function testGetAllSqlUsers() { \Froxlor\Database\Database::needRoot(true); From 57503d9c6ee8ef2d84f2b5b10fb9e09fd978540c Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 9 Jan 2020 14:10:50 +0100 Subject: [PATCH 7/9] try to touch logfile from settings in order for is_writable to work correctly, thx to rubberduck Signed-off-by: Michael Kaufmann --- lib/Froxlor/FroxlorLogger.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Froxlor/FroxlorLogger.php b/lib/Froxlor/FroxlorLogger.php index e8cbc84d..f44e4e15 100644 --- a/lib/Froxlor/FroxlorLogger.php +++ b/lib/Froxlor/FroxlorLogger.php @@ -87,10 +87,13 @@ class FroxlorLogger self::$ml->pushHandler(new SyslogHandler('froxlor', LOG_USER, Logger::DEBUG)); break; case 'file': - if (empty(Settings::Get('logger.logfile')) || ! is_writeable(Settings::Get('logger.logfile'))) { + $logger_logfile = Settings::Get('logger.logfile'); + // is_writable needs an existing file to check if it's actually writable + @touch($logger_logfile); + if (empty($logger_logfile) || ! is_writable($logger_logfile)) { Settings::Set('logger.logfile', '/tmp/froxlor.log'); } - self::$ml->pushHandler(new StreamHandler(Settings::Get('logger.logfile'), Logger::DEBUG)); + self::$ml->pushHandler(new StreamHandler($logger_logfile, Logger::DEBUG)); break; case 'mysql': self::$ml->pushHandler(new MysqlHandler(Logger::DEBUG)); From ac82aa80d233cd5b8a251a2d4d2b4fac753e42ed Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 9 Jan 2020 14:14:04 +0100 Subject: [PATCH 8/9] correct logfiles_format migration; only needed if setting is non-empty Signed-off-by: Michael Kaufmann --- install/updates/froxlor/0.10/update_0.10.inc.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/install/updates/froxlor/0.10/update_0.10.inc.php b/install/updates/froxlor/0.10/update_0.10.inc.php index d13eb893..9508e6a9 100644 --- a/install/updates/froxlor/0.10/update_0.10.inc.php +++ b/install/updates/froxlor/0.10/update_0.10.inc.php @@ -545,7 +545,12 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.10.10')) { if (\Froxlor\Froxlor::isDatabaseVersion('201912311')) { showUpdateStep("Migrate logfiles_format setting"); - Settings::Set('system.logfiles_format', '"' . Settings::Get('system.logfiles_format') . '"'); - lastStepStatus(0); + $current_format = Settings::Set('system.logfiles_format'); + if (!empty($current_format)) { + Settings::Set('system.logfiles_format', '"' . Settings::Get('system.logfiles_format') . '"'); + lastStepStatus(0); + } else { + lastStepStatus(0, 'not needed'); + } \Froxlor\Froxlor::updateToDbVersion('201912312'); } From f6f5765b5497e012c28a978e8c53a1b11d8f8c1b Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 9 Jan 2020 14:45:51 +0100 Subject: [PATCH 9/9] avoid settig more than one catchall address for one domain in Emails.update(), thx to mrairstone Signed-off-by: Michael Kaufmann --- lib/Froxlor/Api/Commands/Emails.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/Froxlor/Api/Commands/Emails.php b/lib/Froxlor/Api/Commands/Emails.php index 80270e55..af1cd0a2 100644 --- a/lib/Froxlor/Api/Commands/Emails.php +++ b/lib/Froxlor/Api/Commands/Emails.php @@ -106,10 +106,12 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt ); $email_check = Database::pexecute_first($stmt, $params, true, true); - if (strtolower($email_check['email_full']) == strtolower($email_full)) { - \Froxlor\UI\Response::standard_error('emailexistalready', $email_full, true); - } elseif ($email_check['email'] == $email) { - \Froxlor\UI\Response::standard_error('youhavealreadyacatchallforthisdomain', '', true); + if ($email_check) { + if (strtolower($email_check['email_full']) == strtolower($email_full)) { + \Froxlor\UI\Response::standard_error('emailexistalready', $email_full, true); + } elseif ($email_check['email'] == $email) { + \Froxlor\UI\Response::standard_error('youhavealreadyacatchallforthisdomain', '', true); + } } $stmt = Database::prepare(" @@ -233,6 +235,19 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $iscatchall = '1'; $email_parts = explode('@', $result['email_full']); $email = '@' . $email_parts[1]; + // catchall check + $stmt = Database::prepare(" + SELECT `email_full` FROM `" . TABLE_MAIL_VIRTUAL . "` + WHERE `email` = :email AND `customerid` = :cid AND `iscatchall` = '1' + "); + $params = array( + "email" => $email, + "cid" => $customer['customerid'] + ); + $email_check = Database::pexecute_first($stmt, $params, true, true); + if ($email_check) { + \Froxlor\UI\Response::standard_error('youhavealreadyacatchallforthisdomain', '', true); + } } else { $iscatchall = '0'; $email = $result['email_full']; @@ -273,7 +288,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt * optional specify offset for resultset * @param array $sql_orderby * optional array with index = fieldname and value = ASC|DESC to order the resultset by one or more fields - * + * * @access admin, customer * @throws \Exception * @return string json-encoded array count|list