Skip to content

Commit 51e1dde

Browse files
author
Marius Burkard
committed
Merge branch 'master' into 'stable-3.1'
fixed installer - ispconfig/ispconfig3#3750 Fixes #3750 See merge request !277
2 parents 4b6c4d6 + adfecbf commit 51e1dde

File tree

6 files changed

+53
-135
lines changed

6 files changed

+53
-135
lines changed

install/dist/lib/centos_base.lib.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,9 @@ public function configure_amavis() {
7070
$config_dir = $conf['postfix']['config_dir'];
7171

7272
// 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 &> /dev/null", $out, $ret);
75-
$add_amavis = @($out[0]=='')?true:false;
76-
unset($out);
77-
exec ("postconf -M 127.0.0.1:10025.inet &> /dev/null", $out, $ret);
78-
$add_amavis_10025 = @($out[0]=='')?true:false;
79-
unset($out);
80-
exec ("postconf -M 127.0.0.1:10027.inet &> /dev/null", $out, $ret);
81-
$add_amavis_10027 = @($out[0]=='')?true:false;
82-
unset($out);
83-
} else { //* fallback - postfix < 2.9
84-
$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;
88-
}
73+
$add_amavis = !$this->get_postfix_service('amavis','unix');
74+
$add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
75+
$add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
8976

9077
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
9178
//* backup master.cf

install/dist/lib/debian60.lib.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ public function configure_dovecot()
5151
}
5252

