Commit 2a63abab authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Merge branch 'master' of git-public.flux.utah.edu:/flux/git/emulab-devel

parents e495330a 7d63765d
......@@ -2,3 +2,5 @@ event/trafgen/tg2.0
sensors/nfstrace/nfsdump2/Makefile
sensors/nfstrace/nfsdump2/config.h
sensors/nfstrace/nfsdump2/config.log
protogeni/demo/.metadata
protogeni/demo/map/.metadata
#!/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";
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -19,18 +19,21 @@ use Getopt::Std;
# allows users to do things on behalf of other users, and we want to track
# that in the audit log.
#
# This script always does the right thing ...
# Use -u for update mode, which skips the checks on current status,
# and forces the target user into that state. Eventually, this should
# be the default mode of operation (independent of web interface).
#
sub usage()
{
print("Usage: tbacct [-f] [-b] ".
print("Usage: tbacct [-f] [-b] [-u] ".
"<add|del|mod|passwd|wpasswd|email|freeze|thaw|verify> ".
"<user> [args]\n");
exit(-1);
}
my $optlist = "fb";
my $optlist = "fbu";
my $force = 0;
my $batch = 0;
my $update = 0;
#
# Configure variables
......@@ -50,6 +53,7 @@ my $CHATSUPPORT = @CHATSUPPORT@;
my $MAILMANSUPPORT= @MAILMANSUPPORT@;
my $THISHOMEBASE= "@THISHOMEBASE@";
my $PROTOUSER = 'elabman';
my $ELABINELAB = @ELABINELAB@;
my $SAMBANODE = "fs"; # DNS makes this do the right thing in E-in-E.
my $SMBPASSWD = "/usr/local/bin/smbpasswd";
......@@ -79,6 +83,7 @@ my $ADDMMUSER = "$TB/sbin/addmmuser";
my $DELMMUSER = "$TB/sbin/delmmuser";
my $OPSDBCONTROL= "$TB/sbin/opsdb_control";
my $ADDHOOK = "$TB/sbin/adduserhook";
my $SETGROUPS = "$TB/sbin/setgroups";
my $NOLOGIN = "/sbin/nologin";
my $SSH = "$TB/bin/sshtb";
my $SAVEUID = $UID;
......@@ -174,6 +179,9 @@ if (defined($options{"f"})) {
if (defined($options{"b"})) {
$batch = 1;
}
if (defined($options{"u"})) {
$update = 1;
}
if (@ARGV < 2) {
usage();
}
......@@ -349,6 +357,13 @@ sub AddUser()
if ($webonly) {
return 0;
}
#
# Allow for users to be initialized to frozen in an inner Emulab.
#
if ($ELABINELAB && $status eq USERSTATUS_FROZEN) {
print STDERR "Ignoring frozen user in elabinelab\n";
return 0;
}
if ($wikionly) {
$EUID = $UID;
......@@ -395,14 +410,18 @@ sub AddUser()
}
}
# shell escape.
$pswd =~ s/\$/\\\$/g;
$pswd =~ s/\*/\\\*/g;
print "Initializing user $user password on $CONTROL.\n";
if (system("$SSH -host $CONTROL $CHPASS -p '$pswd' $user")) {
fatal("Could not initialize password for user $user on $CONTROL!");
#
# Leave the password "starred" on elabinelab; safer.
#
if (!$ELABINELAB) {
# shell escape.
$pswd =~ s/\$/\\\$/g;
$pswd =~ s/\*/\\\*/g;
print "Initializing user $user password on $CONTROL.\n";
if (system("$SSH -host $CONTROL $CHPASS -p '$pswd' $user")) {
fatal("Could not initialize password for $user on $CONTROL!");
}
}
#
......@@ -620,8 +639,9 @@ sub UpdatePassword()
#
# Change on ops only if there is a real account there.
# For ELABINELAB, safer to leave the password "starred".
#
if (! $wikionly) {
if (!$wikionly && !$ELABINELAB) {
#
# Grab from the DB to avoid taint checking sillyness.
#
......@@ -901,7 +921,11 @@ sub FreezeUser()
# Check status.
#
if ($status ne USERSTATUS_FROZEN) {
fatal("$user is still active! Cannot freeze the account!");
fatal("$user is still active! Cannot freeze the account!")
if (!$update);
$target_user->SetStatus(USERSTATUS_FROZEN());
$status = USERSTATUS_FROZEN();
}
$sfsupdate = 1;
......@@ -923,11 +947,38 @@ sub ThawUser()
# Check status.
#
if ($status ne USERSTATUS_ACTIVE) {
fatal("$user is not active! Cannot thaw the account!");
fatal("$user is not active! Cannot thaw the account!")
if (!$update);
$target_user->SetStatus(USERSTATUS_ACTIVE());
$status = USERSTATUS_ACTIVE();
}
$sfsupdate = 1;
return UpdateUser(0);
#
# This lets users start off as frozen in an ELABINELAB, and then
# get created later. Saves a lot of time.
#
if ($ELABINELAB &&
system("egrep -q -s '^${user}:' /etc/passwd")) {
AddUser() == 0
or fatal("Cannot thaw $user");
system("$USERMOD -n $user -s /bin/tcsh");
}
else {
UpdateUser(0) == 0
or fatal("Cannot thaw $user");
}
#
# Invoke as real user for auditing.
#
$EUID = $UID;
system("$SETGROUPS $user");
$EUID = 0;
return 0;
}
#
......
......@@ -27,9 +27,9 @@ static const char rcsid[] = "$Id: parse_advertisement_rspec.cc,v 1.7 2009-10-21
#define ISSWITCH(n) (n->types.find("switch") != n->types.end())
#ifdef TBROOT
#define SCHEMA_LOCATION TBROOT"/lib/assign/rspec-ad.xsd"
#define SCHEMA_LOCATION TBROOT"/lib/assign/ad.xsd"
#else
#define SCHEMA_LOCATION "rspec-ad.xsd"
#define SCHEMA_LOCATION "ad.xsd"
#endif
/*
......
......@@ -27,9 +27,9 @@ static const char rcsid[] = "$Id: parse_request_rspec.cc,v 1.16 2009-10-21 20:49
#define ISSWITCH(n) (n->types.find("switch") != n->types.end())
#ifdef TBROOT
#define SCHEMA_LOCATION TBROOT"/lib/assign/rspec-request.xsd"
#define SCHEMA_LOCATION TBROOT"/lib/assign/request.xsd"
#else
#define SCHEMA_LOCATION "rspec-request.xsd"
#define SCHEMA_LOCATION "request.xsd"
#endif
/*
* XXX: Do I have to release lists when done with them?
......@@ -601,9 +601,16 @@ bool populate_link (DOMElement* elt, tb_vgraph &vg, map< pair<string,string>, pa
tb_vnode *src_vnode = get(vvertex_pmap,v_src_vertex);
tb_vnode *dst_vnode = get(vvertex_pmap,v_dst_vertex);
bool emulated = false;
if (str_virtualization_type.compare("raw") == 0 || str_virtualization_type.compare("") == 0)
emulated = true;
// If the virtualization type on the string is missing or "raw", then
// we leave the emulated flag off - we want the whole physical
// interface. If anything else, we assume that it's some kind of
// virtualized link and the emulated flag should be set.
bool emulated = true;
if (str_virtualization_type.compare("raw") == 0 ||
str_virtualization_type.compare("") == 0) {
emulated = false;
cerr << "Set emulated=false" << endl;
}
// bool allow_delayed = !hasChildTag (elt, "nodelay");
......
......@@ -60,7 +60,7 @@ extern tb_sgraph SG; // switch fabric
void score_link(pedge pe,vedge ve,tb_pnode *src_pnode,tb_pnode *dst_pnode);
void unscore_link(pedge pe,vedge ve,tb_pnode *src_pnode,tb_pnode *dst_pnode);
bool find_best_link(pvertex pv,pvertex switch_pv,tb_vlink *vlink,
pedge &out_edge, bool check_src_iface,
pedge &out_edge, bool flipped, bool check_src_iface,
bool check_dst_iface);
int find_interswitch_path(pvertex src_pv,pvertex dest_pv,
int bandwidth,pedge_path &out_path,
......@@ -240,7 +240,7 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
pedge pe;
// Direct link (have to check both interfaces if they are fixed)
if (find_best_link(dest_pv,pv,vlink,pe,true,true)) {
if (find_best_link(dest_pv,pv,vlink,pe,flipped,true,true)) {
tb_link_info info(tb_link_info::LINK_DIRECT);
info.plinks.push_back(pe);
resolutions.push_back(info);
......@@ -279,9 +279,10 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
}
if (first_link) {
SDEBUG(cerr << " intraswitch: finding first link" << endl;)
// Check only whether the source interface is fixed - this is the
// first link in a multi-hop path
if (!find_best_link(pv,*switch_it,vlink,first,true,false)) {
if (!find_best_link(pv,*switch_it,vlink,first,flipped,true,false)) {
SDEBUG(cerr << " intraswitch failed - no link first" <<
endl;)
// No link to this switch
......@@ -292,7 +293,9 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
if (second_link) {
// Check only whether the dest interface is fixed - this is the
// last link in a multi-hop path
if (!find_best_link(dest_pv,*switch_it,vlink,second,false,true)) {
SDEBUG(cerr << " intraswitch: finding second link (" << ")" << endl;)
if (!find_best_link(dest_pv,*switch_it,vlink,second,flipped,
false,true)) {
// No link to this switch
SDEBUG(cerr << " intraswitch failed - no link second" <<
endl;)
......@@ -359,7 +362,8 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
if (first_link) {
// Check only whether the source interface is fixed - this is the
// first link in a multi-hop path
if (!find_best_link(pv,*source_switch_it,vlink,first,true,false)) {
if (!find_best_link(pv,*source_switch_it,vlink,first,flipped,
true,false)) {
// No link to this switch
SDEBUG(cerr << " interswitch failed - no first link"
<< endl;)
......@@ -370,7 +374,8 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
if (second_link) {
// Check only whether the dest interface is fixed - this is the
// last link in a multi-hop path
if (!find_best_link(dest_pv,*dest_switch_it,vlink,second,false,true)) {
if (!find_best_link(dest_pv,*dest_switch_it,vlink,second,flipped,
false,true)) {
// No link to tshis switch
SDEBUG(cerr << " interswitch failed - no second link" << endl;)
continue;
......@@ -510,6 +515,7 @@ void resolve_link(vvertex vv, pvertex pv, tb_vnode *vnode, tb_pnode *pnode,
*/
bool flipped = false;
if (vlink->src != vv) {
SDEBUG(cerr << " vlink is flipped" << endl);
flipped = true;
}
......@@ -1461,7 +1467,7 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed, bool skip
}
bool find_best_link(pvertex pv,pvertex switch_pv,tb_vlink *vlink,
pedge &out_edge, bool check_src_iface,
pedge &out_edge, bool flipped, bool check_src_iface,
bool check_dst_iface)
{
pvertex dest_pv;
......@@ -1486,15 +1492,20 @@ bool find_best_link(pvertex pv,pvertex switch_pv,tb_vlink *vlink,
// If the vlink has a fixed source interface, and it doesn't match
// this plink, skip it
// XXX: Is this gonna break interswtich?
if (vlink->fix_src_iface && check_src_iface) {
if (plink->srciface != vlink->src_iface) {
SDEBUG(cerr << "find_best_link: Fix source: " << plink->srciface
<< " != " << vlink->src_iface << endl);
// Whether we check the 'source' or 'destination' on the vlink against
// the phyisical link's source interface depends on whether we're
// traversing the link if forward or reverse (flipped) order
fstring compare_iface = (flipped?vlink->dst_iface:vlink->src_iface);
if (plink->srciface != compare_iface) {
SDEBUG(cerr << " find_best_link (" << vlink->name <<
"): Fix source: " << plink->srciface << " != " <<
compare_iface << endl);
continue;
} else {
SDEBUG(cerr << "find_best_link: Fix source: " << plink->srciface
<< " == " << vlink->src_iface << endl);
SDEBUG(cerr << " find_best_link (" << vlink->name <<
"): Fix source: " << plink->srciface << " == " <<
compare_iface << endl);
}
}
......@@ -1503,13 +1514,16 @@ bool find_best_link(pvertex pv,pvertex switch_pv,tb_vlink *vlink,
// XXX: This only works because we always have the node as the 'source'
// of a plink! Shouldn't depend on this!
if (vlink->fix_dst_iface && check_dst_iface) {
if (plink->srciface != vlink->dst_iface) {
SDEBUG(cerr << "find_best_link: Fix dst: " << plink->srciface
<< " != " << vlink->dst_iface << endl);
fstring compare_iface = (flipped?vlink->src_iface:vlink->dst_iface);
if (plink->srciface != compare_iface) {
SDEBUG(cerr << " find_best_link (" << vlink->name <<
"): Fix dst: " << plink->srciface << " != " <<
compare_iface << endl);
continue;
} else {
SDEBUG(cerr << "find_best_link: Fix dst: " << plink->srciface
<< " == " << vlink->dst_iface << endl);
SDEBUG(cerr << " find_best_link (" << vlink->name <<
"): Fix dst: " << plink->srciface << " == " <<
compare_iface << endl);
}
}
......@@ -1562,18 +1576,25 @@ bool find_best_link(pvertex pv,pvertex switch_pv,tb_vlink *vlink,
best_distance = distance;
found_best = true;
best_users = plink->emulated+plink->nonemulated;
SDEBUG(cerr << " find_best_link: picked " << plink->name <<
" with " << best_users << " users" << endl;)
}
}
}
}
if ((!vlink->emulated) && found_best && (best_users > 0)) {
SDEBUG(cerr << " find_best_link failing (first case) (" <<
vlink->emulated << "," << found_best << "," << best_users <<
")" << endl;)
return false;
}
if (found_best) {
out_edge = best_pedge;
SDEBUG(cerr << " find_best_link succeeding" << endl;)
return true;
} else {
SDEBUG(cerr << " find_best_link failing (second case)" << endl;)
return false;
}
}
......
#!/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')" .
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -13,7 +13,7 @@ include $(OBJDIR)/Makeconf
SBIN_SCRIPTS = jabbersetup addjabberuser deljabberuser \
modjabberbuddies addjabberchat deljabberchat \
setchatmembers chatsup.py
setchatmembers
LIBEXEC_SCRIPTS =
CTRL_LIBEXEC_SCRIPTS =
CTRL_LIB_FILES =
......
#! /usr/bin/env python
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005, 2006 University of Utah and the Flux Group.
# All rights reserved.
#
# Permission to use, copy, modify and distribute this software is hereby
# granted provided that (1) source code retains these copyright, permission,
# and disclaimer notices, and (2) redistributions including binaries
# reproduce the notices in supporting documentation.
#
# THE UNIVERSITY OF UTAH ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
# CONDITION. THE UNIVERSITY OF UTAH DISCLAIMS ANY LIABILITY OF ANY KIND
# FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
#
import sys
import getopt
import os, os.path
TBROOT = "@prefix@"
DOMAIN = "@OURDOMAIN@"
TBPATH = os.path.join(TBROOT, "lib")
if TBPATH not in sys.path:
sys.path.append(TBPATH)
pass
# We get this from the testbed library directory.
import xmpp
# Debugging output.
debug = False
verbose = False
# Error condition.
server_error = 0
exitval = 0
# The default admin user to connect as is tbops.
admin_user = "testbed-ops"
admin_password = "WeLovChat"
admin_resource = "TestbedOps"
admin_jid = ""
# Default server to jabber server
jabber_server = "jabber." + DOMAIN
muc_server = "conference." + DOMAIN
# The room we are operating on.
chatroom = False
chatroom_jid = "";
# Current ID we are looking for, and the one we have.
current_id = False;
desired_id = False;
# Stuff to hand to the muc server.
chatroom_fields = {
"muc#owner_roomname" : "",
"muc#owner_roomdesc" : "",
"muc#owner_publicroom" : "0",
"muc#owner_persistentroom" : "1",
"privacy" : "1",
"muc#owner_maxusers" : "50",
"muc#owner_moderatedroom" : "0",
"defaulttype" : "0",
"privmsg" : "0",
"muc#owner_inviteonly" : "1",
"muc#owner_allowinvites" : "1",
"legacy" : "0",
"muc#owner_passwordprotectedroom" : "1",
"muc#owner_roomsecret" : "foobar",
"muc#owner_enablelogging" : "0",
"muc#owner_whois" : "anyone"
}
##
# Print the usage statement to stdout.
#
def usage():
print ("Usage: " + sys.argv[0]
+ " [-d] [-s server] <room> <op> [params]")
sys.exit(-1)
#
# Process program arguments.
#
try:
# Parse the options,
opts, req_args = getopt.getopt(sys.argv[1:],
"dhs:",
[ "help", "server="])
# ... act on them appropriately, and
for opt, val in opts:
if opt in ("-h", "--help"):
usage()
pass
elif opt in ("-s", "--server"):
jabber_server = val
pass
elif opt in ("-d", "--debug"):
debug = True
pass
pass
pass
except getopt.error, e:
print e.args[0]
usage()
sys.exit(2)
pass
if len(req_args) < 2:
usage()
sys.exit(2)
pass
# First argument is the room jid.
chatroom = req_args[0]
req_args = req_args[1:];
# We need these a lot.
chatroom_jid = chatroom + "@" + muc_server + "/" + admin_resource;
admin_jid = admin_user + "@" + jabber_server + "/" + admin_resource
#
# These handlers are required by the xmpp library.
#
def HandlePresence(session, presence):
global current_id, server_error
if verbose:
print str(presence)
pass
current_id = presence.getID()
if presence.getType() == 'error':
errmsg = presence.getError()
server_error = presence.getErrorCode()
raise xmpp.protocol.NodeProcessed
pass
# This is for doing the RoomExists test below.
def HandleMessage(session, message):
global current_id, server_error
if verbose:
print str(message)
pass
current_id = message.getID()
if message.getType() == 'error':
errmsg = message.getError()
server_error = message.getErrorCode()
raise xmpp.protocol.NodeProcessed
pass
def HandleIQ(conn, iq_node):
global current_id, desired_id
if verbose:
print str(iq_node)
pass
current_id = iq_node.getID()
if current_id == desired_id:
raise xmpp.protocol.NodeProcessed
pass
def HandleIQ_Error(conn, iq_node):
global current_id, server_error
if verbose:
print str(iq_node)
pass
errmsg = iq_node.getError()
current_id = iq_node.getID()
server_error = 1
raise xmpp.protocol.NodeProcessed
pass
#
# Try and connect.
#
def Connect():
jid = xmpp.protocol.JID(admin_jid)
dbg = []
if debug:
dbg = ['always',]
pass
cl = xmpp.Client(jid.getDomain(), debug=dbg)
cl.connect()
cl.auth(jid.getNode(), admin_pass