From afee192d2a77afa1c11d25156d0a44df94e19aed Mon Sep 17 00:00:00 2001
From: A. Täffner <darkalex@firesplash.de>
Date: Sat, 23 Jan 2016 07:30:37 -0500
Subject: [PATCH] fixed the cronjob and noticed a bug in ISPC but not able to report as FlySpray is offline

---
 server/plugins-available/mailman_plugin.inc.php |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/server/plugins-available/mailman_plugin.inc.php b/server/plugins-available/mailman_plugin.inc.php
index acf4eb9..b15cd73 100644
--- a/server/plugins-available/mailman_plugin.inc.php
+++ b/server/plugins-available/mailman_plugin.inc.php
@@ -73,12 +73,20 @@
 
 		$this->update_config();
 
-		exec("nohup /usr/lib/mailman/bin/newlist -u ".escapeshellcmd($data["new"]["domain"])." -e ".escapeshellcmd($data["new"]["domain"])." ".escapeshellcmd($data["new"]["listname"])." ".escapeshellcmd($data["new"]["email"])." ".escapeshellcmd($data["new"]["password"])." >/dev/null 2>&1 &");
+		$pid = exec("nohup /usr/lib/mailman/bin/newlist -u ".escapeshellcmd($data["new"]["domain"])." -e ".escapeshellcmd($data["new"]["domain"])." ".escapeshellcmd($data["new"]["listname"])." ".escapeshellcmd($data["new"]["email"])." ".escapeshellcmd($data["new"]["password"])." >/dev/null 2>&1 & echo $!;");
+		// wait for /usr/lib/mailman/bin/newlist-call
+		$running = true;
+		do {
+			exec('ps -p '.intval($pid), $out);
+			if (count($out) ==1) $running=false; else sleep(1);
+			unset($out);
+		} while ($running);
+		unset($out);
 		if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman');
 		if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman');
 		exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &');
 
-		$app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ".$app->db->quote($data["new"]['mailinglist_id']));
+		$app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']);
 
 	}
 
@@ -91,7 +99,7 @@
 		if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') {
 			exec("nohup /usr/lib/mailman/bin/change_pw -l ".escapeshellcmd($data["new"]["listname"])." -p ".escapeshellcmd($data["new"]["password"])." >/dev/null 2>&1 &");
 			exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &');
-			$app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ".$app->db->quote($data["new"]['mailinglist_id']));
+			$app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']);
 		}
 		
 		if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman');
@@ -115,7 +123,7 @@
 	function update_config() {
 		global $app, $conf;
 
-		copy($this->mailman_config_dir.'mm_cfg.py', $this->mailman_config_dir.'mm_cfg.py');
+		copy($this->mailman_config_dir.'mm_cfg.py', $this->mailman_config_dir.'mm_cfg.py~');
 
 		// load the server configuration options
 		$app->uses('getconf');
@@ -136,7 +144,7 @@
 			if (strlen($line) && substr($line, 0, 1) != '#')
 			{
 				list($key, $value) = explode("=", $line);
-				if (!empty($value))
+				if ($value && $value !== '')
 				{
 					$key = rtrim($key);
 					$old_options[$key] = trim($value);

--
Gitblit v1.9.1