Commit f9544e06 authored by Leigh B. Stoller's avatar Leigh B. Stoller

A couple of tweaks for reconfiguring system lists.

parent 031964f0
......@@ -15,12 +15,13 @@ use Errno qw(EEXIST);
#
sub usage()
{
print STDOUT "Usage: addmmlist -a <listname> or\n";
print STDOUT "Usage: addmmlist [-r] -a <listname> or\n";
print STDOUT " addmmlist -u <listname> <listowner> <listpassword>\n";
exit(-1);
}
my $optlist = "dau";
my $debug = 0;
my $optlist = "daur";
my $debug = 0;
my $reconfig = 0;
my $dbuid;
my $listtype;
my $listname;
......@@ -106,6 +107,9 @@ if (! getopts($optlist, \%options)) {
if (defined($options{"d"})) {
$debug = 1;
}
if (defined($options{"r"})) {
$reconfig = 1;
}
if (defined($options{"a"})) {
$listtype = "admin";
......@@ -119,6 +123,8 @@ if (defined($options{"u"})) {
usage()
if (@ARGV != 3);
usage()
if (defined($options{"r"}));
$listname = $ARGV[0];
$listowner = $ARGV[1];
......@@ -178,11 +184,13 @@ $UID = $EUID;
if ($CONTROL ne $BOSSNODE) {
my $optarg = ($debug ? "-d" : "");
my $verb = ($reconfig ? "Reconfiguring" : "Adding");
my $cmd = ($reconfig ? "reconfig" : "addlist");
print "Adding mailman list $listname ($listtype) on $CONTROL.\n";
print "$verb mailman list $listname ($listtype) on $CONTROL.\n";
system("echo '$listowner_email $listpasswd' | ".
"$SSH -host $CONTROL $MMPROXY addlist $listname $listtype");
"$SSH -host $CONTROL $MMPROXY $cmd $listname $listtype");
if ($?) {
if ($? >> 8 == EEXIST()) {
# Not an error.
......@@ -190,10 +198,11 @@ if ($CONTROL ne $BOSSNODE) {
}
fatal("$MMPROXY failed on $CONTROL!");
}
SENDMAIL($TBAUDIT, "Mailman list created",
"Mailman list '$listname' has been created by '$dbuid'",
$TBOPS);
if (! $reconfig) {
SENDMAIL($TBAUDIT, "Mailman list created",
"Mailman list '$listname' has been created by '$dbuid'",
$TBOPS);
}
}
exit(0);
......
......@@ -108,7 +108,7 @@ chdir($MAILMANDIR) or
my $action = shift(@ARGV);
if ($action eq "addlist") {
exit(AddList(@ARGV));
exit(AddList(0, @ARGV));
}
elsif ($action eq "setlistmembers") {
exit(SetListMembers(@ARGV));
......@@ -128,6 +128,9 @@ elsif ($action eq "xlogin") {
elsif ($action eq "membership") {
exit(ListMembership(@ARGV));
}
elsif ($action eq "reconfig") {
exit(AddList(1, @ARGV));
}
else {
die("*** $0:\n".
" Do not know what to do with '$action'!\n");
......@@ -140,9 +143,9 @@ exit(0);
sub AddList(@)
{
usage()
if (@_ != 2);
if (@_ != 3);
my ($name, $listtype) = @_;
my ($reconfig, $name, $listtype) = @_;
my ($owneremail, $password) = ();
# Other info for list comes in from STDIN.
......@@ -165,12 +168,17 @@ sub AddList(@)
#
if (! -d "$MMLISTDIR/" . lc($name)) {
my $optarg = ($listtype eq "admin" ? "-q" : "");
if ($reconfig) {
print "List '$name' does not exist; exiting ...\n";
return -1;
}
system("echo '' | ".
"$MMBINDIR/newlist $optarg $name $owneremail $password") == 0 or
fatal("AddList: Could not create mailing list!");
}
else {
elsif (! $reconfig) {
print "List '$name' and already exists; exiting ...\n";
return EEXIST();
}
......@@ -224,6 +232,10 @@ sub AddList(@)
fatal("AddList: Could not configure mailing list!");
unlink($tempfile);
# Done if just doing a reconfig of the list.
return 0
if ($reconfig);
# Step 3: Regen the aliases. We use an external script for this.
$EUID = $UID = 0;
system("$GENALIASES") == 0 or
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment