Commit 2965922b authored by Leigh Stoller's avatar Leigh Stoller

Finish up user deletion. The big visible change is that when a user is

deleted, they still remain in the user table with a status of
"archived", but since all the queries in the system now use uid_idx
instead of uid, it is safe to reuse a uid since they are no longer
ambiguous. 

The reason for not deleting users from the users table is so that the
stats records can refer to the original record (who was that person
named "mike"). This is very handy and worth the additional effort it
has taken.

There is no way to ressurect a user, but it would not be hard to add.
parent e90c9411
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
# Copyright (c) 2000-2008, 2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -243,7 +243,7 @@ foreach my $key (keys(%{ $xmlparse->{'attribute'} })) {
#
if (exists($newuser_args{'uid'})) {
UserError("User already exists; pick another login name!")
if (User->LookupByUidAll($newuser_args{'uid'}));
if (User->Lookup($newuser_args{'uid'}));
UserError("Reserved user name; pick another login name!")
if (getpwnam($newuser_args{'uid'}));
......@@ -367,13 +367,13 @@ if (TBGetSiteVar("general/firstinit/state", \$firstinitstate)) {
if ($firstinitstate eq "createproject") {
DBQueryFatal("update users set ".
" admin=1,status='". $User::USERSTATUS_UNAPPROVED . "' " .
"where uid='$new_uid'");
"where uid_idx='$usr_idx'");
DBQueryFatal("insert into unixgroup_membership set ".
"uid='$new_uid', gid='wheel'");
"uid='$new_uid', uid_idx='$usr_idx', gid='wheel'");
DBQueryFatal("insert into unixgroup_membership set ".
"uid='$new_uid', gid='$TBADMINGROUP'");
"uid='$new_uid', uid_idx='$usr_idx', gid='$TBADMINGROUP'");
# The web interface requires this line to be printed!
print "User $usr_uid/$usr_idx has been created\n";
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005, 2006 University of Utah and the Flux Group.
# Copyright (c) 2005, 2006, 2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -111,7 +111,7 @@ while (my ($pid) = $query_result->fetchrow_array()) {
$query_result =
DBQueryFatal("select distinct g.uid ".
" from group_membership as g ".
"left join users as u on u.uid=g.uid ".
"left join users as u on u.uid_idx=g.uid_idx ".
"where u.status='active' and g.trust!='none' ".
# " and (g.pid='testbed' or g.pid='emulab-ops' or ".
# " g.pid='tbres' or g.pid='utahstud')" .
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005 University of Utah and the Flux Group.
# Copyright (c) 2005, 2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -102,7 +102,7 @@ if (AuditStart(0)) {
$query_result =
DBQueryFatal("select distinct u.uid ".
" from group_membership as g ".
"left join users as u on u.uid=g.uid ".
"left join users as u on u.uid_idx=g.uid_idx ".
"where u.status='active' ".
# " and (g.pid='testbed' or g.pid='emulab-ops' or ".
# " g.pid='tbres' or g.pid='utahstud' or ".
......@@ -165,7 +165,7 @@ while (my ($pid,$gid) = $query_result->fetchrow_array()) {
my $users_results =
DBQueryFatal("select g.uid from group_membership as g ".
"left join users as u on u.uid=g.uid ".
"left join users as u on u.uid_idx=g.uid_idx ".
"where g.pid='$pid' and g.gid='$gid' and ".
" u.status='active'");
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005, 2006, 2007 University of Utah and the Flux Group.
# Copyright (c) 2005-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -90,18 +90,18 @@ my $optarg = ($debug ? "-d" : "");
# Initialize a mailman password for all users.
#
my $query_result =
DBQueryFatal("select uid from users ".
DBQueryFatal("select uid,uid_uid from users ".
"where mailman_password is NULL and status!='archived'");
while (my ($uid) = $query_result->fetchrow_array()) {
print "Setting initial mailman password for $uid\n"
while (my ($uid,$uid_idx) = $query_result->fetchrow_array()) {
print "Setting initial mailman password for $uid ($uid_idx)\n"
if ($debug);
my $password = TBGenSecretKey();
$password = substr($password, 0, 10);
DBQueryFatal("update users set mailman_password='$password' ".
"where uid='$uid'");
"where uid_idx='$uid_idx'");
}
#
......@@ -110,7 +110,7 @@ while (my ($uid) = $query_result->fetchrow_array()) {
$query_result =
DBQueryFatal("select distinct g.uid,u.usr_email ".
" from group_membership as g ".
"left join users as u on u.uid=g.uid ".
"left join users as u on u.uid_idx=g.uid_idx ".
"where u.status='active' or u.status='frozen' ".
# " and (g.pid='testbed' or g.pid='emulab-ops' or ".
# " g.pid='tbres' or g.pid='utahstud')" .
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005-2009 University of Utah and the Flux Group.
# Copyright (c) 2005-2010 University of Utah and the Flux Group.
# All rights reserved.
#
package User;
......@@ -600,15 +600,15 @@ sub Purge($)
#
DBQueryWarn("delete from login where uid_idx='$uid_idx'")
or return -1;
DBQueryWarn("delete from nodeuidlastlogin where uid='$uid'")
DBQueryWarn("delete from nodeuidlastlogin where uid='$uid_idx'")
or return -1;
DBQueryWarn("delete from uidnodelastlogin where uid='$uid'")
DBQueryWarn("delete from uidnodelastlogin where uid='$uid_idx'")
or return -1;
DBQueryWarn("delete from unixgroup_membership where uid='$uid'")
DBQueryWarn("delete from unixgroup_membership where uid='$uid_idx'")
or return -1;
DBQueryWarn("delete from userslastlogin where uid='$uid'")
DBQueryWarn("delete from userslastlogin where uid='$uid_idx'")
or return -1;
DBQueryWarn("delete from user_policies where uid='$uid'")
DBQueryWarn("delete from user_policies where uid='$uid_idx'")
or return -1;
return 0;
......@@ -1419,13 +1419,13 @@ sub UnixGroupList($$)
return -1
if (! ref($self));
my $user_uid = $self->uid();
my $uid_idx = $self->uid_idx();
my @glist = ();
@$prval = ();
my $query_result =
DBQueryWarn("select gid from unixgroup_membership ".
"where uid='$user_uid'");
"where uid_idx='$uid_idx'");
return -1
if (!defined($query_result));
return 0
......
......@@ -115,17 +115,17 @@ mysystem("$TB/sbin/mkproj -s $pid");
# groups are created (tbacct add does not do a setgroups).
#
my $users_result =
DBQueryFatal("select distinct u.uid,u.admin,u.status ".
DBQueryFatal("select distinct u.uid,u.uid_idx,u.admin,u.status ".
" from group_membership as m ".
"left join users as u on u.uid_idx=m.uid_idx ");
while (my ($uid,$admin,$status) = $users_result->fetchrow_array()) {
while (my ($uid,$uid_idx,$admin,$status) = $users_result->fetchrow_array()) {
next
if ($uid eq "elabman");
if ($admin) {
# Add admin users to group wheel for convenience.
DBQueryFatal("replace into unixgroup_membership ".
"values ('$uid','wheel')");
"values ('$uid','$uid_idx','wheel')");
}
next
if ($status ne USERSTATUS_ACTIVE());
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use Fcntl ':flock';
......@@ -300,7 +300,7 @@ sub ActiveUsers()
if (! ($query_result =
DBQuery("SELECT DISTINCT u.usr_email from experiments as e ".
"left join group_membership as p ".
" on e.pid=p.pid and p.pid=p.gid ".
" on e.pid_idx=p.pid_idx and p.pid_idx=p.gid_idx ".
"left join users as u on u.uid_idx=p.uid_idx ".
"where u.status='active' and ".
" e.state='active' ".
......@@ -352,7 +352,7 @@ sub RecentProjects()
if (! ($query_result =
DBQuery("select distinct u.usr_email from project_stats as s ".
"left join group_membership as g on ".
" g.pid=s.pid and g.gid=g.pid ".
" g.pid_idx=s.pid_idx and g.gid_idx=g.pid_idx ".
"left join users as u on u.uid_idx=g.uid_idx ".
"where u.status='active' and ".
" ((UNIX_TIMESTAMP(now()) - ".
......@@ -379,9 +379,9 @@ sub RecentProjectLeaders()
if (! ($query_result =
DBQuery("select distinct u.usr_email from project_stats as s ".
"left join group_membership as g on ".
" g.pid=s.pid and g.gid=g.pid ".
" g.pid_idx=s.pid_idx and g.gid_idx=g.pid_idx ".
"left join users as u on u.uid_idx=g.uid_idx ".
"left join projects as p on u.uid=p.head_uid ".
"left join projects as p on u.uid_idx=p.head_idx ".
"where u.status='active' and ".
" ((UNIX_TIMESTAMP(now()) - ".
" UNIX_TIMESTAMP(s.last_activity)) <= $limit) ".
......@@ -424,7 +424,7 @@ sub WideAreaPeople()
{
my $query_result =
DBQueryFatal("SELECT DISTINCT u.usr_email from projects as p ".
"left join group_membership as m on m.pid=p.pid ".
"left join group_membership as m on m.pid_idx=p.pid_idx ".
"left join users as u on u.uid_idx=m.uid_idx ".
"where p.approved!=0 and p.pcremote_ok is not null ".
" and m.trust!='none' and u.status='active' ".
......@@ -465,7 +465,7 @@ sub ProjectLists($$)
($MAILMANSUPPORT ?
", u.uid ,u.usr_name, u.mailman_password " : "") .
" from group_membership as p ".
"left join users as u on u.uid=p.uid ".
"left join users as u on u.uid_idx=p.uid_idx ".
"where p.pid='$pid' and p.gid='$gid' and ".
" p.trust!='none' and u.status='active' ".
"order by u.usr_email");
......
......@@ -2604,13 +2604,14 @@ sub TBNodeUpdateAccountsByUID($)
{
my ($uid) = @_;
DBQueryFatal("update users set usr_modified=now() where uid='$uid'");
DBQueryFatal("update users set usr_modified=now() ".
"where uid='$uid' and status!='archived'");
my $query_result =
DBQueryFatal("select p.pid,pcremote_ok from users as u ".
"left join group_membership as g on ".
" u.uid_idx=g.uid_idx and g.pid=g.gid ".
"left join projects as p on p.pid=g.pid ".
" u.uid_idx=g.uid_idx and g.pid_idx=g.gid_idx ".
"left join projects as p on p.pid_idx=g.pid_idx ".
"where u.uid='$uid' and u.status='active' and ".
" p.pid is not null");
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# Copyright (c) 2000-2002, 2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -19,6 +19,7 @@ sub checkGroup ($$);
#
use lib '@prefix@/lib';
use libdb;
use User;
my $TB = "@prefix@";
my $SETGROUPS = "$TB/sbin/setgroups";
......@@ -41,13 +42,19 @@ if (($UID != 0) && (!TBAdmin($UID))) {
my %opt = ();
getopts('rhpa',\%opt);
my ($uid, @gid);
my ($uid, $uid_idx, @gid);
if ($opt{a} || $opt{r}) {
if (@ARGV < 2) {
die "Not enough arguments - see '$0 -h' for help\n";
}
$uid = shift @ARGV;
@gid = @ARGV;
my $target_user = User->Lookup($uid);
if (!defined($target_user)) {
die "No such active user $uid exists\n";
}
$uid_idx = $target_user->uid_idx();
} else {
if (@ARGV != 0) {
die "Too many arguments - see '$0 -h' for help\n";
......@@ -74,12 +81,12 @@ if ($opt{p}) {
#
foreach my $gid (@gid) {
print "Adding user $uid to group $gid in the database\n";
if (checkGroup($uid,$gid)) {
if (checkGroup($uid_idx,$gid)) {
warn "User $uid is already in group $gid, skipping ...\n";
next;
} else {
DBQueryFatal("INSERT INTO unixgroup_membership SET uid='$uid', " .
"gid='$gid'");
DBQueryFatal("INSERT INTO unixgroup_membership SET ".
" uid='$uid', uid_idx='$uid_idx', gid='$gid'");
}
}
......@@ -94,12 +101,12 @@ if ($opt{p}) {
#
foreach my $gid (@gid) {
print "Removing $uid from group $gid in the database\n";
if (!checkGroup($uid,$gid)) {
if (!checkGroup($uid_idx,$gid)) {
warn "User $uid is not in group $gid, skipping ...\n";
next;
} else {
DBQueryFatal("DELETE FROM unixgroup_membership WHERE uid='$uid' " .
"AND gid='$gid'");
DBQueryFatal("DELETE FROM unixgroup_membership ".
"WHERE uid_idx='$uid_idx' AND gid='$gid'");
}
}
......@@ -126,8 +133,9 @@ if ($opt{p}) {
# if not.
#
sub checkGroup ($$) {
my ($uid,$gid) = @_;
my ($uid_idx,$gid) = @_;
my $result = DBQueryFatal("SELECT gid,uid FROM unixgroup_membership WHERE ".
"uid='$uid' AND gid='$gid'");
"uid_idx='$uid_idx' AND gid='$gid'");
return ($result->num_rows() > 0);
}
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2003, 2006 University of Utah and the Flux Group.
* Copyright (c) 2000-2010 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -86,6 +86,12 @@ dbclose(void)
mydb_disconnect();
}
unsigned long
mydb_escape_string(char *to, const char *from, unsigned long length)
{
return mysql_real_escape_string(&db, to, from, length);
}
MYSQL_RES *
mydb_query(char *query, int ncols, ...)
{
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2003, 2006 University of Utah and the Flux Group.
* Copyright (c) 2000-2010 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -33,4 +33,6 @@ int mydb_seteventschedulerpid(char *pid, char *eid, int processid);
*/
MYSQL_RES *mydb_query(char *query, int ncols, ...);
int mydb_update(char *query, ...);
unsigned long mydb_escape_string(char *to, const char *from,
unsigned long length);
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2003, 2006 University of Utah and the Flux Group.
* Copyright (c) 2000-2003, 2006, 2010 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -142,7 +142,8 @@ main(int argc, char **argv)
USERNODE, hstrerror(h_errno));
exit(-1);
}
strncpy(opshostname, he->h_name, strlen(opshostname));
strncpy(opshostname, he->h_name, sizeof(opshostname));
if (bp = strchr(opshostname, '.'))
*bp = 0;
......@@ -194,10 +195,12 @@ doit(gzFile *infp)
{
int i, skip = 0;
time_t curtime, ll_time;
char *user, node[64], prog[128];
char buf[BUFSIZ], *bp;
char *user, node[TBDB_FLEN_NODEID * 2], prog[128];
char buf[BUFSIZ], *bp, uid_idx[128], tmp[BUFSIZ];
struct tm tm;
MYSQL_RES *dbres;
MYSQL_ROW dbrow;
while (1) {
if (gzgets(infp, buf, BUFSIZ) == NULL)
break;
......@@ -315,31 +318,56 @@ doit(gzFile *infp)
if (strcasecmp(user, "ROOT") == 0)
continue;
dbres = mydb_query("select uid_idx from users where uid='%s' ",
1, user);
if (!dbres) {
syslog(LOG_ERR, "DB error getting user %s", user);
continue;
}
if (!mysql_num_rows(dbres)) {
syslog(LOG_INFO, "No DB record for user %s", user);
mysql_free_result(dbres);
continue;
}
dbrow = mysql_fetch_row(dbres);
strncpy(uid_idx, dbrow[0], sizeof(uid_idx));
mysql_free_result(dbres);
/*
* Safety first.
*/
mydb_escape_string(tmp, uid_idx, strlen(uid_idx));
strcpy(uid_idx, tmp);
mydb_escape_string(tmp, node, strlen(node));
strcpy(node, tmp);
if (mydb_update("replace into uidnodelastlogin "
"(uid, node_id, date, time) "
"values ('%s', '%s', "
"(uid, uid_idx, node_id, date, time) "
"values ('%s', '%s', '%s', "
" FROM_UNIXTIME(%ld, '%%Y-%%m-%%d'), "
" FROM_UNIXTIME(%ld, '%%T')) ",
user, node, ll_time, ll_time) == 0)
user, uid_idx, node, ll_time, ll_time) == 0)
break;
if (strncmp(node, opshostname, strlen(node)) == 0 ||
strncmp(node, "ops", strlen(node)) == 0) {
if (mydb_update("replace into userslastlogin "
"(uid, date, time) "
"values ('%s', "
"(uid, uid_idx, date, time) "
"values ('%s', '%s', "
" FROM_UNIXTIME(%ld, '%%Y-%%m-%%d'), "
" FROM_UNIXTIME(%ld, '%%T')) ",
user, ll_time, ll_time) == 0)
user, uid_idx, ll_time, ll_time) == 0)
break;
}
else {
if (mydb_update("replace into nodeuidlastlogin "
"(node_id, uid, date, time) "
"values ('%s', '%s', "
"(node_id, uid_idx, uid, date, time) "
"values ('%s', '%s', '%s', "
" FROM_UNIXTIME(%ld, '%%Y-%%m-%%d'), "
" FROM_UNIXTIME(%ld, '%%T')) ",
node, user, ll_time, ll_time) == 0)
node, uid_idx, user, ll_time, ll_time) == 0)
break;
}
}
......
......@@ -2310,6 +2310,7 @@ DROP TABLE IF EXISTS `nodeuidlastlogin`;
CREATE TABLE `nodeuidlastlogin` (
`node_id` varchar(32) NOT NULL default '',
`uid` varchar(10) NOT NULL default '',
`uid_idx` mediumint(8) unsigned NOT NULL default '0',
`date` date default NULL,
`time` time default NULL,
PRIMARY KEY (`node_id`)
......@@ -3350,6 +3351,7 @@ CREATE TABLE `traces` (
DROP TABLE IF EXISTS `uidnodelastlogin`;
CREATE TABLE `uidnodelastlogin` (
`uid` varchar(10) NOT NULL default '',
`uid_idx` mediumint(8) unsigned NOT NULL default '0',
`node_id` varchar(32) NOT NULL default '',
`date` date default NULL,
`time` time default NULL,
......@@ -3363,6 +3365,7 @@ CREATE TABLE `uidnodelastlogin` (
DROP TABLE IF EXISTS `unixgroup_membership`;
CREATE TABLE `unixgroup_membership` (
`uid` varchar(8) NOT NULL default '',
`uid_idx` mediumint(8) unsigned NOT NULL default '0',
`gid` varchar(16) NOT NULL default '',
PRIMARY KEY (`uid`,`gid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
......@@ -3374,6 +3377,7 @@ CREATE TABLE `unixgroup_membership` (
DROP TABLE IF EXISTS `user_policies`;
CREATE TABLE `user_policies` (
`uid` varchar(8) NOT NULL default '',
`uid_idx` mediumint(8) unsigned NOT NULL default '0',
`policy` varchar(32) NOT NULL default '',
`auxdata` varchar(64) NOT NULL default '',
`count` int(10) NOT NULL default '0',
......@@ -3519,7 +3523,7 @@ CREATE TABLE `users` (
`wikionly` tinyint(1) default '0',
`mailman_password` tinytext,
PRIMARY KEY (`uid_idx`),
UNIQUE KEY `uid` (`uid`),
KEY `uid` (`uid`),
KEY `unix_uid` (`unix_uid`),
KEY `status` (`status`),
KEY `uid_uuid` (`uid_uuid`)
......@@ -3532,6 +3536,7 @@ CREATE TABLE `users` (
DROP TABLE IF EXISTS `userslastlogin`;
CREATE TABLE `userslastlogin` (
`uid` varchar(10) NOT NULL default '',
`uid_idx` mediumint(8) unsigned NOT NULL default '0',
`date` date default NULL,
`time` time default NULL,
PRIMARY KEY (`uid`)
......
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBSlotExists("nodeuidlastlogin", "uid_idx")) {
DBQueryFatal("alter table nodeuidlastlogin add ".
" `uid_idx` mediumint(8) unsigned NOT NULL default '0' ".
" after uid");
# This unique key is no longer wanted cause of archived users.
DBQueryFatal("alter table users drop unique key `uid`");
DBQueryFatal("alter table users add key `uid` (`uid`)");
}
if (!DBSlotExists("uidnodelastlogin", "uid_idx")) {
DBQueryFatal("alter table uidnodelastlogin add ".
" `uid_idx` mediumint(8) unsigned NOT NULL default '0' ".
" after uid");
}
if (!DBSlotExists("userslastlogin", "uid_idx")) {
DBQueryFatal("alter table userslastlogin add ".
" `uid_idx` mediumint(8) unsigned NOT NULL default '0' ".
" after uid");
}
if (!DBSlotExists("user_policies", "uid_idx")) {
DBQueryFatal("alter table user_policies add ".
" `uid_idx` mediumint(8) unsigned NOT NULL default '0' ".
" after uid");
}
if (!DBSlotExists("unixgroup_membership", "uid_idx")) {
DBQueryFatal("alter table unixgroup_membership add ".
" `uid_idx` mediumint(8) unsigned NOT NULL default '0' ".
" after uid");
}
DBQueryFatal("update nodeuidlastlogin as n left join users as u on ".
" n.uid=u.uid ".
"set n.uid_idx=u.uid_idx ".
"where u.status!='archived'");
DBQueryFatal("delete from nodeuidlastlogin where uid_idx=0");
DBQueryFatal("update uidnodelastlogin as n left join users as u on ".
" n.uid=u.uid ".
"set n.uid_idx=u.uid_idx ".
"where u.status!='archived'");
DBQueryFatal("delete from uidnodelastlogin where uid_idx=0");
DBQueryFatal("update userslastlogin as n left join users as u on ".
" n.uid=u.uid ".
"set n.uid_idx=u.uid_idx ".
"where u.status!='archived'");
DBQueryFatal("delete from userslastlogin where uid_idx=0");
DBQueryFatal("update user_policies as n left join users as u on ".
" n.uid=u.uid ".
"set n.uid_idx=u.uid_idx ".
"where u.status!='archived'");
DBQueryFatal("delete from user_policies where uid_idx=0");
DBQueryFatal("update unixgroup_membership as n left join users as u on ".
" n.uid=u.uid ".
"set n.uid_idx=u.uid_idx ".
"where u.status!='archived'");
DBQueryFatal("delete from unixgroup_membership where uid_idx=0");
return 0;
}
1;
......@@ -713,14 +713,6 @@ if (grep($_, values(%plabvnodes))) {
if (keys(%geninodes)) {
TBDebugTimeStamp("Starting Geni setup.");
#
# Need to initialize the eventstate. Move this elsewhere?
#
foreach my $node (keys(%geninodes)) {
TBSetNodeEventState($node, TBDB_NODESTATE_SHUTDOWN())
if (exists($nodes{$node}));
}
$geni_setup_pid = fork();
if (! $geni_setup_pid) {
TBdbfork(); # So we get the event system fork too ...
......
# -*- python -*-
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004, 2006-2008 University of Utah and the Flux Group.
# Copyright (c) 2000-2004, 2006-2008, 2010 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -2350,9 +2350,9 @@ class EmulabPlcObjTranslator:
# grab basic user details
if uid.find("@") > -1:
wherestr = "where u.usr_email=%s"
wherestr = "where u.usr_email=%s and u.status='active'"
else:
wherestr = "where u.uid=%s"
wherestr = "where u.uid=%s and u.status='active'"
pass
qres = DBQueryFatal("select u.uid,u.usr_name,u.usr_email,u.usr_URL," \
" u.usr_phone,u.usr_pswd,admin" \
......@@ -2385,7 +2385,8 @@ class EmulabPlcObjTranslator:
" left join group_membership as gm"
" on u.uid_idx=gm.uid_idx"
" left join projects as p on gm.pid=p.pid"
" where u.uid=%s and gm.gid=gm.pid",(uid,))
" where u.uid=%s and u.status='active'"
" and gm.gid=gm.pid",(uid,))
roles = []
pids = []
max_trust = None
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
use English;
use Getopt::Std;
#
# Users are deleted by removing all of the table entries except the
# entry in the "users" table; this is entry is modified, setting the
# status to "archived". This is causes the entry to be ignored in
# most cases, but allows the stats tables to refer to deleted users.
# That is, when looking at an old experiment record, you can still see
# info about the user that created the experiment.
#
sub usage()
{
print STDOUT "Usage: rmuser [-p <pid> [-n]] uid\n" .
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005, 2006, 2007 University of Utah and the Flux Group.
# Copyright (c) 2005, 2006, 2007, 2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -811,17 +811,18 @@ sub Initialize()
# Initialize a mailman password for all users, just in case not set.
#
my $query_result =
DBQueryFatal("select uid from users where mailman_password is NULL");
DBQueryFatal("select uid,uid_idx from users ".
"where mailman_password is NULL");
while (my ($uid) = $query_result->fetchrow_array()) {
print "Setting initial mailman password for $uid\n"
while (my ($uid,$uid_idx) = $query_result->fetchrow_array()) {
print "Setting initial mailman password for $uid ($uid_idx)\n"
if ($debug);
my $password = TBGenSecretKey();
$password = substr($password, 0, 10);
DBQueryFatal("update users set mailman_password='$password' ".
"where uid='$uid'");
"where uid_idx='$uid_idx'");
}
#
......@@ -846,7 +847,7 @@ sub Initialize()
#
my $projects_result =
DBQueryFatal("select g.pid,g.gid from groups as g ".
"left join projects as p on p.pid=g.pid ".
"left join projects as p on p.pid_idx=g.pid_idx ".
"where p.approved=1 ".
# "and (p.pid='testbed' or p.pid='emulab-ops' or ".
# " p.pid='tbres' or p.pid='utahstud') ".
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005 University of Utah and the Flux Group.
# Copyright (c) 2005, 2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -161,20 +161,20 @@ foreach my $pid (keys(%wikipids)) {
# Now the users.
#
$query_result =
DBQueryFatal("select distinct g.uid,u.usr_name,u.usr_email,u.wikiname ".
DBQueryFatal("select distinct g.uid,u.uid_idx,u.usr_name,u.usr_email,u.wikiname ".
" from group_membership as g ".
"left join users as u on u.uid=g.uid ".
"left join users as u on u.uid_idx=g.uid_idx ".
"where u.status='active' ".
# " and (g.pid='testbed' or g.pid='emulab-ops' or ".
# " g.pid='tbres' or g.pid='utahstud')" .
"order by u.admin");
my %wikiuids = (); # Indexed by user uid, gives wikiname.
my %emailaddrs = (); # Indexed by user uid, gives user email address.
my %wikiuids = (); # Indexed by user uid_idx, gives wikiname.
my %emailaddrs = (); # Indexed by user uid_idx, gives user email address.
# Clear this for next loop.
%wikinames = ();
while (my ($uid,$name,$email,$wikiname) = $query_result->fetchrow_array()) {
while (my ($uid,$idx,$name,$email,$wikiname) = $query_result->fetchrow_array()) {
$emailaddrs{$uid} = $email;
if (!defined($wikiname) || $wikiname eq "") {
......@@ -221,23 +221,23 @@ while (my ($uid,$name,$email,$wikiname) = $query_result->fetchrow_array()) {
}
}
$wikinames{$wikiname} = $uid;
$wikiuids{$uid} = $wikiname;
$emailaddrs{$uid} = $email;
$wikiuids{$idx} = [$uid, $wikiname];
$emailaddrs{$idx} = $email;
}