5353
$config_dir = $conf['postfix']['config_dir'];
54-
//* Configure master.cf and add a line for deliver
55-
if ($this->postfix_master()) {
56-
exec ("postconf -M dovecot.unix &> /dev/null", $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;
61-
}
62-
if($add_dovecot_service) {
54+
if(!$this->get_postfix_service('dovecot', 'unix')) {
6355
//* backup
6456
if(is_file($config_dir.'/master.cf')){
6557
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
@@ -69,7 +61,7 @@ public function configure_dovecot()
6961
}
7062
//* Configure master.cf and add a line for deliver
7163
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
72-
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
64+
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'."\n";
7365
af($config_dir.'/master.cf', $deliver_content);
7466
unset($content);
7567
unset($deliver_content);

install/dist/lib/fedora.lib.php

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,9 @@ public function configure_dovecot()
350350
}
351351

352352
$config_dir = $conf['postfix']['config_dir'];
353+
353354
//* Configure master.cf and add a line for deliver
354-
if ($this->postfix_master()) {
355-
exec ("postconf -M dovecot.unix &> /dev/null", $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;
360-
}
361-
if($add_dovecot_service) {
355+
if(!$this->get_postfix_service('dovecot', 'unix')) {
362356
//* backup
363357
if(is_file($config_dir.'/master.cf')){
364358
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
@@ -368,7 +362,7 @@ public function configure_dovecot()
368362
}
369363
//* Configure master.cf and add a line for deliver
370364
$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}';
365+
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'."\n";
372366
af($conf["postfix"]["config_dir"].'/master.cf', $deliver_content);
373367
unset($content);
374368
unset($deliver_content);
@@ -492,22 +486,9 @@ public function configure_amavis() {
492486
$config_dir = $conf['postfix']['config_dir'];
493487

494488
// 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 &> /dev/null", $out, $ret);
497-
$add_amavis = @($out[0]=='')?true:false;
498-
unset($out);
499-
exec ("postconf -M 127.0.0.1:10025.inet &> /dev/null", $out, $ret);
500-
$add_amavis_10025 = @($out[0]=='')?true:false;
501-
unset($out);
502-
exec ("postconf -M 127.0.0.1:10027.inet &> /dev/null", $out, $ret);
503-
$add_amavis_10027 = @($out[0]=='')?true:false;
504-
unset($out);
505-
} else { //* fallback - postfix < 2.9
506-
$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;
510-
}
489+
$add_amavis = !$this->get_postfix_service('amavis','unix');
490+
$add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
491+
$add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
511492

512493
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
513494
//* backup master.cf

install/dist/lib/gentoo.lib.php

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,9 @@ public function configure_dovecot()
271271
}
272272

273273
$config_dir = $conf['postfix']['config_dir'];
274+
274275
//* Configure master.cf and add a line for deliver
275-
if ($this->postfix_master()) {
276-
exec ("postconf -M dovecot.unix &> /dev/null", $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) {
276+
if(!$this->get_postfix_service('dovecot', 'unix')) {
283277
//* backup
284278
if(is_file($config_dir.'/master.cf')){
285279
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
@@ -289,7 +283,7 @@ public function configure_dovecot()
289283
}
290284
//* Configure master.cf and add a line for deliver
291285
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
292-
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DROhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
286+
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DROhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'."\n";
293287
af($config_dir.'/master.cf', $deliver_content);
294288
unset($content);
295289
unset($deliver_content);
@@ -394,22 +388,9 @@ public function configure_amavis()
394388
$config_dir = $conf['postfix']['config_dir'];
395389

396390
// 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 &> /dev/null", $out, $ret);
399-
$add_amavis = @($out[0]=='')?true:false;
400-
unset($out);
401-
exec ("postconf -M 127.0.0.1:10025.inet &> /dev/null", $out, $ret);
402-
$add_amavis_10025 = @($out[0]=='')?true:false;
403-
unset($out);
404-
exec ("postconf -M 127.0.0.1:10027.inet &> /dev/null", $out, $ret);
405-
$add_amavis_10027 = @($out[0]=='')?true:false;
406-
unset($out);
407-
} else { //* fallback - postfix < 2.9
408-
$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-
}
391+
$add_amavis = !$this->get_postfix_service('amavis','unix');
392+
$add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
393+
$add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
413394

414395
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
415396
//* backup master.cf

install/dist/lib/opensuse.lib.php

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ function configure_postfix($options = '')
228228
//* Check maildrop service in posfix master.cf
229229
$regex = "/^maildrop unix.*pipe flags=DRhu user=vmail argv=\\/usr\\/bin\\/maildrop -d ".$cf['vmail_username']." \\$\{extension} \\$\{recipient} \\$\{user} \\$\{nexthop} \\$\{sender}/";
230230
$configfile = $config_dir.'/master.cf';
231-
if ($this->postfix_master()) {
231+
if($this->get_postfix_service('maildrop', 'unix')) {
232232
exec ("postconf -M maildrop.unix &> /dev/null", $out, $ret);
233233
$change_maildrop_flags = @(preg_match($regex, $out[0]) && $out[0] !='')?false:true;
234-
} else { //* fallback - postfix < 2.9
234+
} else {
235235
$change_maildrop_flags = @(preg_match($regex, $configfile))?false:true;
236236
}
237237
if ($change_maildrop_flags) {
@@ -365,15 +365,9 @@ public function configure_dovecot()
365365
}
366366

367367
$config_dir = $conf['postfix']['config_dir'];
368+
368369
//* Configure master.cf and add a line for deliver
369-
if ($this->postfix_master()) {
370-
exec ("postconf -M dovecot.unix &> /dev/null", $out, $ret);
371-
$add_dovecot_service = @($out[0]=='')?true:false;
372-
} else { //* fallback - postfix < 2.9
373-
$content = rf($config_dir.'/master.cf');
374-
$add_dovecot_service = @(!stristr($content, "dovecot/deliver"))?true:false;
375-
}
376-
if($add_dovecot_service) {
370+
if(!$this->get_postfix_service('dovecot', 'unix')) {
377371
//* backup
378372
if(is_file($config_dir.'/master.cf')){
379373
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
@@ -383,7 +377,7 @@ public function configure_dovecot()
383377
}
384378
//* Configure master.cf and add a line for deliver
385379
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
386-
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
380+
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'."\n";
387381
af($conf["postfix"]["config_dir"].'/master.cf', $deliver_content);
388382
unset($content);
389383
unset($deliver_content);
@@ -502,22 +496,9 @@ public function configure_amavis() {
502496
$config_dir = $conf['postfix']['config_dir'];
503497

504498
// Adding amavis-services to the master.cf file if the service does not already exists
505-
if ($this->postfix_master()) {
506-
exec ("postconf -M amavis.unix &> /dev/null", $out, $ret);
507-
$add_amavis = @($out[0]=='')?true:false;
508-
unset($out);
509-
exec ("postconf -M 127.0.0.1:10025.inet &> /dev/null", $out, $ret);
510-
$add_amavis_10025 = @($out[0]=='')?true:false;
511-
unset($out);
512-
exec ("postconf -M 127.0.0.1:10027.inet &> /dev/null", $out, $ret);
513-
$add_amavis_10027 = @($out[0]=='')?true:false;
514-
unset($out);
515-
} else { //* fallback - postfix < 2.9
516-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
517-
$add_amavis = @(!preg_match('/^amavis\s+unix\s+/m', $content))?true:false;
518-
$add_amavis_10025 = @(!preg_match('/^127.0.0.1:10025\s+/m', $content))?true:false;
519-
$add_amavis_10027 = @(!preg_match('/^127.0.0.1:10027\s+/m', $content))?true:false;
520-
}
499+
$add_amavis = !$this->get_postfix_service('amavis','unix');
500+
$add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
501+
$add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
521502

522503
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
523504
//* backup master.cf

install/lib/installer_base.lib.php

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,25 @@ public function configure_mailman($status = 'insert') {
793793
exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman');
794794
}
795795

796-
//* with postfix >= 2.9 we can detect configured services with postconf
797-
public function postfix_master() {
798-
exec("postconf -M", $out, $ret);
799-
return $ret===0?true:false;
796+
public function get_postfix_service($service, $type) {
797+
global $conf;
798+
799+
exec("postconf -M", $out, $ret);
800+
801+
if ($ret === 0) { //* with postfix >= 2.9 we can detect configured services with postconf
802+
unset($out);
803+
exec ("postconf -M $service/$type 2> /dev/null", $out, $ret); //* Postfix >= 2.11
804+
if (!isset($out[0])) { //* try Postfix 2.9
805+
exec ("postconf -M $service.$type 2> /dev/null", $out, $ret);
806+
}
807+
$postfix_service = @($out[0]=='')?false:true;
808+
} else { //* fallback - Postfix < 2.9
809+
rf($conf['postfix']['config_dir'].'/master.cf');
810+
$regex = '/[^#]'.$service.'.*.'.$type.'.*/';
811+
$postfix_service = @(!preg_match($regex, $content))?true:false;
812+
}
813+
814+
return $postfix_service;
800815
}
801816

802817
public function configure_postfix($options = '') {
@@ -988,10 +1003,10 @@ public function configure_postfix($options = '') {
9881003
//* Check maildrop service in posfix master.cf
9891004
$regex = "/^maildrop unix.*pipe flags=DRhu user=vmail argv=\\/usr\\/bin\\/maildrop -d ".$cf['vmail_username']." \\$\{extension} \\$\{recipient} \\$\{user} \\$\{nexthop} \\$\{sender}/";
9901005
$configfile = $config_dir.'/master.cf';
991-
if ($this->postfix_master()) {
1006+
if($this->get_postfix_service('maildrop', 'unix')) {
9921007
exec ("postconf -M maildrop.unix &> /dev/null", $out, $ret);
9931008
$change_maildrop_flags = @(preg_match($regex, $out[0]) && $out[0] !='')?false:true;
994-
} else { //* fallback - postfix < 2.9
1009+
} else {
9951010
$change_maildrop_flags = @(preg_match($regex, $configfile))?false:true;
9961011
}
9971012
if ($change_maildrop_flags) {
@@ -1167,15 +1182,9 @@ public function configure_dovecot() {
11671182
}
11681183

11691184
$config_dir = $conf['postfix']['config_dir'];
1185+
11701186
//* Configure master.cf and add a line for deliver
1171-
if ($this->postfix_master()) {
1172-
exec ("postconf -M dovecot.unix &> /dev/null", $out, $ret);
1173-
$add_dovecot_service = @($out[0]=='')?true:false;
1174-
} else { //* fallback - postfix < 2.9
1175-
$content = rf($config_dir.'/master.cf');
1176-
$add_dovecot_service = @(!stristr($content, "dovecot/deliver"))?true:false;
1177-
}
1178-
if($add_dovecot_service) {
1187+
if(!$this->get_postfix_service('dovecot', 'unix')) {
11791188
//* backup
11801189
if(is_file($config_dir.'/master.cf')){
11811190
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
@@ -1185,7 +1194,7 @@ public function configure_dovecot() {
11851194
}
11861195
//* Configure master.cf and add a line for deliver
11871196
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
1188-
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
1197+
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'."\n";
11891198
af($config_dir.'/master.cf', $deliver_content);
11901199
unset($content);
11911200
unset($deliver_content);
@@ -1307,25 +1316,12 @@ public function configure_amavis() {
13071316
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
13081317
}
13091318

1310-
$config_dir = $conf['postfix'];
1319+
$config_dir = $conf['postfix']['config_dir'];
13111320

13121321
// Adding amavis-services to the master.cf file if the service does not already exists
1313-
if ($this->postfix_master()) {
1314-
exec ("postconf -M amavis.unix &> /dev/null", $out, $ret);
1315-
$add_amavis = @($out[0]=='')?true:false;
1316-
unset($out);
1317-
exec ("postconf -M 127.0.0.1:10025.inet &> /dev/null", $out, $ret);
1318-
$add_amavis_10025 = @($out[0]=='')?true:false;
1319-
unset($out);
1320-
exec ("postconf -M 127.0.0.1:10027.inet &> /dev/null", $out, $ret);
1321-
$add_amavis_10027 = @($out[0]=='')?true:false;
1322-
unset($out);
1323-
} else { //* fallback - postfix < 2.9
1324-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
1325-
$add_amavis = @(!preg_match('/^amavis\s+unix\s+/m', $content))?true:false;
1326-
$add_amavis_10025 = @(!preg_match('/^127.0.0.1:10025\s+/m', $content))?true:false;
1327-
$add_amavis_10027 = @(!preg_match('/^127.0.0.1:10027\s+/m', $content))?true:false;
1328-
}
1322+
$add_amavis = !$this->get_postfix_service('amavis','unix');
1323+
$add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
1324+
$add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
13291325

13301326
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
13311327
//* backup master.cf

0 commit comments

Comments
 (0)