Skip to content

Commit 8cfb4fa

Browse files
committed
fix tests for when to reconfigure postfix
1 parent 2c2fa72 commit 8cfb4fa

File tree

6 files changed

+114
-128
lines changed

6 files changed

+114
-128
lines changed

install/dist/lib/centos_base.lib.php

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,28 @@ public function configure_amavis() {
8383

8484
$config_dir = $conf['postfix']['config_dir'];
8585

86-
// Adding amavis-services to the master.cf file if the service does not already exists
87-
$add_amavis = !$this->get_postfix_service('amavis','unix');
88-
$add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
89-
$add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
90-
91-
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
92-
//* backup master.cf
93-
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
94-
// adjust amavis-config
95-
if($add_amavis) {
96-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
97-
af($config_dir.'/master.cf', $content);
98-
unset($content);
99-
}
100-
if ($add_amavis_10025) {
101-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
102-
af($config_dir.'/master.cf', $content);
103-
unset($content);
104-
}
105-
if ($add_amavis_10027) {
106-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
107-
af($config_dir.'/master.cf', $content);
108-
unset($content);
109-
}
110-
}
86+
// Adding amavis-services to the master.cf file
87+
88+
// backup master.cf
89+
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
90+
91+
// first remove the old service definitions
92+
$this->remove_postfix_service('amavis','unix');
93+
$this->remove_postfix_service('127.0.0.1:10025','inet');
94+
$this->remove_postfix_service('127.0.0.1:10027','inet');
95+
96+
// then add them back
97+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
98+
af($config_dir.'/master.cf', $content);
99+
unset($content);
100+
101+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
102+
af($config_dir.'/master.cf', $content);
103+
unset($content);
104+
105+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
106+
af($config_dir.'/master.cf', $content);
107+
unset($content);
111108

112109
removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn # REMOVE ME', 1);
113110
replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1);

install/dist/lib/fedora.lib.php

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -330,31 +330,28 @@ public function configure_amavis() {
330330

331331
$config_dir = $conf['postfix']['config_dir'];
332332

333-
// Adding amavis-services to the master.cf file if the service does not already exists
334-
$add_amavis = !$this->get_postfix_service('amavis','unix');
335-
$add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
336-
$add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
337-
338-
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
339-
//* backup master.cf
340-
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
341-
// adjust amavis-config
342-
if($add_amavis) {
343-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
344-
af($config_dir.'/master.cf', $content);
345-
unset($content);
346-
}
347-
if ($add_amavis_10025) {
348-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
349-
af($config_dir.'/master.cf', $content);
350-
unset($content);
351-
}
352-
if ($add_amavis_10027) {
353-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
354-
af($config_dir.'/master.cf', $content);
355-
unset($content);
356-
}
357-
}
333+
// Adding amavis-services to the master.cf file
334+
335+
// backup master.cf
336+
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
337+
338+
// first remove the old service definitions
339+
$this->remove_postfix_service('amavis','unix');
340+
$this->remove_postfix_service('127.0.0.1:10025','inet');
341+
$this->remove_postfix_service('127.0.0.1:10027','inet');
342+
343+
// then add them back
344+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
345+
af($config_dir.'/master.cf', $content);
346+
unset($content);
347+
348+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
349+
af($config_dir.'/master.cf', $content);
350+
unset($content);
351+
352+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
353+
af($config_dir.'/master.cf', $content);
354+
unset($content);
358355

359356
removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn # REMOVE ME', 1);
360357
replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1);

install/dist/lib/gentoo.lib.php

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -444,31 +444,28 @@ public function configure_amavis()
444444

445445
$config_dir = $conf['postfix']['config_dir'];
446446

447-
// Adding amavis-services to the master.cf file if the service does not already exists
448-
$add_amavis = !$this->get_postfix_service('amavis','unix');
449-
$add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
450-
$add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
451-
452-
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
453-
//* backup master.cf
454-
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
455-
// adjust amavis-config
456-
if($add_amavis) {
457-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
458-
af($config_dir.'/master.cf', $content);
459-
unset($content);
460-
}
461-
if ($add_amavis_10025) {
462-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
463-
af($config_dir.'/master.cf', $content);
464-
unset($content);
465-
}
466-
if ($add_amavis_10027) {
467-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
468-
af($config_dir.'/master.cf', $content);
469-
unset($content);
470-
}
471-
}
447+
// Adding amavis-services to the master.cf file
448+
449+
// backup master.cf
450+
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
451+
452+
// first remove the old service definitions
453+
$this->remove_postfix_service('amavis','unix');
454+
$this->remove_postfix_service('127.0.0.1:10025','inet');
455+
$this->remove_postfix_service('127.0.0.1:10027','inet');
456+
457+
// then add them back
458+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
459+
af($config_dir.'/master.cf', $content);
460+
unset($content);
461+
462+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
463+
af($config_dir.'/master.cf', $content);
464+
unset($content);
465+
466+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
467+
af($config_dir.'/master.cf', $content);
468+
unset($content);
472469

