Commit f61c13cf authored by Leigh Stoller's avatar Leigh Stoller

Add support for adding (and removing) groups from the tipservers.

Did this with a little DB table that lists any aux machines that
groups need to be built on.
parent 10adfc02
......@@ -215,6 +215,28 @@ if (system("$SSH $control_node egrep -q -s '^${unix_name}:' /etc/group")) {
}
}
#
# Create group on the tip servers.
#
my @tipservers;
$query_result =
DBQueryFatal("select * from tipservers");
while (@db_row = $query_result->fetchrow_array() ) {
push(@tipservers, $db_row[0]);
}
foreach my $tipserver ( @tipservers ) {
if (system("$SSH $tipserver egrep -q -s '^${unix_name}:' /etc/group")) {
print "Adding group $unix_name to $tipserver\n";
if (system("$SSH $tipserver $GROUPADD $unix_name -g $unix_gid")) {
fatal("Could not add $unix_name ($unix_gid) to $tipserver!\n");
}
}
}
#
# Create the group directory if it does not already exist.
#
......
......@@ -121,6 +121,7 @@ my $user_email = $db_row[3];
my @groupnames;
my %groupnumbers;
my @grouplist;
my @tipservers;
#
# Form a list of project (group) membership names. We do this in two
......@@ -154,6 +155,17 @@ while (@db_row = $query_result->fetchrow_array() ) {
#
my $control_node = $CONTROL;
#
# We need a list of tipservers to build groups on so that the console
# lines can get the appropriate group permissions.
#
$query_result =
DBQueryFatal("select * from tipservers");
while (@db_row = $query_result->fetchrow_array() ) {
push(@tipservers, $db_row[0]);
}
#
# Create groups on both the control and operations nodes. We assume
# FreeBSD for both.
......@@ -198,6 +210,19 @@ foreach my $group ( @groupnames ) {
fatal("Could not add $group ($group_number) to $control_node!\n");
}
}
#
# On tipservers too.
#
foreach my $tipserver ( @tipservers ) {
if (system("$SSH $tipserver egrep -q -s '^${group}:' /etc/group")) {
print "Adding group $group to $tipserver\n";
if (system("$SSH $tipserver $GROUPADD $group -g $group_number")) {
fatal("Could not add $group ($group_number) to $tipserver!\n");
}
}
}
}
#
......
......@@ -138,5 +138,25 @@ if (system("$SSH $CONTROL $GROUPDEL $unix_name")) {
$errors++;
}
exit(errors);
#
# Remove group on the tip servers.
#
my @tipservers;
$query_result =
DBQueryFatal("select * from tipservers");
while (@db_row = $query_result->fetchrow_array() ) {
push(@tipservers, $db_row[0]);
}
foreach my $tipserver ( @tipservers ) {
if (system("$SSH $tipserver $GROUPDEL $unix_name")) {
warn("*** WARNING: ".
"Could not remove group $unix_name from $tipserver!\n");
$errors++;
}
}
exit($errors);
......@@ -21,6 +21,7 @@ my $CONTROL = "@USERNODE@";
my $PROJROOT = "/proj";
my $SSH = "$TB/bin/sshtb";
my $GROUPDEL = "/usr/sbin/pw groupdel";
my $errors = 0;
#
# Untaint the path
......@@ -67,13 +68,13 @@ if ($UID && !TBAdmin($UID)) {
}
#
# Ensure that the project is not in the database!
# Unix info for the group
#
my $query_result =
DBQueryFatal("select head_uid from projects where pid='$pid'");
my $unix_gid;
my $unix_name;
if ($query_result->numrows) {
die("*** Project '$pid' is still in the database!\n");
if (! TBGroupUnixInfo($pid, $pid, \$unix_gid, \$unix_name)) {
die("*** No info for project $pid!");
}
#
......@@ -107,8 +108,10 @@ if (! chown(0, 0, $newname)) {
#
# Now remove the group from the group file on both plastic and paper.
#
if (system("$GROUPDEL $pid")) {
die("*** Could not remove group $pid fron operatons node (paper)\n");
if (system("$GROUPDEL $unix_name")) {
warn("*** WARNING: ".
"Could not remove group $pid from operations node!\n");
$errors++;
}
#
......@@ -116,9 +119,30 @@ if (system("$GROUPDEL $pid")) {
#
$UID = 0;
if (system("$SSH $CONTROL $GROUPDEL $pid")) {
die("*** Could not remove group $pid fron control node ($CONTROL)\n");
if (system("$SSH $CONTROL $GROUPDEL $unix_name")) {
warn("*** WARNING: ".
"Could not remove group $pid from from $CONTROL!\n");
}
exit(0);
#
# Remove group on the tip servers.
#
my @tipservers;
$query_result =
DBQueryFatal("select * from tipservers");
while (@db_row = $query_result->fetchrow_array() ) {
push(@tipservers, $db_row[0]);
}
foreach my $tipserver ( @tipservers ) {
if (system("$SSH $tipserver $GROUPDEL $unix_name")) {
warn("*** WARNING: ".
"Could not remove group $pid from $tipserver!\n");
$errors++;
}
}
exit($errors);
......@@ -106,17 +106,17 @@ if (!$confirmed_twice) {
$query_result =
DBQueryFatal("delete FROM group_membership where pid='$pid'");
#
# Remove the project directory and the group.
#
SUEXEC($uid, "flux", "rmproj $pid", 0);
#
# Then the project table itself.
#
$query_result =
DBQueryFatal("delete FROM projects where pid='$pid'");
#
# Remove the project directory.
#
SUEXEC($uid, "flux", "rmproj $pid", 0);
#
# Warm fuzzies.
#
......
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