Commit 9253e03b authored by Leigh Stoller's avatar Leigh Stoller

Minor fixes and cleanups.

parent 66701c41
......@@ -35,7 +35,8 @@ script-install: dir-install
$(INSTALL_PROG) $(SRCDIR)/update $(INSTALL_DIR)/update
$(INSTALL_PROG) $(SRCDIR)/libsetup.pm $(INSTALL_DIR)/libsetup.pm
$(INSTALL_PROG) $(SRCDIR)/liblocsetup.pm $(INSTALL_DIR)/liblocsetup.pm
# $(INSTALL_PROG) $(SRCDIR)/rc.testbed /usr/local/etc/rc.d/testbed.sh
$(INSTALL_PROG) $(SRCDIR)/rc.testbed $(INSTALL_DIR)/rc.testbed
$(INSTALL_PROG) $(SRCDIR)/mkemuman.sh $(INSTALL_DIR)/mkemuman.sh
post-install:
chown root $(INSTALL_DIR)/update
......
......@@ -142,7 +142,7 @@ sub doaccounts ()
#
# Group info goes in the hash table.
#
$newgroups{$1} = $2
$newgroups{"emu-$1"} = $2
}
elsif ($_ =~ /^ADDUSER LOGIN=([0-9a-z]+)/) {
#
......@@ -168,9 +168,10 @@ sub doaccounts ()
# DB as we create it.
#
while (($group, $gid) = each %newgroups) {
($exists) = getgrgid($gid);
my ($exists,undef,$curgid) = getgrnam($group);
if ($exists) {
if ($exists ne $group) {
if ($gid != $curgid) {
warn "*** WARNING: $group/$gid mismatch with existing group\n";
}
next;
......@@ -260,10 +261,11 @@ sub doaccounts ()
# Must ask for the current home dir since we rely on pw.conf.
#
if (defined($homedir) &&
index($homedir, "/${login}") &&
index($homedir, "/${login}")) {
print "Removing home directory: $homedir\n";
system("rm -rf $homedir")) {
if (system("rm -rf $homedir")) {
warn "*** WARNING: Could not remove homedir $homedir.\n";
}
}
# Delete from DB only if successful.
......@@ -297,9 +299,14 @@ sub doaccounts ()
my ($exists,undef,$curuid) = getpwnam($login);
if ($exists) {
if ($exists ne $login || $curuid != $uid) {
if (!defined($PWDDB{$login})) {
warn "*** WARNING: ".
"Skipping since $login existed before EmulabMan!\n";
next;
}
if ($curuid != $uid) {
warn "*** WARNING: ".
"$login/$uid mismatch with existing login.\n";
"$login/$uid uid mismatch with existing login.\n";
next;
}
print "Updating $login login info.\n";
......@@ -324,7 +331,7 @@ sub doaccounts ()
undef,undef,undef,$homedir) = getpwuid($uid);
my $sshdir = "$homedir/.ssh";
if (! -e $sshdir && (defined($ekey) || defined($hkey))) {
if (! -e $sshdir && ($ekey ne "" || $hkey ne "")) {
if (! mkdir($sshdir, 0700)) {
warn("*** WARNING: Could not mkdir $sshdir: $!\n");
next;
......@@ -337,10 +344,10 @@ sub doaccounts ()
warn("*** WARNING: Could not open $sshdir/keys: $!\n");
next;
}
if (defined($ekey)) {
if ($ekey ne "") {
print AUTHKEYS "$ekey\n";
}
if (defined($hkey)) {
if ($hkey ne "") {
print AUTHKEYS "$hkey\n";
}
close(AUTHKEYS);
......
#!/bin/csh
pw useradd emulabman -u 65520 -g bin -m -s /bin/tcsh -c \"Emulab Man\"
cd /usr/local/etc/testbed
cp rc.testbed /usr/local/etc/rc.d/testbed.sh
chown emulabman . *
chgrp bin . *
chown root update
chmod u+s update
chown root /usr/bin/suidperl
chmod u+s /usr/bin/suidperl
cd ~emulabman
chmod 755 .
mkdir .ssh
chown emulabman .ssh
chgrp bin .ssh
chmod 700 .ssh
cd .ssh
touch authorized_keys
chown emulabman authorized_keys
chgrp bin authorized_keys
echo "1024 37 168728947415883137658395816497236019932357443574364998989351516015013006429180411438552594116282442938932702706360430451154958992295988097967662214818020771421328881173382895214540694120581207714991274873698590147743427181599852480329442016838781882554809552882295931111276319070960396053057987057937216750401 root@paper.cs.utah.edu" > authorized_keys
......@@ -65,7 +65,8 @@ function SPITFORM($formfields, $returning, $errors)
</td>
</tr>\n
<form action=joinproject.php3 method=post>\n";
<form enctype=multipart/form-data
action=joinproject.php3 method=post>\n";
if (! $returning) {
#
......@@ -461,19 +462,24 @@ if (!$returning) {
# If usr provided a file for the key, it overrides the paste in text.
# Must read and check it.
#
# XXX I allow only a single line of stuff. The rest is ignored for now.
#
if (isset($usr_keyfile) &&
strcmp($usr_keyfile, "") &&
strcmp($usr_keyfile, "none")) {
$keyfilegoo = file($usr_keyfile);
if (! ereg("^[0-9a-zA-Z\@\. ]*$", $keyfilegoo[0])) {
$errors["PubKey File Contents"] = "Invalid characters";
if (! ($fp = fopen($usr_keyfile, "r"))) {
TBERROR("Could not open $usr_keyfile", 1);
}
else {
$usr_key = $keyfilegoo[0];
$buffer = fgets($fp, 4096);
if (! ereg("^[0-9a-zA-Z\@\. ]*$", $buffer)) {
$errors["PubKey File Contents"] = "Invalid characters";
SPITFORM($formfields, $errors);
PAGEFOOTER();
return;
}
$usr_key = Chop($buffer);
fclose($fp);
}
}
else {
......
......@@ -60,7 +60,8 @@ function SPITFORM($formfields, $errors)
</td>
</tr>\n
<form action=moduserinfo.php3 method=post>\n";
<form enctype=multipart/form-data
action=moduserinfo.php3 method=post>\n";
#
# UserName. This is a constant field.
......@@ -184,7 +185,6 @@ function SPITFORM($formfields, $errors)
<td rowspan><center>Upload (1K max)[<b>3</b>]<br>
<b>Or</b><br>
<br>
Insert Key
</center></td>
......@@ -443,16 +443,21 @@ if (isset($formfields[usr_key]) &&
if (isset($usr_keyfile) &&
strcmp($usr_keyfile, "") &&
strcmp($usr_keyfile, "none")) {
$keyfilegoo = file($usr_keyfile);
if (! ereg("^[0-9a-zA-Z\@\. ]*$", $keyfilegoo[0])) {
if (! ($fp = fopen($usr_keyfile, "r"))) {
TBERROR("Could not open $usr_keyfile", 1);
}
$buffer = fgets($fp, 4096);
if (! ereg("^[0-9a-zA-Z\@\. \n]*$", $buffer)) {
$errors["PubKey File Contents"] = "Invalid characters";
SPITFORM($formfields, $errors);
PAGEFOOTER();
return;
}
$usr_key = $keyfilegoo[0];
$usr_key = Chop($buffer);
fclose($fp);
}
#
......
......@@ -71,7 +71,8 @@ function SPITFORM($formfields, $returning, $errors)
</td>
</tr>\n
<form action=newproject.php3 method=post>\n";
<form enctype=multipart/form-data
action=newproject.php3 method=post>\n";
if (! $returning) {
#
......@@ -649,19 +650,24 @@ if (!$returning) {
# If usr provided a file for the key, it overrides the paste in text.
# Must read and check it.
#
# XXX I allow only a single line of stuff. The rest is ignored for now.
#
if (isset($usr_keyfile) &&
strcmp($usr_keyfile, "") &&
strcmp($usr_keyfile, "none")) {
$keyfilegoo = file($usr_keyfile);
if (! ereg("^[0-9a-zA-Z\@\. ]*$", $keyfilegoo[0])) {
$errors["PubKey File Contents"] = "Invalid characters";
if (! ($fp = fopen($usr_keyfile, "r"))) {
TBERROR("Could not open $usr_keyfile", 1);
}
else {
$usr_key = $keyfilegoo[0];
$buffer = fgets($fp, 4096);
if (! ereg("^[0-9a-zA-Z\@\. \n]*$", $buffer)) {
$errors["PubKey File Contents"] = "Invalid characters";
SPITFORM($formfields, $errors);
PAGEFOOTER();
return;
}
$usr_key = Chop($buffer);
fclose($fp);
}
}
else {
......
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