Commit 4d7dd46b authored by Leigh Stoller's avatar Leigh Stoller

Noticed that users were not being removed from per-project mailing

lists.  This (harmless) bug has been around a while; needed to move
the call to genelists up a level from setgroups to modgroups, since
that is where we have the information about what groups a user has
been deleted from, and so can tell genelists to regen those project
mailing lists.
parent 60bc7622
......@@ -28,6 +28,7 @@ my $user;
my @addlist = ();
my @modlist = (); # Just changing the trust value ...
my @remlist = ();
my $optarg = "";
#
# Configure variables
......@@ -41,6 +42,7 @@ my $WIKISUPPORT = @WIKISUPPORT@;
my $BUGDBSUPPORT = @BUGDBSUPPORT@;
my $CHATSUPPORT = @CHATSUPPORT@;
my $ELABINELAB = @ELABINELAB@;
my $GENELISTS = "$TB/sbin/genelists";
my $MODBUDDIES = "$TB/sbin/modjabberbuddies";
my $SETCHATMEMBERS = "$TB/sbin/setchatmembers";
my $SETGROUPS = "$TB/sbin/setgroups";
......@@ -89,7 +91,8 @@ if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{"d"})) {
$debug = 1;
$debug = 1;
$optarg = "-d";
}
if (defined($options{"a"})) {
my @tokens = split(",", $options{"a"});
......@@ -213,12 +216,12 @@ foreach my $token (@addlist) {
# Tell chat subsystem to change groups ...
#
if ($CHATSUPPORT) {
system("$MODBUDDIES -a $pid:$gid $user") == 0 or
system("$MODBUDDIES $optarg -a $pid:$gid $user") == 0 or
fatal("$MODBUDDIES '-a $pid:$gid $user' failed!");
# Does not work yet.
if (0) {
system("$SETCHATMEMBERS -g $gid $pid") == 0 or
system("$SETCHATMEMBERS $optarg -g $gid $pid") == 0 or
fatal("$SETCHATMEMBERS '-g $gid $pid' failed!");
}
}
......@@ -264,6 +267,15 @@ foreach my $token (@remlist) {
(($pid ne $gid) ? "gid='$gid' and " : " ") .
" uid='$user'");
#
# When deleting a user from a group, need to call genelists on the
# project, not the user, since that information is obviously gone from
# the DB, and genelists will not generate the right lists.
#
print "Updating email lists for project $pid\n";
system("$GENELISTS $optarg -p $pid") == 0 or
fatal("$GENELISTS -p $pid failed!");
#
# Tell chat subsystem to change groups ...
#
......@@ -275,19 +287,30 @@ foreach my $token (@remlist) {
# Does not work yet.
if (0) {
system("$SETCHATMEMBERS -g $group $pid") == 0 or
system("$SETCHATMEMBERS $optarg -g $group $pid") == 0 or
fatal("$SETCHATMEMBERS '-g $group $pid' failed!");
}
}
if (@optlist) {
my $chatargs = join(",", @optlist);
system("$MODBUDDIES -r $chatargs $user") == 0 or
system("$MODBUDDIES $optarg -r $chatargs $user") == 0 or
fatal("$MODBUDDIES '-r $chatargs $user' failed!");
}
}
}
#
# Call genelists, but just when adding or modifying. For deletion, it
# is handled above.
#
if (@addlist || @modlist) {
print "Updating email lists for user $user\n";
system("$GENELISTS $optarg -u $user") == 0 or
fatal("$GENELISTS -u $user failed!");
}
#
# Finally, call setgroups to do the rest.
#
......
......@@ -31,7 +31,9 @@ sub usage()
sub fatal($);
my $optlist = "p:";
my $optlist = "dp:";
my $debug = 0;
my $optarg = "";
#
# Configure variables
......@@ -49,7 +51,6 @@ my $SETWIKIGROUPS = "$TB/sbin/setwikigroups";
my $SETBUGDBGROUPS= "$TB/sbin/setbugdbgroups";
my $SSH = "$TB/bin/sshtb";
my $GENELISTS="$TB/sbin/genelists";
my $USERMOD = "/usr/sbin/pw usermod";
my $SAVEUID = $UID;
......@@ -111,6 +112,10 @@ if ($UID == 0) {
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{"d"})) {
$debug = 1;
$optarg = "-d";
}
if (defined($options{"p"})) {
$pid = $options{"p"};
......@@ -380,27 +385,15 @@ foreach my $uid (@userlist) {
$UID = $SAVEUID;
$EUID = $UID;
if (defined($pid)) {
print "Updating email lists for project $pid\n";
system("$GENELISTS -p $pid");
}
else {
print "Updating email lists for: ".join(" ",@userlist)."\n";
foreach $u (@userlist) {
system("$GENELISTS -u $u");
}
}
# and the twiki.
if ($WIKISUPPORT || $BUGDBSUPPORT) {
foreach $user (@userlist) {
if ($WIKISUPPORT) {
system("$SETWIKIGROUPS $user") == 0 or
system("$SETWIKIGROUPS $optarg $user") == 0 or
fatal("$SETWIKIGROUPS $user failed!");
}
if ($BUGDBSUPPORT) {
system("$SETBUGDBGROUPS $user") == 0 or
system("$SETBUGDBGROUPS $optarg $user") == 0 or
fatal("$SETBUGDBGROUPS $user failed!");
}
}
......
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