473470
//* Add the clamav user to the amavis group
474471
exec('usermod -a -G amavis clamav');

install/dist/lib/opensuse.lib.php

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -513,31 +513,28 @@ public function configure_amavis() {
513513

514514
$config_dir = $conf['postfix']['config_dir'];
515515

516-
// Adding amavis-services to the master.cf file if the service does not already exists
517-
$add_amavis = !$this->get_postfix_service('amavis','unix');
518-
$add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
519-
$add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
520-
521-
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
522-
//* backup master.cf
523-
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
524-
// adjust amavis-config
525-
if($add_amavis) {
526-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
527-
af($config_dir.'/master.cf', $content);
528-
unset($content);
529-
}
530-
if ($add_amavis_10025) {
531-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
532-
af($config_dir.'/master.cf', $content);
533-
unset($content);
534-
}
535-
if ($add_amavis_10027) {
536-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
537-
af($config_dir.'/master.cf', $content);
538-
unset($content);
539-
}
540-
}
516+
// Adding amavis-services to the master.cf file
517+
518+
// backup master.cf
519+
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
520+
521+
// first remove the old service definitions
522+
$this->remove_postfix_service('amavis','unix');
523+
$this->remove_postfix_service('127.0.0.1:10025','inet');
524+
$this->remove_postfix_service('127.0.0.1:10027','inet');
525+
526+
// then add them back
527+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
528+
af($config_dir.'/master.cf', $content);
529+
unset($content);
530+
531+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
532+
af($config_dir.'/master.cf', $content);
533+
unset($content);
534+
535+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
536+
af($config_dir.'/master.cf', $content);
537+
unset($content);
541538

542539
// Add the clamav user to the vscan group
543540
//exec('groupmod --add-user clamav vscan');

install/lib/installer_base.lib.php

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,32 +1720,28 @@ public function configure_amavis() {
17201720
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
17211721
}
17221722

1723-
// Adding amavis-services to the master.cf file if the service does not already exists
1724-
// (just remove the old service definitions and add them again)
1725-
$add_amavis = $this->remove_postfix_service('amavis','unix');
1726-
$add_amavis_10025 = $this->remove_postfix_service('127.0.0.1:10025','inet');
1727-
$add_amavis_10027 = $this->remove_postfix_service('127.0.0.1:10027','inet');
1728-
1729-
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
1730-
//* backup master.cf
1731-
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
1732-
// adjust amavis-config
1733-
if($add_amavis) {
1734-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
1735-
af($config_dir.'/master.cf', $content);
1736-
unset($content);
1737-
}
1738-
if ($add_amavis_10025) {
1739-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
1740-
af($config_dir.'/master.cf', $content);
1741-
unset($content);
1742-
}
1743-
if ($add_amavis_10027) {
1744-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
1745-
af($config_dir.'/master.cf', $content);
1746-
unset($content);
1747-
}
1748-
}
1723+
// Adding amavis-services to the master.cf file
1724+
1725+
// backup master.cf
1726+
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
1727+
1728+
// first remove the old service definitions
1729+
$this->remove_postfix_service('amavis','unix');
1730+
$this->remove_postfix_service('127.0.0.1:10025','inet');
1731+
$this->remove_postfix_service('127.0.0.1:10027','inet');
1732+
1733+
// then add them back
1734+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
1735+
af($config_dir.'/master.cf', $content);
1736+
unset($content);
1737+
1738+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
1739+
af($config_dir.'/master.cf', $content);
1740+
unset($content);
1741+
1742+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
1743+
af($config_dir.'/master.cf', $content);
1744+
unset($content);
17491745
}
17501746

17511747
// Add the clamav user to the amavis group

server/plugins-available/postfix_server_plugin.inc.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,9 @@ function update($event_name, $data) {
332332
}
333333
}
334334

335-
$quoted_postfix_config_dir = preg_quote($conf['postfix']['config_dir'], '|');
335+
$config_dir = exec("postconf -h config_directory");
336+
$quoted_postfix_config_dir = preg_quote($config_dir, '|');
337+
336338
$new_options = array();
337339
$options = preg_split("/,\s*/", exec("postconf -h smtpd_recipient_restrictions"));
338340
foreach ($options as $key => $value) {
@@ -343,7 +345,7 @@ function update($event_name, $data) {
343345
}
344346
$new_options[] = $value;
345347
}
346-
if (defined($configure_lmtp) && $configure_lmtp && $mail_config['content_filter'] == 'amavisd') {
348+
if (isset($configure_lmtp) && $configure_lmtp && $mail_config['content_filter'] == 'amavisd') {
347349
for ($i = 0; isset($new_options[$i]); $i++) {
348350
if ($new_options[$i] == 'reject_unlisted_recipient') {
349351
array_splice($new_options, $i+1, 0, array("check_recipient_access proxy:mysql:${quoted_postfix_config_dir}/mysql-verify_recipients.cf"));

0 commit comments

Comments
 (0)