From 74d5e1a58d403fcc4474cec3187cd5f3ca72f12e Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Thu, 08 Aug 2013 03:09:35 -0400
Subject: [PATCH] - Fixed "PHP Notice:  Undefined variable: rbl_list in /tmp/ispconfig-3.0.5/install/dist/lib/fedora.lib.php on line 173" - Redirect Apache/nginx/PHP-FPM/BIND restart errors to STDOUT.

---
 server/mods-available/dns_module.inc.php        |    6 +-
 install/dist/lib/fedora.lib.php                 |   18 ++++++++
 server/plugins-available/apache2_plugin.inc.php |   22 +++++++----
 install/dist/lib/opensuse.lib.php               |   16 ++++++++
 server/mods-available/web_module.inc.php        |    6 +-
 5 files changed, 53 insertions(+), 15 deletions(-)

diff --git a/install/dist/lib/fedora.lib.php b/install/dist/lib/fedora.lib.php
index a0136f6..61130a1 100644
--- a/install/dist/lib/fedora.lib.php
+++ b/install/dist/lib/fedora.lib.php
@@ -163,7 +163,23 @@
 		if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 
 		$command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
-		if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");		
+		if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+
+		//* These postconf commands will be executed on installation and update
+		$server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']);
+		$server_ini_array = ini_to_array(stripslashes($server_ini_rec['config']));
+		unset($server_ini_rec);
+
+		//* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update
+		$rbl_list = '';
+		if (@isset($server_ini_array['mail']['realtime_blackhole_list']) && $server_ini_array['mail']['realtime_blackhole_list'] != '') {
+			$rbl_hosts = explode(",",str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list']));
+			foreach ($rbl_hosts as $key => $value) {
+				$rbl_list .= ", reject_rbl_client ". $value;
+			}
+		}
+		unset($rbl_hosts);
+		unset($server_ini_array);
 
 		//* These postconf commands will be executed on installation and update
         $postconf_placeholders = array('{config_dir}' => $config_dir,
diff --git a/install/dist/lib/opensuse.lib.php b/install/dist/lib/opensuse.lib.php
index 57b2cd6..7a2fa26 100644
--- a/install/dist/lib/opensuse.lib.php
+++ b/install/dist/lib/opensuse.lib.php
@@ -179,6 +179,22 @@
 		if($cf['vmail_mailbox_base'] != '' && strlen($cf['vmail_mailbox_base']) >= 10 && $this->is_update === false) exec('chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base']);
 		
 		//* These postconf commands will be executed on installation and update
+		$server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']);
+		$server_ini_array = ini_to_array(stripslashes($server_ini_rec['config']));
+		unset($server_ini_rec);
+
+		//* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update
+		$rbl_list = '';
+		if (@isset($server_ini_array['mail']['realtime_blackhole_list']) && $server_ini_array['mail']['realtime_blackhole_list'] != '') {
+			$rbl_hosts = explode(",",str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list']));
+			foreach ($rbl_hosts as $key => $value) {
+				$rbl_list .= ", reject_rbl_client ". $value;
+			}
+		}
+		unset($rbl_hosts);
+		unset($server_ini_array);
+		
+		//* These postconf commands will be executed on installation and update
         $postconf_placeholders = array('{config_dir}' => $config_dir,
                                        '{vmail_mailbox_base}' => $cf['vmail_mailbox_base'],
                                        '{vmail_userid}' => $cf['vmail_userid'],
diff --git a/server/mods-available/dns_module.inc.php b/server/mods-available/dns_module.inc.php
index 2fac7b5..2a06361 100644
--- a/server/mods-available/dns_module.inc.php
+++ b/server/mods-available/dns_module.inc.php
@@ -130,9 +130,9 @@
 		
 		$retval = array('output' => '', 'retval' => 0);
 		if($action == 'restart') {
-			exec($conf['init_scripts'] . '/' . $daemon . ' restart', $retval['output'], $retval['retval']);
+			exec($conf['init_scripts'] . '/' . $daemon . ' restart 2>&1', $retval['output'], $retval['retval']);
 		} else {
-			exec($conf['init_scripts'] . '/' . $daemon . ' reload', $retval['output'], $retval['retval']);
+			exec($conf['init_scripts'] . '/' . $daemon . ' reload 2>&1', $retval['output'], $retval['retval']);
 		}
 		return $retval;
 	}
@@ -179,7 +179,7 @@
 		}
 
 		$retval = array('output' => '', 'retval' => 0);
-		exec($conf['init_scripts'] . '/' . $daemon . ' restart', $retval['output'], $retval['retval']);
+		exec($conf['init_scripts'] . '/' . $daemon . ' restart 2>&1', $retval['output'], $retval['retval']);
 
 //     unset $tmps;
 		return $retval;
diff --git a/server/mods-available/web_module.inc.php b/server/mods-available/web_module.inc.php
index 52d4aed..868cf9e 100644
--- a/server/mods-available/web_module.inc.php
+++ b/server/mods-available/web_module.inc.php
@@ -212,9 +212,9 @@
 
 		$retval = array('output' => '', 'retval' => 0);
 		if($action == 'restart') {
-			exec($conf['init_scripts'] . '/' . $daemon . ' restart', $retval['output'], $retval['retval']);
+			exec($conf['init_scripts'] . '/' . $daemon . ' restart 2>&1', $retval['output'], $retval['retval']);
 		} else {
-			exec($conf['init_scripts'] . '/' . $daemon . ' reload', $retval['output'], $retval['retval']);
+			exec($conf['init_scripts'] . '/' . $daemon . ' reload 2>&1', $retval['output'], $retval['retval']);
 		}
 		return $retval;
 	}
