Skip to content

Commit e296394

Browse files
author
Marius Cramer
committed
Merge branch 'master' into 'master'
Master See merge request !209
2 parents 374226a + c12031b commit e296394

File tree

7 files changed

+359
-208
lines changed

7 files changed

+359
-208
lines changed

install/dist/lib/centos_base.lib.php

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,46 @@ public function configure_amavis() {
6767
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
6868
}
6969

70-
// Append the configuration for amavisd to the master.cf file
71-
if(is_file($conf['postfix']['config_dir'].'/master.cf')) copy($conf['postfix']['config_dir'].'/master.cf', $conf['postfix']['config_dir'].'/master.cf~');
72-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
73-
// Only add the content if we had not addded it before
74-
if(!preg_match('/^amavis\s+unix\s+/m', $content)) {
75-
unset($content);
76-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
77-
af($conf['postfix']['config_dir'].'/master.cf', $content);
70+
$config_dir = $conf['postfix']['config_dir'];
71+
72+
// Adding amavis-services to the master.cf file if the service does not already exists
73+
if ($this->postfix_master()) {
74+
exec ("postconf -M amavis.unix", $out, $ret);
75+
$add_amavis = @($out[0]=='')?true:false;
76+
unset($out);
77+
exec ("postconf -M 127.0.0.1:10025.inet", $out, $ret);
78+
$add_amavis_10025 = @($out[0]=='')?true:false;
79+
unset($out);
80+
exec ("postconf -M 127.0.0.1:10027.inet", $out, $ret);
81+
$add_amavis_10027 = @($out[0]=='')?true:false;
82+
unset($out);
83+
} else { //* fallback - postfix < 2.9
7884
$content = rf($conf['postfix']['config_dir'].'/master.cf');
85+
$add_amavis = @(!preg_match('/^amavis\s+unix\s+/m', $content))?true:false;
86+
$add_amavis_10025 = @(!preg_match('/^127.0.0.1:10025\s+/m', $content))?true:false;
87+
$add_amavis_10027 = @(!preg_match('/^127.0.0.1:10027\s+/m', $content))?true:false;
7988
}
80-
if(!preg_match('/^127.0.0.1:10025\s+/m', $content)) {
81-
unset($content);
82-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
83-
af($conf['postfix']['config_dir'].'/master.cf', $content);
84-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
85-
}
86-
if(!preg_match('/^127.0.0.1:10027\s+/m', $content)) {
87-
unset($content);
88-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
89-
af($conf['postfix']['config_dir'].'/master.cf', $content);
89+
90+
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
91+
//* backup master.cf
92+
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
93+
// adjust amavis-config
94+
if($add_amavis) {
95+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
96+
af($config_dir.'/master.cf', $content);
97+
unset($content);
98+
}
99+
if ($add_amavis_10025) {
100+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
101+
af($config_dir.'/master.cf', $content);
102+
unset($content);
103+
}
104+
if ($add_amavis_10027) {
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);
108+
}
90109
}
91-
unset($content);
92110

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

install/dist/lib/debian60.lib.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,30 @@ public function configure_dovecot()
5050
}
5151
}
5252

53-
$config_dir = $conf['dovecot']['config_dir'];
54-
53+
$config_dir = $conf['postfix']['config_dir'];
5554
//* Configure master.cf and add a line for deliver
56-
if(is_file($config_dir.'/master.cf')){
57-
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
55+
if ($this->postfix_master()) {
56+
exec ("postconf -M dovecot.unix", $out, $ret);
57+
$add_dovecot_service = @($out[0]=='')?true:false;
58+
} else { //* fallback - postfix < 2.9
59+
$content = rf($config_dir.'/master.cf');
60+
$add_dovecot_service = @(!stristr($content, "dovecot/deliver"))?true:false;
5861
}
59-
if(is_file($config_dir.'/master.cf~')){
60-
chmod($config_dir.'/master.cf~2', 0400);
61-
}
62-
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
63-
// Only add the content if we had not addded it before
64-
if(!stristr($content, "dovecot/deliver")) {
62+
if($add_dovecot_service) {
63+
//* backup
64+
if(is_file($config_dir.'/master.cf')){
65+
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
66+
}
67+
if(is_file($config_dir.'/master.cf~')){
68+
chmod($config_dir.'/master.cf~2', 0400);
69+
}
70+
//* Configure master.cf and add a line for deliver
71+
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
6572
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
66-
af($conf["postfix"]["config_dir"].'/master.cf', $deliver_content);
73+
af($config_dir.'/master.cf', $deliver_content);
74+
unset($content);
75+
unset($deliver_content);
6776
}
68-
unset($content);
69-
unset($deliver_content);
70-
7177

7278
//* Reconfigure postfix to use dovecot authentication
7379
// Adding the amavisd commands to the postfix configuration
@@ -88,6 +94,7 @@ public function configure_dovecot()
8894
}
8995

9096
//* copy dovecot.conf
97+
$config_dir = $conf['dovecot']['config_dir'];
9198
$configfile = 'dovecot.conf';
9299
if(is_file($config_dir.'/'.$configfile)){
93100
copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');

install/dist/lib/fedora.lib.php

Lines changed: 61 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -349,27 +349,30 @@ public function configure_dovecot()
349349
}
350350
}
351351

