From 72a3334c1201cce67e7a215bd793f6a979bfd1c3 Mon Sep 17 00:00:00 2001 From: Thom Pol Date: Thu, 11 Mar 2021 19:08:09 +0100 Subject: [PATCH 1/3] Copy custom dovecot config on Debian 6+ sytems (#6096) --- install/dist/lib/debian60.lib.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/install/dist/lib/debian60.lib.php b/install/dist/lib/debian60.lib.php index 154c6b99c4..d76a45c2d3 100644 --- a/install/dist/lib/debian60.lib.php +++ b/install/dist/lib/debian60.lib.php @@ -33,7 +33,7 @@ class installer extends installer_base { public function configure_dovecot() { global $conf; - + $virtual_transport = 'dovecot'; $configure_lmtp = false; @@ -48,7 +48,7 @@ class installer extends installer_base { $tmp = $this->db->queryOneRecord("SELECT * FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . ".server", $conf['server_id']); $ini_array = ini_to_array(stripslashes($tmp['config'])); // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni() - + if(isset($ini_array['mail']['mailbox_virtual_uidgid_maps']) && $ini_array['mail']['mailbox_virtual_uidgid_maps'] == 'y') { $virtual_transport = 'lmtp:unix:private/dovecot-lmtp'; $configure_lmtp = true; @@ -108,6 +108,10 @@ class installer extends installer_base { } else { copy('tpl/debian6_dovecot2.conf.master', $config_dir.'/'.$configfile); } + // Copy custom config file + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/dovecot_custom.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/dovecot_custom.conf.master', $config_dir.'/conf.d/99-ispconfig-custom-config.conf'); + } replaceLine($config_dir.'/'.$configfile, 'postmaster_address = postmaster@example.com', 'postmaster_address = postmaster@'.$conf['hostname'], 1, 0); replaceLine($config_dir.'/'.$configfile, 'postmaster_address = webmaster@localhost', 'postmaster_address = postmaster@'.$conf['hostname'], 1, 0); if(version_compare($dovecot_version,2.1) < 0) { @@ -123,7 +127,7 @@ class installer extends installer_base { if(version_compare($dovecot_version,2.3) >= 0) { // Remove deprecated setting(s) removeLine($config_dir.'/'.$configfile, 'ssl_protocols ='); - + // Check if we have a dhparams file and if not, create it if(!file_exists('/etc/dovecot/dh.pem')) { swriteln('Creating new DHParams file, this takes several minutes. Do not interrupt the script.'); @@ -146,7 +150,7 @@ class installer extends installer_base { $content = str_replace('#2.3+ ','',$content); file_put_contents($config_dir.'/'.$configfile,$content); unset($content); - + } else { // remove settings which are not supported in Dovecot < 2.3 removeLine($config_dir.'/'.$configfile, 'ssl_min_protocol ='); @@ -159,7 +163,7 @@ class installer extends installer_base { copy('tpl/debian6_dovecot.conf.master', $config_dir.'/'.$configfile); } } - + $dovecot_protocols = 'imap pop3'; //* dovecot-lmtpd @@ -196,7 +200,7 @@ class installer extends installer_base { chmod($config_dir.'/'.$configfile, 0600); chown($config_dir.'/'.$configfile, 'root'); chgrp($config_dir.'/'.$configfile, 'root'); - + // Dovecot shall ignore mounts in website directory if(is_installed('doveadm')) exec("doveadm mount add '/var/www/*' ignore > /dev/null 2> /dev/null"); -- GitLab From 581bb48b2d7e3adba2444ac0611381f47620023b Mon Sep 17 00:00:00 2001 From: Thom Pol Date: Thu, 11 Mar 2021 19:10:41 +0100 Subject: [PATCH 2/3] Add trailing space so line is removed when parsing the config --- install/tpl/debian6_dovecot2.conf.master | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/tpl/debian6_dovecot2.conf.master b/install/tpl/debian6_dovecot2.conf.master index 91d745bc39..7aae62db40 100644 --- a/install/tpl/debian6_dovecot2.conf.master +++ b/install/tpl/debian6_dovecot2.conf.master @@ -91,7 +91,7 @@ protocol lmtp { #2.3+ group = vmail #2.3+ mode = 0660 #2.3+ } -#2.3+ +#2.3+ #2.3+ unix_listener stats-writer { #2.3+ user = vmail #2.3+ group = vmail -- GitLab From eed63b31712824f34ba681a1a1c70aac161014af Mon Sep 17 00:00:00 2001 From: Thom Pol Date: Sat, 13 Mar 2021 09:14:47 +0100 Subject: [PATCH 3/3] Add check if conf.d folder for Dovecot exists --- install/dist/lib/debian60.lib.php | 3 +++ install/lib/installer_base.lib.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/install/dist/lib/debian60.lib.php b/install/dist/lib/debian60.lib.php index d76a45c2d3..981e6cff92 100644 --- a/install/dist/lib/debian60.lib.php +++ b/install/dist/lib/debian60.lib.php @@ -110,6 +110,9 @@ class installer extends installer_base { } // Copy custom config file if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/dovecot_custom.conf.master')) { + if(!@is_dir($config_dir . '/conf.d')) { + mkdir($config_dir . '/conf.d'); + } copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/dovecot_custom.conf.master', $config_dir.'/conf.d/99-ispconfig-custom-config.conf'); } replaceLine($config_dir.'/'.$configfile, 'postmaster_address = postmaster@example.com', 'postmaster_address = postmaster@'.$conf['hostname'], 1, 0); diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 6de768f7e5..5617826313 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1536,6 +1536,9 @@ class installer_base { } // Copy custom config file if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/dovecot_custom.conf.master')) { + if(!@is_dir($config_dir . '/conf.d')) { + mkdir($config_dir . '/conf.d'); + } copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/dovecot_custom.conf.master', $config_dir.'/conf.d/99-ispconfig-custom-config.conf'); } replaceLine($config_dir.'/'.$configfile, 'postmaster_address = postmaster@example.com', 'postmaster_address = postmaster@'.$conf['hostname'], 1, 0); -- GitLab