From 7af766be71e4393fdda56f9391eb44c80155d132 Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Fri, 16 Feb 2024 09:54:21 +0000 Subject: [PATCH 01/10] add mail conf task --- lib/Froxlor/Cli/MasterCron.php | 2 +- lib/Froxlor/Cron/Mail/Dovecot.php | 111 ++++++++++++++++++++++++++ lib/Froxlor/Cron/Mail/Postfix.php | 108 +++++++++++++++++++++++++ lib/Froxlor/Cron/System/TasksCron.php | 26 ++++++ lib/Froxlor/Cron/TaskId.php | 5 ++ lib/Froxlor/System/Cronjob.php | 7 ++ 6 files changed, 258 insertions(+), 1 deletion(-) create mode 100755 lib/Froxlor/Cron/Mail/Dovecot.php create mode 100755 lib/Froxlor/Cron/Mail/Postfix.php diff --git a/lib/Froxlor/Cli/MasterCron.php b/lib/Froxlor/Cli/MasterCron.php index 61926ecc10..bdee97280e 100644 --- a/lib/Froxlor/Cli/MasterCron.php +++ b/lib/Froxlor/Cli/MasterCron.php @@ -96,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($input->getOption('run-task')) { $tasks_to_run = $input->getOption('run-task'); foreach ($tasks_to_run as $ttr) { - if (in_array($ttr, [TaskId::REBUILD_VHOST, TaskId::REBUILD_DNS, TaskId::REBUILD_RSPAMD, TaskId::CREATE_QUOTA, TaskId::REBUILD_CRON])) { + if (in_array($ttr, [TaskId::REBUILD_VHOST, TaskId::REBUILD_DNS, TaskId::REBUILD_RSPAMD, TaskId::CREATE_QUOTA, TaskId::REBUILD_CRON, TaskId::REBUILD_MAIL_CONF])) { Cronjob::inserttask($ttr); $jobs[] = 'tasks'; } else { diff --git a/lib/Froxlor/Cron/Mail/Dovecot.php b/lib/Froxlor/Cron/Mail/Dovecot.php new file mode 100755 index 0000000000..8566725dc3 --- /dev/null +++ b/lib/Froxlor/Cron/Mail/Dovecot.php @@ -0,0 +1,111 @@ + + * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 + */ + +namespace Froxlor\Cron\Mail; + +use Froxlor\Cron\Http\DomainSSL; +use Froxlor\Cron\Http\WebserverBase; +use Froxlor\Database\Database; +use Froxlor\FileDir; +use Froxlor\FroxlorLogger; +use Froxlor\Settings; +use PDO; + +class Dovecot +{ + private $content = ""; + + public function createVirtualSSLHost() + { + $domains = WebserverBase::getVhostsToCreate(); + foreach ($domains as $domain) { + FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'dovecot::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']); + if ($domain['deactivated'] == '0' && $domain['customer_deactivated'] == '0' && $domain['isemaildomain'] == '1' + && $domain['ssl_enabled'] == '1' && $domain['ssl'] == '1') { + $this->content .= $this->getSSLConf($domain); + } + } + } + + private function getSSLConf($domain) + { + $query = "SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` `i`, `" . TABLE_DOMAINTOIP . "` `dip` + WHERE dip.id_domain = :domainid AND i.id = dip.id_ipandports AND i.ssl = '1' ORDER BY i.ssl_cert_file ASC;"; + + $result_stmt = Database::prepare($query); + Database::pexecute($result_stmt, [ + 'domainid' => $domain['id'] + ]); + $content = ""; + while ($ipandport = $result_stmt->fetch(PDO::FETCH_ASSOC)) { + $domain['ssl_cert_file'] = $ipandport['ssl_cert_file']; + $domain['ssl_key_file'] = $ipandport['ssl_key_file']; + $domain['ssl_ca_file'] = $ipandport['ssl_ca_file']; + $domain['ssl_cert_chainfile'] = $ipandport['ssl_cert_chainfile']; + + // SSL STUFF + $dssl = new DomainSSL(); + // this sets the ssl-related array-indices in the $domain array + // if the domain has customer-defined ssl-certificates + $dssl->setDomainSSLFilesArray($domain); + + if($domain['ssl_cert_file'] != '') { + $content .= 'local_name ' . $domain['domain'] . " {\n"; + $content .= ' ssl_cert = <' . FileDir::makeCorrectFile($domain['ssl_cert_file']) . "\n"; + + if ($domain['ssl_key_file'] != '') { + $content .= ' ssl_key = <' . FileDir::makeCorrectFile($domain['ssl_key_file']) . "\n"; + } + $content .="}\n"; + + } + } + + return $content; + } + + public function writeConfigs() + { + if($this->content !== "") { + $vhosts_filename = '/etc/dovecot/conf.d/99-froxlor-vhost.ssl.conf'; + $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $this->content; + $vhosts_file_handler = fopen($vhosts_filename, 'w'); + fwrite($vhosts_file_handler, $vhosts_file); + fclose($vhosts_file_handler); + } + } + + public function reload() + { + if($this->content !== "") { + //FileDir::safe_exec(escapeshellcmd(Settings::Get('system.dovecotreload_command'))); + } + } + + public function init() + { + + } +} diff --git a/lib/Froxlor/Cron/Mail/Postfix.php b/lib/Froxlor/Cron/Mail/Postfix.php new file mode 100755 index 0000000000..9b4e6b73ff --- /dev/null +++ b/lib/Froxlor/Cron/Mail/Postfix.php @@ -0,0 +1,108 @@ + + * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 + */ + +namespace Froxlor\Cron\Mail; + +use Froxlor\Cron\Http\DomainSSL; +use Froxlor\Cron\Http\WebserverBase; +use Froxlor\Database\Database; +use Froxlor\FileDir; +use Froxlor\FroxlorLogger; +use Froxlor\Settings; +use PDO; + +class Postfix +{ + private $content = ""; + + private $postFixMapFile = "99-froxlor.map"; + + public function createVirtualSSLHost() + { + $domains = WebserverBase::getVhostsToCreate(); + foreach ($domains as $domain) { + FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'dovecot::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']); + if ($domain['deactivated'] == '0' && $domain['customer_deactivated'] == '0' && $domain['isemaildomain'] == '1' + && $domain['ssl_enabled'] == '1' && $domain['ssl'] == '1') { + $this->content .= $this->getSSLConf($domain); + } + } + } + + private function getSSLConf($domain) + { + $query = "SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` `i`, `" . TABLE_DOMAINTOIP . "` `dip` + WHERE dip.id_domain = :domainid AND i.id = dip.id_ipandports AND i.ssl = '1' ORDER BY i.ssl_cert_file ASC;"; + + $result_stmt = Database::prepare($query); + Database::pexecute($result_stmt, [ + 'domainid' => $domain['id'] + ]); + $content = ""; + while ($ipandport = $result_stmt->fetch(PDO::FETCH_ASSOC)) { + $domain['ssl_cert_file'] = $ipandport['ssl_cert_file']; + $domain['ssl_key_file'] = $ipandport['ssl_key_file']; + $domain['ssl_ca_file'] = $ipandport['ssl_ca_file']; + $domain['ssl_cert_chainfile'] = $ipandport['ssl_cert_chainfile']; + + // SSL STUFF + $dssl = new DomainSSL(); + // this sets the ssl-related array-indices in the $domain array + // if the domain has customer-defined ssl-certificates + $dssl->setDomainSSLFilesArray($domain); + + if($domain['ssl_cert_file'] != '' && $domain['ssl_key_file'] != '') { + $content .= $domain['domain'].' ' . FileDir::makeCorrectFile($domain['ssl_key_file']) . " " . FileDir::makeCorrectFile($domain['ssl_cert_file']). "\n"; + } + } + + return $content; + } + + public function writeConfigs() + { + if($this->content !== "") { + $vhosts_filename = '/etc/postfix/'.$this->postFixMapFile; + FileDir::safe_exec('postconf -e tls_server_sni_maps=hash:'.$vhosts_filename); + $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $this->content; + $vhosts_file_handler = fopen($vhosts_filename, 'w'); + fwrite($vhosts_file_handler, $vhosts_file); + fclose($vhosts_file_handler); + FileDir::safe_exec('postmap -F hash:'.$vhosts_filename); + } + } + + public function reload() + { + if($this->content !== "") { + //FileDir::safe_exec(escapeshellcmd(Settings::Get('system.dovecotreload_command'))); + } + } + + public function init() + { + + } +} diff --git a/lib/Froxlor/Cron/System/TasksCron.php b/lib/Froxlor/Cron/System/TasksCron.php index 83cfdd3f76..46d273e7fd 100644 --- a/lib/Froxlor/Cron/System/TasksCron.php +++ b/lib/Froxlor/Cron/System/TasksCron.php @@ -29,6 +29,8 @@ use Froxlor\Cron\FroxlorCron; use Froxlor\Cron\Http\ConfigIO; use Froxlor\Cron\Http\HttpConfigBase; +use Froxlor\Cron\Mail\Dovecot; +use Froxlor\Cron\Mail\Postfix; use Froxlor\Cron\Mail\Rspamd; use Froxlor\Cron\TaskId; use Froxlor\Database\Database; @@ -125,6 +127,11 @@ public static function run() */ FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_NOTICE, "Removing Let's Encrypt entries for domain " . $row['data']['domain']); Domain::doLetsEncryptCleanUp($row['data']['domain']); + } elseif ($row['type'] == TaskId::REBUILD_MAIL_CONF) { + /** + * TYPE=13 MEANS TO CREATE REBUILD MAIL CONF + */ + self::rebuildMailConfigs(); } } @@ -461,4 +468,23 @@ private static function rebuildAntiSpamConfigs() $antispam = new Rspamd(FroxlorLogger::getInstanceOf()); $antispam->writeConfigs(); } + + private static function rebuildMailConfigs() + { + $toBeConfigure = []; + if (Settings::Get('system.mdaserver') == "dovecot") { + $toBeConfigure[] = Dovecot::class; + } + if (Settings::Get('system.mtaserver') == "postfix") { + $toBeConfigure[] = Postfix::class; + } + + foreach($toBeConfigure as $class_name) { + $conf = new $class_name(); + $conf->init(); + $conf->createVirtualSSLHost(); + $conf->writeConfigs(); + $conf->reload(); + } + } } diff --git a/lib/Froxlor/Cron/TaskId.php b/lib/Froxlor/Cron/TaskId.php index f905eba4bc..077d5631b8 100644 --- a/lib/Froxlor/Cron/TaskId.php +++ b/lib/Froxlor/Cron/TaskId.php @@ -87,6 +87,11 @@ final class TaskId */ const DELETE_DOMAIN_SSL = 12; + /** + * TYPE=13 rebuild mail config + */ + const REBUILD_MAIL_CONF = 13; + /** * TYPE=20 CUSTUMER DATA DUMP */ diff --git a/lib/Froxlor/System/Cronjob.php b/lib/Froxlor/System/Cronjob.php index b4be07ac2e..ba14458de7 100644 --- a/lib/Froxlor/System/Cronjob.php +++ b/lib/Froxlor/System/Cronjob.php @@ -180,6 +180,13 @@ public static function inserttask(int $type, ...$params) 'type' => TaskId::DELETE_CUSTOMER_FILES, 'data' => $data ]); + } elseif ($type == TaskId::REBUILD_MAIL_CONF) { + $data = []; + $data = json_encode($data); + Database::pexecute($ins_stmt, [ + 'type' => TaskId::REBUILD_MAIL_CONF, + 'data' => $data + ]); } elseif ($type == TaskId::DELETE_EMAIL_DATA && count($params) == 2 && $params[0] != '' && $params[1] != '') { $data = []; $data['loginname'] = $params[0]; From 3a3e2e5e4c1091d9551131128d70fb69722fb867 Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Mon, 19 Feb 2024 13:07:15 +0000 Subject: [PATCH 02/10] add mail conf task --- actions/admin/settings/150.mail.php | 42 +++++++++++++++++++- install/froxlor.sql.php | 2 + install/updates/froxlor/update_2.2.inc.php | 4 ++ lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php | 2 + lib/Froxlor/Cron/Mail/Dovecot.php | 4 +- lib/Froxlor/Cron/Mail/Postfix.php | 4 +- lng/de.lng.php | 16 ++++++++ lng/en.lng.php | 16 ++++++++ 8 files changed, 85 insertions(+), 5 deletions(-) diff --git a/actions/admin/settings/150.mail.php b/actions/admin/settings/150.mail.php index 57cef6087d..89cd8847cd 100644 --- a/actions/admin/settings/150.mail.php +++ b/actions/admin/settings/150.mail.php @@ -139,6 +139,26 @@ 'save_method' => 'storeSettingField', 'advanced_mode' => true ], + 'system_mda_conf_dir' => [ + 'label' => lng('serversettings.mda_conf_dir'), + 'settinggroup' => 'system', + 'varname' => 'mda_conf_dir', + 'type' => 'text', + 'string_type' => 'filedir', + 'default' => '/etc/dovecot/conf.d', + 'save_method' => 'storeSettingField', + 'requires_reconf' => ['mail'] + ], + 'system_mda_reload_command' => [ + 'label' => lng('serversettings.mda_reload_command'), + 'settinggroup' => 'system', + 'varname' => 'mda_reload_command', + 'type' => 'text', + 'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i', + 'default' => 'service dovecot restart', + 'save_method' => 'storeSettingField', + 'required_otp' => true + ], 'system_mtaserver' => [ 'label' => lng('serversettings.mtaserver'), 'settinggroup' => 'system', @@ -162,7 +182,27 @@ 'string_emptyallowed' => true, 'save_method' => 'storeSettingField', 'advanced_mode' => true - ] + ], + 'system_mta_conf_dir' => [ + 'label' => lng('serversettings.mta_conf_dir'), + 'settinggroup' => 'system', + 'varname' => 'mta_conf_dir', + 'type' => 'text', + 'string_type' => 'filedir', + 'default' => '/etc/postfix', + 'save_method' => 'storeSettingField', + 'requires_reconf' => ['mail'] + ], + 'system_mta_reload_command' => [ + 'label' => lng('serversettings.mta_reload_command'), + 'settinggroup' => 'system', + 'varname' => 'mta_reload_command', + 'type' => 'text', + 'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i', + 'default' => 'service postfix restart', + 'save_method' => 'storeSettingField', + 'required_otp' => true + ], ] ] ] diff --git a/install/froxlor.sql.php b/install/froxlor.sql.php index 84e40bb558..6f100d3d1e 100644 --- a/install/froxlor.sql.php +++ b/install/froxlor.sql.php @@ -613,7 +613,9 @@ ('system', 'mdalog', '/var/log/mail.log'), ('system', 'mtalog', '/var/log/mail.log'), ('system', 'mdaserver', 'dovecot'), + ('system', 'mda_reload_command', 'service dovecot restart'), ('system', 'mtaserver', 'postfix'), + ('system', 'mta_reload_command', 'service postfix restart'), ('system', 'mailtraffic_enabled', '1'), ('system', 'cronconfig', '/etc/cron.d/froxlor'), ('system', 'crondreload', 'service cron reload'), diff --git a/install/updates/froxlor/update_2.2.inc.php b/install/updates/froxlor/update_2.2.inc.php index 19b975c6f2..0b3d6e1200 100644 --- a/install/updates/froxlor/update_2.2.inc.php +++ b/install/updates/froxlor/update_2.2.inc.php @@ -97,6 +97,10 @@ Update::showUpdateStep("Adding new settings"); Settings::AddNew("system.le_renew_services", ""); Settings::AddNew("system.le_renew_hook", "systemctl restart postfix dovecot proftpd"); + Settings::AddNew("system.mda_reload_command", "service dovecot reload"); + Settings::AddNew("system.mda_conf_dir", "/etc/dovecot/conf.d"); + Settings::AddNew("system.mta_reload_command", "service postfix reload"); + Settings::AddNew("system.mta_conf_dir", "/etc/postfix"); Update::lastStepStatus(0); Froxlor::updateToDbVersion('202401090'); diff --git a/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php b/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php index ca6b94eea2..705f2ae738 100644 --- a/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php +++ b/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php @@ -85,6 +85,7 @@ public static function run(bool $internal = false) if ($issue_froxlor || !empty($issue_domains) || !empty($renew_froxlor) || $renew_domains) { // insert task to generate certificates and vhost-configs Cronjob::inserttask(TaskId::REBUILD_VHOST); + Cronjob::inserttask(TaskId::REBUILD_MAIL_CONF); } return 0; } @@ -205,6 +206,7 @@ public static function run(bool $internal = false) if ($changedetected) { if (self::$no_inserttask == false) { Cronjob::inserttask(TaskId::REBUILD_VHOST); + Cronjob::inserttask(TaskId::REBUILD_MAIL_CONF); } FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "Let's Encrypt certificates have been updated"); } else { diff --git a/lib/Froxlor/Cron/Mail/Dovecot.php b/lib/Froxlor/Cron/Mail/Dovecot.php index 8566725dc3..a285a7819f 100755 --- a/lib/Froxlor/Cron/Mail/Dovecot.php +++ b/lib/Froxlor/Cron/Mail/Dovecot.php @@ -89,7 +89,7 @@ private function getSSLConf($domain) public function writeConfigs() { if($this->content !== "") { - $vhosts_filename = '/etc/dovecot/conf.d/99-froxlor-vhost.ssl.conf'; + $vhosts_filename = Settings::Get('system.mda_conf_dir') .'/99-froxlor-vhost.ssl.conf'; $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $this->content; $vhosts_file_handler = fopen($vhosts_filename, 'w'); fwrite($vhosts_file_handler, $vhosts_file); @@ -100,7 +100,7 @@ public function writeConfigs() public function reload() { if($this->content !== "") { - //FileDir::safe_exec(escapeshellcmd(Settings::Get('system.dovecotreload_command'))); + FileDir::safe_exec(escapeshellcmd(Settings::Get('system.mda_reload_command'))); } } diff --git a/lib/Froxlor/Cron/Mail/Postfix.php b/lib/Froxlor/Cron/Mail/Postfix.php index 9b4e6b73ff..61625b0ad1 100755 --- a/lib/Froxlor/Cron/Mail/Postfix.php +++ b/lib/Froxlor/Cron/Mail/Postfix.php @@ -84,7 +84,7 @@ private function getSSLConf($domain) public function writeConfigs() { if($this->content !== "") { - $vhosts_filename = '/etc/postfix/'.$this->postFixMapFile; + $vhosts_filename = Settings::Get('system.mta_conf_dir') .'/'.$this->postFixMapFile; FileDir::safe_exec('postconf -e tls_server_sni_maps=hash:'.$vhosts_filename); $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $this->content; $vhosts_file_handler = fopen($vhosts_filename, 'w'); @@ -97,7 +97,7 @@ public function writeConfigs() public function reload() { if($this->content !== "") { - //FileDir::safe_exec(escapeshellcmd(Settings::Get('system.dovecotreload_command'))); + FileDir::safe_exec(escapeshellcmd(Settings::Get('system.mta_reload_command'))); } } diff --git a/lng/de.lng.php b/lng/de.lng.php index eac909a146..c5dfb74781 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -1862,6 +1862,14 @@ 'title' => 'Logdatei des MDA', 'description' => 'Die Logdatei des Mail Delivery Server', ], + 'mda_conf_dir' => [ + 'title' => 'MDA Konfigurations Verzeichnis', + 'description' => 'Geben Sie hier den Pfad zur Konfigurationverzeichniss ein', + ], + 'mda_reload_command' => [ + 'title' => 'MDA-Daemon reload Befehl', + 'description' => 'Geben Sie hier den Befehl zum Neuladen des MDA-Daemons an', + ], 'mtaserver' => [ 'title' => 'Typ des MTA', 'description' => 'Der eingesetzte Mail Transfer Agent', @@ -1870,6 +1878,14 @@ 'title' => 'Logdatei des MTA', 'description' => 'Die Logdatei des Mail Transfer Agent', ], + 'mta_reload_command' => [ + 'title' => 'MTA-Daemon reload Befehl', + 'description' => 'Geben Sie hier den Befehl zum Neuladen des MTA-Daemons an', + ], + 'mta_conf_dir' => [ + 'title' => 'MTA Konfigurations Verzeichnis', + 'description' => 'Geben Sie hier den Pfad zur Konfigurationverzeichniss ein', + ], 'system_cronconfig' => [ 'title' => 'Cron-Konfigurationsdatei', 'description' => 'Pfad zur Konfigurationsdatei des Cron-Dienstes. Diese Datei wird von Froxlor automatisch aktualisiert.
Hinweis: Bitte verwenden Sie exakt die gleiche Datei wie für den Froxlor-Haupt-Cronjob (Standard: /etc/cron.d/froxlor)!

Wird FreeBSD verwendet, sollte hier /etc/crontab angegeben werden!', diff --git a/lng/en.lng.php b/lng/en.lng.php index 272511fe49..7adc001308 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -1984,6 +1984,14 @@ 'title' => 'MDA log', 'description' => 'Logfile of the Mail Delivery Server', ], + 'mda_conf_dir' => [ + 'title' => 'MTA configuration dirname', + 'description' => 'Where should the configuration be stored? Please specify an directory here.', + ], + 'mda_reload_command' => [ + 'title' => 'MDA-daemon reload command', + 'description' => 'Specify the command to execute in order to reload your systems mda-daemon', + ], 'mtaserver' => [ 'title' => 'MTA type', 'description' => 'Type of the Mail Transfer Agent', @@ -1992,6 +2000,14 @@ 'title' => 'MTA log', 'description' => 'Logfile of the Mail Transfer Agent', ], + 'mta_conf_dir' => [ + 'title' => 'MTA configuration dirname', + 'description' => 'Where should the configuration be stored? Please specify an directory here.', + ], + 'mta_reload_command' => [ + 'title' => 'MTA-daemon reload command', + 'description' => 'Specify the command to execute in order to reload your systems mta-daemon', + ], 'system_cronconfig' => [ 'title' => 'Cron configuration file', 'description' => 'Path to the cron-service configuration-file. This file will be updated regularly and automatically by froxlor.
Note: Please be sure to use the same filename as for the main froxlor cronjob (default: /etc/cron.d/froxlor)!

If you are using FreeBSD, please specify /etc/crontab here!', From d9dd785b6014d1562105a48df2e8026dab35ba6f Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Mon, 19 Feb 2024 13:10:48 +0000 Subject: [PATCH 03/10] add mail conf task --- lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php b/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php index 705f2ae738..5b2929c013 100644 --- a/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php +++ b/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php @@ -634,7 +634,7 @@ private static function runAcmeSh(array $certrow, array $domains, &$cronlog = nu } if (Settings::IsInList('system.le_renew_services', 'dovecot')) { // custom config for dovecot - $dovecot_conf = '/etc/dovecot/conf.d/99-froxlor.ssl.conf'; // @fixme setting? + $dovecot_conf = Settings::Get('system.mda_conf_dir') . '/99-froxlor.ssl.conf'; $ssl_content = << Date: Mon, 19 Feb 2024 14:33:29 +0000 Subject: [PATCH 04/10] add mail conf task --- actions/admin/settings/150.mail.php | 8 ++++---- install/updates/froxlor/update_2.2.inc.php | 14 +++++++++++--- lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php | 2 +- lib/Froxlor/Cron/Mail/Dovecot.php | 2 +- lib/Froxlor/Cron/Mail/Postfix.php | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/actions/admin/settings/150.mail.php b/actions/admin/settings/150.mail.php index 89cd8847cd..95821b40dc 100644 --- a/actions/admin/settings/150.mail.php +++ b/actions/admin/settings/150.mail.php @@ -144,8 +144,8 @@ 'settinggroup' => 'system', 'varname' => 'mda_conf_dir', 'type' => 'text', - 'string_type' => 'filedir', - 'default' => '/etc/dovecot/conf.d', + 'string_type' => 'confdir', + 'default' => '/etc/dovecot/conf.d/', 'save_method' => 'storeSettingField', 'requires_reconf' => ['mail'] ], @@ -188,8 +188,8 @@ 'settinggroup' => 'system', 'varname' => 'mta_conf_dir', 'type' => 'text', - 'string_type' => 'filedir', - 'default' => '/etc/postfix', + 'string_type' => 'confdir', + 'default' => '/etc/postfix/', 'save_method' => 'storeSettingField', 'requires_reconf' => ['mail'] ], diff --git a/install/updates/froxlor/update_2.2.inc.php b/install/updates/froxlor/update_2.2.inc.php index 0b3d6e1200..f64363dc87 100644 --- a/install/updates/froxlor/update_2.2.inc.php +++ b/install/updates/froxlor/update_2.2.inc.php @@ -97,11 +97,19 @@ Update::showUpdateStep("Adding new settings"); Settings::AddNew("system.le_renew_services", ""); Settings::AddNew("system.le_renew_hook", "systemctl restart postfix dovecot proftpd"); + Update::lastStepStatus(0); + + Froxlor::updateToDbVersion('202401090'); +} + +if (Froxlor::isDatabaseVersion('202401090')) { + + Update::showUpdateStep("Adding new settings"); Settings::AddNew("system.mda_reload_command", "service dovecot reload"); - Settings::AddNew("system.mda_conf_dir", "/etc/dovecot/conf.d"); + Settings::AddNew("system.mda_conf_dir", "/etc/dovecot/conf.d/"); Settings::AddNew("system.mta_reload_command", "service postfix reload"); - Settings::AddNew("system.mta_conf_dir", "/etc/postfix"); + Settings::AddNew("system.mta_conf_dir", "/etc/postfix/"); Update::lastStepStatus(0); - Froxlor::updateToDbVersion('202401090'); + Froxlor::updateToDbVersion('202402190'); } diff --git a/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php b/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php index 5b2929c013..29798a31a1 100644 --- a/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php +++ b/lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php @@ -634,7 +634,7 @@ private static function runAcmeSh(array $certrow, array $domains, &$cronlog = nu } if (Settings::IsInList('system.le_renew_services', 'dovecot')) { // custom config for dovecot - $dovecot_conf = Settings::Get('system.mda_conf_dir') . '/99-froxlor.ssl.conf'; + $dovecot_conf = FileDir::makeCorrectFile(Settings::Get('system.mda_conf_dir') . '99-froxlor.ssl.conf'); $ssl_content = <<content !== "") { - $vhosts_filename = Settings::Get('system.mda_conf_dir') .'/99-froxlor-vhost.ssl.conf'; + $vhosts_filename = FileDir::makeCorrectFile(Settings::Get('system.mda_conf_dir') . '99-froxlor-vhost.ssl.conf'); $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $this->content; $vhosts_file_handler = fopen($vhosts_filename, 'w'); fwrite($vhosts_file_handler, $vhosts_file); diff --git a/lib/Froxlor/Cron/Mail/Postfix.php b/lib/Froxlor/Cron/Mail/Postfix.php index 61625b0ad1..8c4a54d8a2 100755 --- a/lib/Froxlor/Cron/Mail/Postfix.php +++ b/lib/Froxlor/Cron/Mail/Postfix.php @@ -84,7 +84,7 @@ private function getSSLConf($domain) public function writeConfigs() { if($this->content !== "") { - $vhosts_filename = Settings::Get('system.mta_conf_dir') .'/'.$this->postFixMapFile; + $vhosts_filename = FileDir::makeCorrectFile(Settings::Get('system.mta_conf_dir') . $this->postFixMapFile); FileDir::safe_exec('postconf -e tls_server_sni_maps=hash:'.$vhosts_filename); $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $this->content; $vhosts_file_handler = fopen($vhosts_filename, 'w'); From 4de6ed0e554c3327e8386b828c6e6957b2105c79 Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Mon, 19 Feb 2024 14:37:52 +0000 Subject: [PATCH 05/10] add mail conf task --- install/froxlor.sql.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/froxlor.sql.php b/install/froxlor.sql.php index 6f100d3d1e..fc7774715e 100644 --- a/install/froxlor.sql.php +++ b/install/froxlor.sql.php @@ -613,8 +613,10 @@ ('system', 'mdalog', '/var/log/mail.log'), ('system', 'mtalog', '/var/log/mail.log'), ('system', 'mdaserver', 'dovecot'), + ('system', 'mda_conf_dir', '/etc/dovecot/conf.d/'), ('system', 'mda_reload_command', 'service dovecot restart'), ('system', 'mtaserver', 'postfix'), + ('system', 'mta_conf_dir', '/etc/postfix/'), ('system', 'mta_reload_command', 'service postfix restart'), ('system', 'mailtraffic_enabled', '1'), ('system', 'cronconfig', '/etc/cron.d/froxlor'), From d9343670a6e8d06ad4f6d804f42ac29348ac3b25 Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Mon, 19 Feb 2024 14:38:26 +0000 Subject: [PATCH 06/10] add mail conf task --- install/froxlor.sql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/froxlor.sql.php b/install/froxlor.sql.php index fc7774715e..753d15861f 100644 --- a/install/froxlor.sql.php +++ b/install/froxlor.sql.php @@ -735,7 +735,7 @@ ('panel', 'settings_mode', '0'), ('panel', 'menu_collapsed', '1'), ('panel', 'version', '2.2.0-dev1'), - ('panel', 'db_version', '202401090'); + ('panel', 'db_version', '202402190'); DROP TABLE IF EXISTS `panel_tasks`; From 5015e680719873c2414d67965254b1f7b56a19f5 Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Mon, 19 Feb 2024 16:28:53 +0000 Subject: [PATCH 07/10] add mail conf task --- actions/admin/settings/150.mail.php | 14 ++++++++++---- install/froxlor.sql.php | 1 + lib/Froxlor/Cron/System/TasksCron.php | 28 ++++++++++++++------------- lng/de.lng.php | 8 ++++++-- lng/en.lng.php | 4 ++++ 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/actions/admin/settings/150.mail.php b/actions/admin/settings/150.mail.php index 95821b40dc..9b31c59d53 100644 --- a/actions/admin/settings/150.mail.php +++ b/actions/admin/settings/150.mail.php @@ -115,6 +115,14 @@ 'save_method' => 'storeSettingField', 'advanced_mode' => true ], + 'system_mail_sni_enabled' => [ + 'label' => lng('serversettings.mail_sni_enabled'), + 'settinggroup' => 'system', + 'varname' => 'mail_sni_enabled', + 'type' => 'checkbox', + 'default' => false, + 'save_method' => 'storeSettingField', + ], 'system_mdaserver' => [ 'label' => lng('serversettings.mdaserver'), 'settinggroup' => 'system', @@ -146,8 +154,7 @@ 'type' => 'text', 'string_type' => 'confdir', 'default' => '/etc/dovecot/conf.d/', - 'save_method' => 'storeSettingField', - 'requires_reconf' => ['mail'] + 'save_method' => 'storeSettingField' ], 'system_mda_reload_command' => [ 'label' => lng('serversettings.mda_reload_command'), @@ -190,8 +197,7 @@ 'type' => 'text', 'string_type' => 'confdir', 'default' => '/etc/postfix/', - 'save_method' => 'storeSettingField', - 'requires_reconf' => ['mail'] + 'save_method' => 'storeSettingField' ], 'system_mta_reload_command' => [ 'label' => lng('serversettings.mta_reload_command'), diff --git a/install/froxlor.sql.php b/install/froxlor.sql.php index 753d15861f..3f9517e123 100644 --- a/install/froxlor.sql.php +++ b/install/froxlor.sql.php @@ -618,6 +618,7 @@ ('system', 'mtaserver', 'postfix'), ('system', 'mta_conf_dir', '/etc/postfix/'), ('system', 'mta_reload_command', 'service postfix restart'), + ('system', 'mail_sni_enabled', '0'), ('system', 'mailtraffic_enabled', '1'), ('system', 'cronconfig', '/etc/cron.d/froxlor'), ('system', 'crondreload', 'service cron reload'), diff --git a/lib/Froxlor/Cron/System/TasksCron.php b/lib/Froxlor/Cron/System/TasksCron.php index 46d273e7fd..508f0cdc48 100644 --- a/lib/Froxlor/Cron/System/TasksCron.php +++ b/lib/Froxlor/Cron/System/TasksCron.php @@ -471,20 +471,22 @@ private static function rebuildAntiSpamConfigs() private static function rebuildMailConfigs() { - $toBeConfigure = []; - if (Settings::Get('system.mdaserver') == "dovecot") { - $toBeConfigure[] = Dovecot::class; - } - if (Settings::Get('system.mtaserver') == "postfix") { - $toBeConfigure[] = Postfix::class; - } + if (Settings::Get("system.mail_sni_enabled")) { + $toBeConfigure = []; + if (Settings::Get('system.mdaserver') == "dovecot") { + $toBeConfigure[] = Dovecot::class; + } + if (Settings::Get('system.mtaserver') == "postfix") { + $toBeConfigure[] = Postfix::class; + } - foreach($toBeConfigure as $class_name) { - $conf = new $class_name(); - $conf->init(); - $conf->createVirtualSSLHost(); - $conf->writeConfigs(); - $conf->reload(); + foreach ($toBeConfigure as $class_name) { + $conf = new $class_name(); + $conf->init(); + $conf->createVirtualSSLHost(); + $conf->writeConfigs(); + $conf->reload(); + } } } } diff --git a/lng/de.lng.php b/lng/de.lng.php index c5dfb74781..2bf242215b 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -1854,6 +1854,10 @@ 'title' => 'Analysiere Mailtraffic', 'description' => 'Aktiviere das Analysieren der Logdateien des Mailsystems, um den verbrauchten Traffic zu berechnen.', ], + 'mail_sni_enabled' => [ + 'title' => 'Erzeuge SNI Einträge für die Mail-Dienste', + 'description' => 'Wenn Email und SSL für Domains aktiviert, werden SNI Einträge für die Mail-Dienste erzeugt.', + ], 'mdaserver' => [ 'title' => 'Typ des MDA', 'description' => 'Der eingesetzte Mail Delivery Server', @@ -1864,7 +1868,7 @@ ], 'mda_conf_dir' => [ 'title' => 'MDA Konfigurations Verzeichnis', - 'description' => 'Geben Sie hier den Pfad zur Konfigurationverzeichniss ein', + 'description' => 'Geben Sie hier den Pfad zur Konfigurationverzeichniss ein. Sollte nur in Ausnahmen angepasst werden müssen.', ], 'mda_reload_command' => [ 'title' => 'MDA-Daemon reload Befehl', @@ -1884,7 +1888,7 @@ ], 'mta_conf_dir' => [ 'title' => 'MTA Konfigurations Verzeichnis', - 'description' => 'Geben Sie hier den Pfad zur Konfigurationverzeichniss ein', + 'description' => 'Geben Sie hier den Pfad zur Konfigurationverzeichniss ein. Sollte nur in Ausnahmen angepasst werden müssen.', ], 'system_cronconfig' => [ 'title' => 'Cron-Konfigurationsdatei', diff --git a/lng/en.lng.php b/lng/en.lng.php index 7adc001308..1bbeb2b72e 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -1976,6 +1976,10 @@ 'title' => 'Analyse mail traffic', 'description' => 'Enable analysing of mailserver logs to calculate the traffic', ], + 'mail_sni_enabled' => [ + 'title' => 'Create SNI entrys for mail services', + 'description' => 'If in domain settings email and ssl activated, sni entrys for mail services created.', + ], 'mdaserver' => [ 'title' => 'MDA type', 'description' => 'Type of the Mail Delivery Server', From 8634a295f16e6235040d4a1ca255d7eeb273bba9 Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Mon, 19 Feb 2024 16:32:05 +0000 Subject: [PATCH 08/10] add mail conf task --- install/updates/froxlor/update_2.2.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/install/updates/froxlor/update_2.2.inc.php b/install/updates/froxlor/update_2.2.inc.php index f64363dc87..d4ebe59121 100644 --- a/install/updates/froxlor/update_2.2.inc.php +++ b/install/updates/froxlor/update_2.2.inc.php @@ -109,6 +109,7 @@ Settings::AddNew("system.mda_conf_dir", "/etc/dovecot/conf.d/"); Settings::AddNew("system.mta_reload_command", "service postfix reload"); Settings::AddNew("system.mta_conf_dir", "/etc/postfix/"); + Settings::AddNew("system.mail_sni_enabled", "0"); Update::lastStepStatus(0); Froxlor::updateToDbVersion('202402190'); From e41295002d56d0c77b4513d4d6cf4ff3e98434fc Mon Sep 17 00:00:00 2001 From: boonkerz Date: Mon, 27 May 2024 19:26:55 +0200 Subject: [PATCH 09/10] Update build-mariadb.yml --- .github/workflows/build-mariadb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-mariadb.yml b/.github/workflows/build-mariadb.yml index 57ae83525c..2f84c543f6 100644 --- a/.github/workflows/build-mariadb.yml +++ b/.github/workflows/build-mariadb.yml @@ -1,5 +1,5 @@ name: Froxlor-CI-MariaDB -on: [ 'push', 'pull_request', 'create' ] +on: [ 'push', 'pull_request', 'create', 'workflow_dispatch' ] jobs: froxlor: From ae9d68d04152da1928b5801a75f41cbebfa217bd Mon Sep 17 00:00:00 2001 From: boonkerz Date: Mon, 27 May 2024 19:33:59 +0200 Subject: [PATCH 10/10] Update build-mariadb.yml --- .github/workflows/build-mariadb.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-mariadb.yml b/.github/workflows/build-mariadb.yml index 2f84c543f6..aa5cd2c5ed 100644 --- a/.github/workflows/build-mariadb.yml +++ b/.github/workflows/build-mariadb.yml @@ -118,12 +118,9 @@ jobs: mv froxlor-nightly.${{steps.vars.outputs.sha_short}}.zip dist/ mv froxlor-nightly.${{steps.vars.outputs.sha_short}}.zip.sha256 dist/ - - name: Deploy nightly to server - uses: easingthemes/ssh-deploy@main - env: - ARGS: "-rltDzvO --chown=${{ secrets.WEB_USER }}:${{ secrets.WEB_USER }}" - SOURCE: "dist/" - SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }} - REMOTE_HOST: ${{ secrets.REMOTE_HOST }} - REMOTE_USER: ${{ secrets.REMOTE_USER }} - TARGET: "${{ secrets.REMOTE_TARGET }}" + - name: 'Upload Artifact' + uses: actions/upload-artifact@v4 + with: + name: froxlor-nightly.${{steps.vars.outputs.sha_short}}.zip + path: dist/froxlor-nightly.${{steps.vars.outputs.sha_short}}.zip + retention-days: 5