352-
$config_dir = $conf['dovecot']['config_dir'];
353-
354-
//* Use /etc/dovecot as config dir if exists
355-
if(is_dir('/etc/dovecot')) $config_dir = '/etc/dovecot';
356-
352+
$config_dir = $conf['postfix']['config_dir'];
357353
//* Configure master.cf and add a line for deliver
358-
if(is_file($config_dir.'/master.cf')){
359-
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
360-
}
361-
if(is_file($config_dir.'/master.cf~')){
362-
exec('chmod 400 '.$config_dir.'/master.cf~2');
354+
if ($this->postfix_master()) {
355+
exec ("postconf -M dovecot.unix", $out, $ret);
356+
$add_dovecot_service = @($out[0]=='')?true:false;
357+
} else { //* fallback - postfix < 2.9
358+
$content = rf($config_dir'/master.cf');
359+
$add_dovecot_service = @(!stristr($content, "dovecot/deliver"))?true:false;
363360
}
364-
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
365-
// Only add the content if we had not addded it before
366-
if(!stristr($content, "dovecot/deliver")) {
367-
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DROhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
361+
if($add_dovecot_service) {
362+
//* backup
363+
if(is_file($config_dir.'/master.cf')){
364+
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
365+
}
366+
if(is_file($config_dir.'/master.cf~')){
367+
chmod($config_dir.'/master.cf~2', 0400);
368+
}
369+
//* Configure master.cf and add a line for deliver
370+
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
371+
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
368372
af($conf["postfix"]["config_dir"].'/master.cf', $deliver_content);
373+
unset($content);
374+
unset($deliver_content);
369375
}
370-
unset($content);
371-
unset($deliver_content);
372-
373376

374377
//* Reconfigure postfix to use dovecot authentication
375378
// Adding the amavisd commands to the postfix configuration
@@ -389,6 +392,10 @@ public function configure_dovecot()
389392
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
390393
}
391394

395+
//* Use /etc/dovecot as config dir if exists
396+
// if(is_dir('/etc/dovecot')) $config_dir = '/etc/dovecot';
397+
$config_dir = $conf['dovecot']['config_dir'];
398+
392399
//* backup dovecot.conf
393400
$configfile = 'dovecot.conf';
394401
if(is_file("$config_dir/$configfile")){
@@ -482,28 +489,46 @@ public function configure_amavis() {
482489
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
483490
}
484491

485-
// Append the configuration for amavisd to the master.cf file
486-
if(is_file($conf['postfix']['config_dir'].'/master.cf')) copy($conf['postfix']['config_dir'].'/master.cf', $conf['postfix']['config_dir'].'/master.cf~');
487-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
488-
// Only add the content if we had not addded it before
489-
if(!preg_match('/^amavis\s+unix\s+/m', $content)) {
490-
unset($content);
491-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
492-
af($conf['postfix']['config_dir'].'/master.cf', $content);
493-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
494-
}
495-
if(!preg_match('/^127.0.0.1:10025\s+/m', $content)) {
496-
unset($content);
497-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
498-
af($conf['postfix']['config_dir'].'/master.cf', $content);
492+
$config_dir = $conf['postfix']['config_dir'];
493+
494+
// Adding amavis-services to the master.cf file if the service does not already exists
495+
if ($this->postfix_master()) {
496+
exec ("postconf -M amavis.unix", $out, $ret);
497+
$add_amavis = @($out[0]=='')?true:false;
498+
unset($out);
499+
exec ("postconf -M 127.0.0.1:10025.inet", $out, $ret);
500+
$add_amavis_10025 = @($out[0]=='')?true:false;
501+
unset($out);
502+
exec ("postconf -M 127.0.0.1:10027.inet", $out, $ret);
503+
$add_amavis_10027 = @($out[0]=='')?true:false;
504+
unset($out);
505+
} else { //* fallback - postfix < 2.9
499506
$content = rf($conf['postfix']['config_dir'].'/master.cf');
507+
$add_amavis = @(!preg_match('/^amavis\s+unix\s+/m', $content))?true:false;
508+
$add_amavis_10025 = @(!preg_match('/^127.0.0.1:10025\s+/m', $content))?true:false;
509+
$add_amavis_10027 = @(!preg_match('/^127.0.0.1:10027\s+/m', $content))?true:false;
500510
}
501-
if(!preg_match('/^127.0.0.1:10027\s+/m', $content)) {
502-
unset($content);
503-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
504-
af($conf['postfix']['config_dir'].'/master.cf', $content);
511+
512+
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
513+
//* backup master.cf
514+
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
515+
// adjust amavis-config
516+
if($add_amavis) {
517+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
518+
af($config_dir.'/master.cf', $content);
519+
unset($content);
520+
}
521+
if ($add_amavis_10025) {
522+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
523+
af($config_dir.'/master.cf', $content);
524+
unset($content);
525+
}
526+
if ($add_amavis_10027) {
527+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
528+
af($config_dir.'/master.cf', $content);
529+
unset($content);
530+
}
505531
}
506-
unset($content);
507532

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

install/dist/lib/gentoo.lib.php

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -270,27 +270,30 @@ public function configure_dovecot()
270270
}
271271
}
272272

273-
$config_dir = $conf['dovecot']['config_dir'];
274-
275-
$configfile = $conf['postfix']['config_dir'].'/master.cf';
276-
277-
if(is_file($configfile)) {
278-
copy($configfile, $configfile.'~2');
279-
}
280-
if(is_file($configfile.'~2')) {
281-
chmod($configfile.'~2', 0400);
282-
}
283-
273+
$config_dir = $conf['postfix']['config_dir'];
284274
//* Configure master.cf and add a line for deliver
285-
$content = rf($configfile);
286-
287-
if(!stristr($content, 'dovecot/deliver')) {
275+
if ($this->postfix_master()) {
276+
exec ("postconf -M dovecot.unix", $out, $ret);
277+
$add_dovecot_service = @($out[0]=='')?true:false;
278+
} else { //* fallback - postfix < 2.9
279+
$content = rf($config_dir.'/master.cf');
280+
$add_dovecot_service = @(!stristr($content, "dovecot/deliver"))?true:false;
281+
}
282+
if($add_dovecot_service) {
283+
//* backup
284+
if(is_file($config_dir.'/master.cf')){
285+
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
286+
}
287+
if(is_file($config_dir.'/master.cf~')){
288+
chmod($config_dir.'/master.cf~2', 0400);
289+
}
290+
//* Configure master.cf and add a line for deliver
291+
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
288292
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DROhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
289-
af($conf['postfix']['config_dir'].'/master.cf', $deliver_content);
293+
af($conf[$config_dir.'/master.cf', $deliver_content);
294+
unset($content);
295+
unset($deliver_content);
290296
}
291-
unset($content);
292-
unset($deliver_content);
293-
unset($configfile);
294297

295298
//* Reconfigure postfix to use dovecot authentication
296299
$postconf_commands = array (
@@ -310,6 +313,7 @@ public function configure_dovecot()
310313
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
311314
}
312315

316+
$config_dir = $conf['dovecot']['config_dir'];
313317
//* copy dovecot.conf
314318
$configfile = $config_dir.'/dovecot.conf';
315319
$content = $this->get_template_file('dovecot.conf', true);
@@ -387,27 +391,46 @@ public function configure_amavis()
387391
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
388392
}
389393

390-
// Append the configuration for amavisd to the master.cf file
391-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
392-
// Only add the content if we had not addded it before
393-
if(!preg_match('/^amavis\s+unix\s+/m', $content)) {
394-
unset($content);
395-
$content = $this->get_template_file('master_cf_amavis', true);
396-
af($conf['postfix']['config_dir'].'/master.cf', $content);
397-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
398-
}
399-
if(!preg_match('/^127.0.0.1:10025\s+/m', $content)) {
400-
unset($content);
401-
$content = $this->get_template_file('master_cf_amavis10025', true);
402-
af($conf['postfix']['config_dir'].'/master.cf', $content);
394+
$config_dir = $conf['postfix']['config_dir'];
395+
396+
// Adding amavis-services to the master.cf file if the service does not already exists
397+
if ($this->postfix_master()) {
398+
exec ("postconf -M amavis.unix", $out, $ret);
399+
$add_amavis = @($out[0]=='')?true:false;
400+
unset($out);
401+
exec ("postconf -M 127.0.0.1:10025.inet", $out, $ret);
402+
$add_amavis_10025 = @($out[0]=='')?true:false;
403+
unset($out);
404+
exec ("postconf -M 127.0.0.1:10027.inet", $out, $ret);
405+
$add_amavis_10027 = @($out[0]=='')?true:false;
406+
unset($out);
407+
} else { //* fallback - postfix < 2.9
403408
$content = rf($conf['postfix']['config_dir'].'/master.cf');
409+
$add_amavis = @(!preg_match('/^amavis\s+unix\s+/m', $content))?true:false;
410+
$add_amavis_10025 = @(!preg_match('/^127.0.0.1:10025\s+/m', $content))?true:false;
411+
$add_amavis_10027 = @(!preg_match('/^127.0.0.1:10027\s+/m', $content))?true:false;
412+
}
413+
414+
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
415+
//* backup master.cf
416+
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
417+
// adjust amavis-config
418+
if($add_amavis) {
419+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
420+
af($config_dir.'/master.cf', $content);
421+
unset($content);
422+
}
423+
if ($add_amavis_10025) {
424+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
425+
af($config_dir.'/master.cf', $content);
426+
unset($content);
427+
}
428+
if ($add_amavis_10027) {
429+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
430+
af($config_dir.'/master.cf', $content);
431+
unset($content);
432+
}
404433
}
405-
if(!preg_match('/^127.0.0.1:10027\s+/m', $content)) {
406-
unset($content);
407-
$content = $this->get_template_file('master_cf_amavis10027', true);
408-
af($conf['postfix']['config_dir'].'/master.cf', $content);
409-
}
410-
unset($content);
411434

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

0 commit comments

Comments
 (0)