Commit 136b09b6 authored by Leigh Stoller's avatar Leigh Stoller

CMU sillynees; add a hook script they can modify for post-user

creation.  Only runs on the CMU emulab.
parent a82e4ef2
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -16,6 +16,7 @@ SBIN_STUFF = tbacct addsfskey addpubkey mkusercert quotamail genpubkeys \
newuser newproj
LIBEXEC_STUFF = webtbacct webaddsfskey webaddpubkey webmkusercert \
webnewuser webnewproj
CTRLSBIN_STUFF = adduserhook
# These scripts installed setuid, with sudo.
SETUID_BIN_SCRIPTS =
......@@ -26,7 +27,7 @@ SETUID_LIBX_SCRIPTS =
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all: $(SBIN_STUFF) $(LIBEXEC_STUFF)
all: $(SBIN_STUFF) $(LIBEXEC_STUFF) $(CTRLSBIN_STUFF)
include $(TESTBED_SRCDIR)/GNUmakerules
......@@ -50,6 +51,8 @@ post-install:
control-install:
hook-install: $(addprefix $(INSTALL_DIR)/opsdir/sbin/, $(CTRLSBIN_STUFF))
# This rule says what web* script depends on which installed binary directory.
$(LIBEXEC_STUFF): $(INSTALL_SBINDIR)
......@@ -64,3 +67,7 @@ $(LIBEXEC_STUFF): $(TESTBED_SRCDIR)/WEBtemplate.in
clean:
rm -f *.o core
$(INSTALL_DIR)/opsdir/sbin/%: %
@echo "Installing $<"
-mkdir -p $(INSTALL_DIR)/opsdir/sbin
$(INSTALL) $< $@
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2008 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
use English;
use Getopt::Std;
#
# A hook invoked from boss after a new user is added to ops.
#
sub usage()
{
print "Usage: adduserhook <uid>\n";
exit(-1);
}
my $optlist = "d";
my $debug = 0;
#
# Configure variables
#
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
#
# Turn off line buffering on output
#
$| = 1;
#
# Untaint the path
#
$ENV{'PATH'} = "/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Only real root can run this script.
#
if ($UID != 0) {
die("*** $0:\n".
" Must be root to run this script!\n");
}
#
# Testbed Support libraries
#
use lib "@prefix@/lib";
use libtestbed;
# Protos
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{"d"})) {
$debug = 1;
}
if (@ARGV != 1) {
usage();
}
my $user = shift(@ARGV);
#
# Add your code here, but remember you are running as root. Be careful.
#
exit(0);
sub fatal($)
{
my($mesg) = $_[0];
die("*** $0:\n".
" $mesg\n");
}
......@@ -48,6 +48,7 @@ my $BUGDBSUPPORT= @BUGDBSUPPORT@;
my $OPSDBSUPPORT= @OPSDBSUPPORT@;
my $CHATSUPPORT = @CHATSUPPORT@;
my $MAILMANSUPPORT= @MAILMANSUPPORT@;
my $THISHOMEBASE= "@THISHOMEBASE@";
my $PROTOUSER = 'elabman';
my $SAMBANODE = "fs"; # DNS makes this do the right thing in E-in-E.
......@@ -77,6 +78,7 @@ my $MMMODIFYUSER= "$TB/sbin/mmmodifymember";
my $ADDMMUSER = "$TB/sbin/addmmuser";
my $DELMMUSER = "$TB/sbin/delmmuser";
my $OPSDBCONTROL= "$TB/sbin/opsdb_control";
my $ADDHOOK = "$TB/sbin/adduserhook";
my $NOLOGIN = "/sbin/nologin";
my $SSH = "$TB/bin/sshtb";
my $SAVEUID = $UID;
......@@ -402,6 +404,16 @@ sub AddUser()
if (system("$SSH -host $CONTROL $CHPASS -p '$pswd' $user")) {
fatal("Could not initialize password for user $user on $CONTROL!");
}
#
# Extra hook added for CMU. Generalize later.
#
if ($THISHOMEBASE =~ /^cmuemulab$/i) {
print "Running post create hook for user $user on $CONTROL.\n";
# Do not worry about failure.
system("$SSH -host $CONTROL $ADDHOOK $user");
}
}
$UID = $SAVEUID;
......
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