@@ -231,7 +231,7 @@
 		if(!$init_script) $init_script = $conf['init_scripts'].'/'.$web_config['php_fpm_init_script'];
 		
 		$retval = array('output' => '', 'retval' => 0);
-		exec($init_script.' '.$action, $retval['output'], $retval['retval']);
+		exec($init_script.' '.$action.' 2>&1', $retval['output'], $retval['retval']);
 		return $retval;
 	}
 
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 5da8b28..1a5252e 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -1496,24 +1496,30 @@
 				} else {
 					// if no output is given, check again
 					$webserver_binary = '';
-					exec('which apache2', $webserver_check_output, $webserver_check_retval);
+					exec('which apache2ctl', $webserver_check_output, $webserver_check_retval);
 					if($webserver_check_retval == 0){
-						$webserver_binary = 'apache2';
+						$webserver_binary = 'apache2ctl';
 					} else {
 						unset($webserver_check_output, $webserver_check_retval);
-						exec('which httpd2', $webserver_check_output, $webserver_check_retval);
+						exec('which apache2', $webserver_check_output, $webserver_check_retval);
 						if($webserver_check_retval == 0){
-							$webserver_binary = 'httpd2';
+							$webserver_binary = 'apache2';
 						} else {
 							unset($webserver_check_output, $webserver_check_retval);
-							exec('which httpd', $webserver_check_output, $webserver_check_retval);
+							exec('which httpd2', $webserver_check_output, $webserver_check_retval);
 							if($webserver_check_retval == 0){
-								$webserver_binary = 'httpd';
+								$webserver_binary = 'httpd2';
 							} else {
 								unset($webserver_check_output, $webserver_check_retval);
-								exec('which apache', $webserver_check_output, $webserver_check_retval);
+								exec('which httpd', $webserver_check_output, $webserver_check_retval);
 								if($webserver_check_retval == 0){
-									$webserver_binary = 'apache';
+									$webserver_binary = 'httpd';
+								} else {
+									unset($webserver_check_output, $webserver_check_retval);
+									exec('which apache', $webserver_check_output, $webserver_check_retval);
+									if($webserver_check_retval == 0){
+										$webserver_binary = 'apache';
+									}
 								}
 							}
 						}

--
Gitblit v1.9.1