From 16a2fa67b7f7c37f9869420d334af614cb065e4e Mon Sep 17 00:00:00 2001 From: Jesse Norell <jesse@kci.net> Date: Wed, 10 Feb 2016 17:23:10 -0700 Subject: [PATCH] add postfix version check, smtpd_relay_restrictions and stress adaptive behavior add postfix version check add stress adaptive behavior (syntax changes with postfix version 3.0) add smtpd_relay_restrictions (postfix version 2.10) --- install/lib/installer_base.lib.php | 25 +++++++++++++++++++++++++ install/tpl/postfix_2-10.conf.master | 5 +++++ install/tpl/postfix_2-5.conf.master | 11 +++++++++++ install/tpl/postfix_3-0.conf.master | 11 +++++++++++ 4 files changed, 52 insertions(+) create mode 100644 install/tpl/postfix_2-10.conf.master create mode 100644 install/tpl/postfix_2-5.conf.master create mode 100644 install/tpl/postfix_3-0.conf.master diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 6a4d771e16..e95c3e3e9c 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -967,6 +967,11 @@ class installer_base { $this->error("The postfix configuration directory '$config_dir' does not exist."); } + //* Get postfix version + exec('postfix -d mail_version 2>&1', $out); + $postfix_version = preg_replace('/.*=\s*/', '', $out[0]); + unset($out); + //* mysql-virtual_domains.cf $this->process_postfix_config('mysql-virtual_domains.cf'); @@ -1093,6 +1098,26 @@ class installer_base { $postconf_tpl = strtr($postconf_tpl, $postconf_placeholders); $postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines + //* Merge version-specific postfix config + if(version_compare($postfix_version , '2.5', '>=')) { + $configfile = 'postfix_2-5.conf'; + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', 'tpl/'.$configfile.'.master'); + $content = strtr($content, $postconf_placeholders); + $postconf_commands = array_merge($postconf_commands, array_filter(explode("\n", $content))); + } + if(version_compare($postfix_version , '2.10', '>=')) { + $configfile = 'postfix_2-10.conf'; + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', 'tpl/'.$configfile.'.master'); + $content = strtr($content, $postconf_placeholders); + $postconf_commands = array_merge($postconf_commands, array_filter(explode("\n", $content))); + } + if(version_compare($postfix_version , '3.0', '>=')) { + $configfile = 'postfix_3-0.conf'; + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', 'tpl/'.$configfile.'.master'); + $content = strtr($content, $postconf_placeholders); + $postconf_commands = array_merge($postconf_commands, array_filter(explode("\n", $content))); + } + //* These postconf commands will be executed on installation only if($this->is_update == false) { $postconf_commands = array_merge($postconf_commands, array( diff --git a/install/tpl/postfix_2-10.conf.master b/install/tpl/postfix_2-10.conf.master new file mode 100644 index 0000000000..d77f37e0a0 --- /dev/null +++ b/install/tpl/postfix_2-10.conf.master @@ -0,0 +1,5 @@ +# Postfix configuration for version 2.10 and up +smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination + +# This is supported in version 2.9, but lets not create another conf file for it +address_verify_sender_ttl = 15686s diff --git a/install/tpl/postfix_2-5.conf.master b/install/tpl/postfix_2-5.conf.master new file mode 100644 index 0000000000..398dc6393c --- /dev/null +++ b/install/tpl/postfix_2-5.conf.master @@ -0,0 +1,11 @@ +# Postfix configuration for version 2.5 and up +in_flow_delay = ${stress?3}${stress:1}s +smtp_connect_timeout = ${stress?10}${stress:30}s +smtp_helo_timeout = ${stress?10}${stress:60}s +smtp_mail_timeout = ${stress?10}${stress:60}s +smtpd_error_sleep_time = ${stress?1}${stress:2}s +smtpd_hard_error_limit = ${stress?1}${stress:10} +smtpd_recipient_overshoot_limit = ${stress?60}${stress:600} +smtpd_soft_error_limit = ${stress?2}${stress:5} +smtpd_timeout = ${stress?10}${stress:60}s + diff --git a/install/tpl/postfix_3-0.conf.master b/install/tpl/postfix_3-0.conf.master new file mode 100644 index 0000000000..a185eb6dad --- /dev/null +++ b/install/tpl/postfix_3-0.conf.master @@ -0,0 +1,11 @@ +# Postfix configuration for version 3.0 and up +in_flow_delay = ${stress?{3}:{1}}s +smtp_connect_timeout = ${stress?{10}:{30}}s +smtp_helo_timeout = ${stress?{10}:{60}}s +smtp_mail_timeout = ${stress?{10}:{60}}s +smtpd_error_sleep_time = ${stress?{1}:{2}}s +smtpd_hard_error_limit = ${stress?{1}:{10}} +smtpd_recipient_overshoot_limit = ${stress?{60}:{600}} +smtpd_soft_error_limit = ${stress?{2}:{5}} +smtpd_timeout = ${stress?{10}:{60}}s + -- GitLab