//
$mailing_lists=array();
$mlists_cmd = escapeshellcmd(forge_get_config('mailman_path')."/bin/list_lists");
-$err .= "Command to be executed is $mlists_cmd\n";
+//$err .= "Command to be executed is $mlists_cmd\n";
$fp = popen ($mlists_cmd,"r");
while (!feof($fp)) {
$mlist = fgets($fp, 4096);
}
}
-$err .= 'Existing mailing lists : '.implode(', ', $mailing_lists)."\n";
+// $err .= 'Existing mailing lists : '.implode(', ', $mailing_lists)."\n";
pclose($fp);
$err .= db_error();
$rows=db_numrows($res);
-$err .= "$rows rows returned from query\n";
+//$err .= "$rows rows returned from query\n";
$h1 = fopen(forge_get_config('data_path').'/dumps/mailman-aliases',"w");
$listpassword = db_result($res,$i,'password');
$grouplistid = db_result($res,$i,'group_list_id');
$public = db_result($res,$i,'is_public');
+ $status = db_result($res,$i,'status');
+
+ $listname = trim($listname);
+ if (!$listname) {
+ $err .= "Empty name for a mailing list in 'mail_group_list' table\n";
+ break;
+ }
+ if (!preg_match('/^[a-z0-9\-_\.]*$/', $listname) || $listname == '.' || $listname == '..') {
+ $err .= 'Invalid List Name: ' . $listname;
+ break;
+ }
+ $is_commits_list = preg_match('/-commits$/', $listname);
+
+ // Hack to Disable auto-public of listname.
+ $is_commits_list = false;
+
// Here we assume that the privatize_list.py script is located in the same dir as this script
$script_dir = dirname(__FILE__);
$privatize_cmd = escapeshellcmd(forge_get_config('mailman_path').'/bin/config_list -i '.$script_dir.'/privatize_list.py '.$listname);
echo $err;
continue;
} else {
- // Privatize the new list
+ if ($is_commits_list || $public) {
+ // Make the *-commits list public
+ $err .= "Making ".$listname." public: ".$publicize_cmd."\n";
+ passthru($publicize_cmd,$publicizeFailed);
+ } else {
+ // Privatize the new list
+ $err .= "Privatizing ".$listname.": ".$privatize_cmd."\n";
+ passthru($privatize_cmd,$privatizeFailed);
+ }
+ }
+ $mailingListIds[] = $grouplistid;
+ } elseif ($status == MAIL__MAILING_LIST_IS_UPDATED) {
+ // For already created list, update only if status was changed on the forge to
+ // avoid anwanted reset of parameters.
+
+ // Get the mailman info on public/private to change
+ if ($is_commits_list || $public) {
+ $err .= "Making ".$listname." public: ".$publicize_cmd."\n";
+ passthru($publicize_cmd,$publicizeFailed);
+ } elseif (!$public) {
+ // Privatize only if it is marked as private
$err .= "Privatizing ".$listname.": ".$privatize_cmd."\n";
passthru($privatize_cmd,$privatizeFailed);
}
- $mailingListIds[] = $grouplistid;
+ } elseif ($status == MAIL__MAILING_LIST_PW_RESET_REQUESTED) {
+ $change_pw_cmd = escapeshellcmd(forge_get_config ('mailman_path').'/bin/change_pw -l '.$listname);
+ $err .= "Resetting password of ".$listname."\n";
+ passthru($change_pw_cmd,$failed);
+ if ($failed) {
+ $err .= 'Failed to reset password of '.$listname."\n";
+ }
} else { // Old list
if (!$public) {
// Privatize only if it is marked as private
fwrite($h1,$list_str);
}
-// Update status
-//if(!empty($mailingListIds)) {
db_query_params ('UPDATE mail_group_list set status=$1 WHERE status=$2',
array (MAIL__MAILING_LIST_IS_CREATED,
MAIL__MAILING_LIST_IS_REQUESTED));
echo db_error();
-//}
fclose($h1);
for($k = 0; $k < $rows; $k++) {
$deleted_mail_list = db_result($res,$k,'mailing_list_name');
-
- exec(forge_get_config('mailman_path')."/bin/rmlist -a $deleted_mail_list", $output);
+
+ $deleted_mail_list = trim($deleted_mail_list);
+ if (!$deleted_mail_list) {
+ $err .= "Empty name for a mailing list in 'deleted_mailing_lists' table\n";
+ break;
+ }
+ if (!preg_match('/^[a-z0-9\-_\.]*$/', $deleted_mail_list) || $deleted_mail_list == '.' || $deleted_mail_list == '..') {
+ $err .= 'Invalid List Name: ' . $deleted_mail_list;
+ break;
+ }
+
+ exec(forge_get_config('mailman_path')."/bin/rmlist -a '$deleted_mail_list'", $output);
$success = false;
foreach ($output as $line) {
// Mailman 2.1.x