From f9ba7fe6f258a2e071a1864c01b55c42b8a9b8cc Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Fri, 4 Nov 2022 23:23:12 +0100 Subject: [PATCH] Fix undefined $postfix_version and generalize code, #6405 --- install/lib/installer_base.lib.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 6cc4de996a..be78cb6351 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1071,6 +1071,14 @@ class installer_base { return true; } + public function get_postfix_version() { + //* Get postfix version + exec('postconf -d mail_version 2>&1', $out); + $postfix_version = preg_replace('/.*=\s*/', '', $out[0]); + unset($out); + return $postfix_version; + } + public function configure_postfix($options = '') { global $conf,$autoinstall; $cf = $conf['postfix']; @@ -1080,10 +1088,7 @@ class installer_base { $this->error("The postfix configuration directory '$config_dir' does not exist."); } - //* Get postfix version - exec('postconf -d mail_version 2>&1', $out); - $postfix_version = preg_replace('/.*=\s*/', '', $out[0]); - unset($out); + $postfix_version = $this->get_postfix_version(); //* Install virtual mappings foreach (glob('tpl/mysql-virtual_*.master') as $filename) { @@ -1482,8 +1487,7 @@ class installer_base { $config_dir = $conf['postfix']['config_dir']; $quoted_config_dir = preg_quote($config_dir, '|'); - $postfix_version = `postconf -d mail_version 2>/dev/null`; - $postfix_version = preg_replace( '/mail_version\s*=\s*(.*)\s*/', '$1', $postfix_version ); + $postfix_version = $this->get_postfix_version(); //* Configure master.cf and add a line for deliver if(!$this->get_postfix_service('dovecot', 'unix')) { @@ -1725,6 +1729,7 @@ class installer_base { break; } } + $postfix_version = $this->get_postfix_version(); # postfix < 3.3 needs this when using reject_unverified_recipient: if(version_compare($postfix_version, 3.3, '<')) { $postconf_commands[] = "enable_original_recipient = yes"; -- GitLab