Commit cd71ae9c authored by Mac Newbold's avatar Mac Newbold
Browse files

Call out to genelists on membership changes.

parent ce7ef773
......@@ -17,7 +17,7 @@ use Getopt::Std;
# uses this option since it know what users have been changed via the web
# form.
#
# Note that this script does not create accounts or groups. That should
# Note that this script does not create accounts or groups. That should
# already have been done with other scripts.
#
sub usage()
......@@ -25,7 +25,7 @@ sub usage()
print STDOUT
"Usage: setgroups -p <pid> [user ...]\n".
" setgroups [user ...]\n";
exit(-1);
}
my $optlist = "p:";
......@@ -41,11 +41,12 @@ my $BOSSNODE= "@BOSSNODE@";
my $ADMINGRP= "@TBADMINGROUP@";
my $SSH = "$TB/bin/sshtb";
my $GENELISTS="$TB/sbin/genelists";
my $USERMOD = "/usr/sbin/pw usermod";
my $dbuid;
my @userlist;
my $pid;
my $pid="";
my $user_name;
my $user_email;
my $logname;
......@@ -53,13 +54,13 @@ my @db_row;
my $query_result;
#
# Note hardwired control node.
#
# Note hardwired control node.
#
my $control_node = $CONTROL;
#
# Untaint the path
#
#
$ENV{'PATH'} = "/bin:/usr/bin";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
......@@ -69,7 +70,7 @@ delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
$| = 1;
#
# Load the Testbed support stuff.
# Load the Testbed support stuff.
#
use lib "@prefix@/lib";
use libaudit;
......@@ -87,7 +88,7 @@ if ($EUID != 0) {
#
# This script is setuid, so please do not run it as root. Hard to track
# what has happened.
#
#
if ($UID == 0) {
die("*** $0:\n".
" Please do not run this as root! Its already setuid!\n");
......@@ -129,7 +130,7 @@ if (@ARGV) {
else {
die("Bad user name: $user.");
}
push(@userlist, $user);
}
}
......@@ -167,7 +168,7 @@ if (AuditStart(0)) {
exit(0);
}
#
#
# All this stuff must be done as root (ssh).
#
$UID = $EUID;
......@@ -202,8 +203,8 @@ foreach my $uid (@userlist) {
# Form a list of project (group) membership names. We do this in two
# steps to ensure that we get the default group membership since we
# want that to be the user's primary group. Not sure this really matters
# all that much, but might as well.
#
# all that much, but might as well.
#
$query_result =
DBQueryFatal("select g.unix_name from group_membership as m ".
"left join groups as g on m.pid=g.pid and m.gid=g.gid ".
......@@ -236,7 +237,7 @@ foreach my $uid (@userlist) {
#
# Okay, pick up subgroup (pid!=gid) membership.
#
#
$query_result =
DBQueryFatal("select g.unix_name from group_membership as m ".
"left join groups as g on m.pid=g.pid and m.gid=g.gid ".
......@@ -292,7 +293,7 @@ foreach my $uid (@userlist) {
#
# Add special groups. These are listed in the DB so that special local
# users can have more unix groups than just the projects/groups they are
# in. These groups must already exist.
# in. These groups must already exist.
#
my @extragrouplist = TBUnixGroupList($uid);
......@@ -306,10 +307,10 @@ foreach my $uid (@userlist) {
push(@extragrouplist, $ADMINGRP);
}
}
if (@extragrouplist) {
print "Adding extra groups to list: @extragrouplist\n";
if ($grouplist) {
$grouplist = "$grouplist," . join(",", @extragrouplist);
}
......@@ -337,8 +338,8 @@ foreach my $uid (@userlist) {
print "Updating user $uid record on $control_node.\n";
if ($control_node ne $BOSSNODE) {
$groupargument =~ s/\"/\\"/g;
$groupargument =~ s/\"/\\"/g; #"
if (system("$SSH -host $control_node ".
"'$USERMOD $uid -g $project $groupargument'")) {
fatal("Could not modify user $uid record on $control_node.");
......@@ -346,6 +347,10 @@ foreach my $uid (@userlist) {
}
}
print "Updating email lists for: ".join(" ",@userlist)."\n";
foreach $u (@userlist) { system("$GENELISTS -n $u"); }
print "Group Update Completed!\n";
exit(0);
......
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