-
-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add mail conf task #1238
base: main
Are you sure you want to change the base?
add mail conf task #1238
Changes from all commits
7af766b
3a3e2e5
d9dd785
558f815
4de6ed0
d934367
5015e68
8634a29
c1408fc
e2728ba
e412950
ae9d68d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -613,7 +613,12 @@ | |
('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'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing |
||
('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'), | ||
|
@@ -731,7 +736,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`; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,3 +105,16 @@ | |
|
||
Froxlor::updateToDbVersion('202401090'); | ||
} | ||
|
||
if (Froxlor::isDatabaseVersion('202401090')) { | ||
|
||
Update::showUpdateStep("Adding new settings"); | ||
Settings::AddNew("system.mda_reload_command", "service dovecot reload"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a new update section with a new db-version is required or users on that version will not get the updates |
||
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'); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Froxlor project. | ||
* Copyright (c) 2010 the Froxlor Team (see authors). | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, you can also view it online at | ||
* https://files.froxlor.org/misc/COPYING.txt | ||
* | ||
* @copyright the authors | ||
* @author Froxlor team <[email protected]> | ||
* @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 = 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); | ||
fclose($vhosts_file_handler); | ||
} | ||
} | ||
|
||
public function reload() | ||
{ | ||
if($this->content !== "") { | ||
FileDir::safe_exec(escapeshellcmd(Settings::Get('system.mda_reload_command'))); | ||
} | ||
} | ||
|
||
public function init() | ||
{ | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Froxlor project. | ||
* Copyright (c) 2010 the Froxlor Team (see authors). | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, you can also view it online at | ||
* https://files.froxlor.org/misc/COPYING.txt | ||
* | ||
* @copyright the authors | ||
* @author Froxlor team <[email protected]> | ||
* @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 = 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'); | ||
fwrite($vhosts_file_handler, $vhosts_file); | ||
fclose($vhosts_file_handler); | ||
FileDir::safe_exec('postmap -F hash:'.$vhosts_filename); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how is this map integrated in the postfix config and being used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, missed the 'postconf -e tls_server_sni_maps' command there, sorry |
||
} | ||
} | ||
|
||
public function reload() | ||
{ | ||
if($this->content !== "") { | ||
FileDir::safe_exec(escapeshellcmd(Settings::Get('system.mta_reload_command'))); | ||
} | ||
} | ||
|
||
public function init() | ||
{ | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please dont change stuff in the build - this needs to be available on our servers for the update/autoupdate to work and does not have anything to do with the feature you are working on in any way