Commit fc7aec1c authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Add per-group email lists as per payment by Eric.

parent 3175c488
...@@ -25,6 +25,7 @@ my $USERS = "@USERNODE@"; ...@@ -25,6 +25,7 @@ my $USERS = "@USERNODE@";
my $TBACTIVE = "@TBACTIVEARCHIVE@"; my $TBACTIVE = "@TBACTIVEARCHIVE@";
my $TBALL = "@TBUSERSARCHIVE@"; my $TBALL = "@TBUSERSARCHIVE@";
my $PROJROOT = "/proj"; my $PROJROOT = "/proj";
my $GRPROOT = "/groups";
# Note no -n option. We redirect stdin from the new exports file below. # Note no -n option. We redirect stdin from the new exports file below.
my $SSH = "$TB/bin/sshtb -l root -host $USERS"; my $SSH = "$TB/bin/sshtb -l root -host $USERS";
...@@ -53,7 +54,7 @@ if ($EUID != 0) { ...@@ -53,7 +54,7 @@ if ($EUID != 0) {
" Must be root! Maybe its a development version?\n"); " Must be root! Maybe its a development version?\n");
} }
# XXX Hacky! # XXX Hacky!
if (1 && $TB ne "/usr/testbed") { if (0 && $TB ne "/usr/testbed") {
die("*** $0:\n". die("*** $0:\n".
" Wrong version. Maybe its a development version?\n"); " Wrong version. Maybe its a development version?\n");
} }
...@@ -211,31 +212,38 @@ if (defined($newuser) || defined($allprojects)) { ...@@ -211,31 +212,38 @@ if (defined($newuser) || defined($allprojects)) {
if (defined($newuser)) { if (defined($newuser)) {
$proj_result = $proj_result =
DBQueryFatal("select pid from group_membership ". DBQueryFatal("select pid,gid from group_membership ".
"where uid='$newuser' and pid=gid"); "where uid='$newuser'");
} }
else { else {
$proj_result = $proj_result =
DBQueryFatal("select pid from projects"); DBQueryFatal("select pid,gid from groups");
} }
while (($pid) = $proj_result->fetchrow_array) { while (my ($pid,$gid) = $proj_result->fetchrow_array) {
print "Getting project members for $pid\n" if $d; print "Getting project members for $pid/$gid\n" if $d;
my $query_result = my $query_result =
DBQueryFatal("SELECT distinct u.usr_email from ". DBQueryFatal("SELECT distinct u.usr_email from ".
" group_membership as p ". " group_membership as p ".
"left join users as u on u.uid=p.uid ". "left join users as u on u.uid=p.uid ".
"where p.pid='$pid' and p.pid=p.gid and ". "where p.pid='$pid' and p.gid='$gid' and ".
" p.trust!='none' ". " p.trust!='none' ".
"order by u.usr_email"); "order by u.usr_email");
if ($query_result->numrows) { if ($query_result->numrows) {
my $archive = "$PROJROOT/$pid/$pid-users.mail"; my $archive;
if ($pid eq $gid) {
$archive = "$PROJROOT/$pid/$pid-users.mail";
}
else {
$archive = "$GRPROOT/$pid/$gid/$pid-$gid.mail";
}
# #
# This would be nice, but will not work since the mailer daemon # This would be nice, but will not work since the mailer daemon
# cannot access files in /proj/$pid. # cannot access files in /proj/$pid or /groups/$pid
# #
if (0 && ! -e $archive) { if (0 && ! -e $archive) {
open(ARCHIVE, ">>$archive") or open(ARCHIVE, ">>$archive") or
...@@ -245,8 +253,13 @@ if (defined($newuser) || defined($allprojects)) { ...@@ -245,8 +253,13 @@ if (defined($newuser) || defined($allprojects)) {
chmod(0666, "$archive") or chmod(0666, "$archive") or
fatal("Could not chmod(666) $archive: $!"); fatal("Could not chmod(666) $archive: $!");
} }
if ($pid eq $gid) {
genelist($query_result, undef, "$pid-users"); genelist($query_result, undef, "$pid-users");
} }
else {
genelist($query_result, undef, "$pid-$gid-users");
}
}
} }
} }
......
Supports Markdown
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