Commit 35bf212d authored by Leigh Stoller's avatar Leigh Stoller

Add eventkey function to return event shared key and write to usual

spot in /var/emulab/boot.
parent e3f1e9c3
......@@ -29,7 +29,7 @@ use Exporter;
TMNICKNAME HOSTSFILE TMSTARTUPCMD FINDIF TMTUNNELCONFIG
TMTRAFFICCONFIG TMROUTECONFIG TMLINKDELAY TMDELMAP TMMOUNTDB
TMPROGAGENTS TMPASSDB TMGROUPDB TMGATEDCONFIG
TMSYNCSERVER TMRCSYNCSERVER TMKEYHASH TMNODEID
TMSYNCSERVER TMRCSYNCSERVER TMKEYHASH TMNODEID TMEVENTKEY
);
# Must come after package declaration!
......@@ -245,6 +245,7 @@ sub TMDELMAP() { CONFDIR() . "/delay_mapping";}
sub TMSYNCSERVER() { CONFDIR() . "/syncserver";}
sub TMRCSYNCSERVER() { CONFDIR() . "/rc.syncserver";}
sub TMKEYHASH() { CONFDIR() . "/keyhash";}
sub TMEVENTKEY() { CONFDIR() . "/eventkey";}
sub TMNODEID() { CONFDIR() . "/nodeid";}
#
......@@ -331,6 +332,7 @@ sub cleanup_node ($) {
unlink TMMOUNTDB . ".db";
unlink TMSFSMOUNTDB . ".db";
unlink "$VARDIR/db/rtabid";
unlink TMKEYHASH, TMEVENTKEY;
#
# If scrubbing, remove the password/group file DBs so that we revert
......@@ -2239,6 +2241,46 @@ sub dokeyhash()
return 0;
}
#
# Get the event key
#
sub doeventkey()
{
my $eventkey;
my @tmccresults;
if (tmcc(TMCCCMD_EVENTKEY, undef, \@tmccresults) < 0) {
warn("*** WARNING: Could not get eventkey from server!\n");
return -1;
}
return 0
if (! @tmccresults);
#
# There should be just one string. Ignore anything else.
#
if ($tmccresults[0] =~ /EVENTKEY KEY=\'([\w]*)\'/) {
$eventkey = $1;
}
else {
warn "*** WARNING: Bad eventkey line: $tmccresults[0]";
return -1;
}
#
# Write a file so the node knows the key.
#
my $oldumask = umask(0227);
if (system("echo -n '$eventkey' > ". TMEVENTKEY)) {
warn "*** WARNING: Could not write " . TMEVENTKEY . "\n";
umask($oldumask);
return -1;
}
umask($oldumask);
return 0;
}
#
# Get the nodeid
#
......@@ -2440,8 +2482,9 @@ sub bootsetup()
#
# Get the key
#
print STDOUT "Checking Testbed key ...\n";
print STDOUT "Checking Testbed keys ...\n";
dokeyhash();
doeventkey();
#
# Router Configuration.
......@@ -2546,8 +2589,9 @@ sub jailsetup()
print STDOUT "Checking Testbed sync server setup ...\n";
dosyncserver();
print STDOUT "Checking Testbed key ...\n";
print STDOUT "Checking Testbed keys ...\n";
dokeyhash();
doeventkey();
print STDOUT "Checking Testbed RPM configuration ... \n";
dorpms();
......@@ -2694,8 +2738,9 @@ sub plabsetup()
print STDOUT "Checking Testbed hostnames configuration ... \n";
dohostnames();
print STDOUT "Checking Testbed key ...\n";
print STDOUT "Checking Testbed keys ...\n";
dokeyhash();
doeventkey();
print STDOUT "Checking Testbed group/user configuration ... \n";
doaccounts();
......
......@@ -25,7 +25,7 @@ use Exporter;
TMCCCMD_SFSHOSTID TMCCCMD_JAILCONFIG
TMCCCMD_PLABCONFIG TMCCCMD_SUBCONFIG TMCCCMD_LINKDELAYS
TMCCCMD_PROGRAMS TMCCCMD_SYNCSERVER TMCCCMD_KEYHASH TMCCCMD_NODEID
TMCCCMD_NTPINFO TMCCCMD_NTPDRIFT
TMCCCMD_NTPINFO TMCCCMD_NTPDRIFT TMCCCMD_EVENTKEY
);
# Must come after package declaration!
......@@ -139,6 +139,7 @@ my %commandset =
"ntpinfo" => {TAG => "ntpinfo"},
"ntprift" => {TAG => "ntpdrift"},
"sdparams" => {TAG => "sdparams"},
"eventkey" => {TAG => "eventkey"},
);
#
......@@ -177,6 +178,7 @@ sub TMCCCMD_KEYHASH() { $commandset{"keyhash"}->{TAG}; }
sub TMCCCMD_NODEID() { $commandset{"nodeid"}->{TAG}; }
sub TMCCCMD_NTPINFO() { $commandset{"ntpinfo"}->{TAG}; }
sub TMCCCMD_NTPDRIFT() { $commandset{"ntpdrift"}->{TAG}; }
sub TMCCCMD_EVENTKEY() { $commandset{"eventkey"}->{TAG}; }
#
# Caller uses this routine to set configuration of this library
......
......@@ -29,7 +29,7 @@ use Exporter;
TMNICKNAME HOSTSFILE TMSTARTUPCMD FINDIF TMTUNNELCONFIG
TMTRAFFICCONFIG TMROUTECONFIG TMLINKDELAY TMDELMAP TMMOUNTDB
TMPROGAGENTS TMPASSDB TMGROUPDB TMGATEDCONFIG
TMSYNCSERVER TMRCSYNCSERVER TMKEYHASH TMNODEID
TMSYNCSERVER TMRCSYNCSERVER TMKEYHASH TMNODEID TMEVENTKEY
);
# Must come after package declaration!
......@@ -245,6 +245,7 @@ sub TMDELMAP() { CONFDIR() . "/delay_mapping";}
sub TMSYNCSERVER() { CONFDIR() . "/syncserver";}
sub TMRCSYNCSERVER() { CONFDIR() . "/rc.syncserver";}
sub TMKEYHASH() { CONFDIR() . "/keyhash";}
sub TMEVENTKEY() { CONFDIR() . "/eventkey";}
sub TMNODEID() { CONFDIR() . "/nodeid";}
#
......@@ -331,6 +332,7 @@ sub cleanup_node ($) {
unlink TMMOUNTDB . ".db";
unlink TMSFSMOUNTDB . ".db";
unlink "$VARDIR/db/rtabid";
unlink TMKEYHASH, TMEVENTKEY;
#
# If scrubbing, remove the password/group file DBs so that we revert
......@@ -2239,6 +2241,46 @@ sub dokeyhash()
return 0;
}
#
# Get the event key
#
sub doeventkey()
{
my $eventkey;
my @tmccresults;
if (tmcc(TMCCCMD_EVENTKEY, undef, \@tmccresults) < 0) {
warn("*** WARNING: Could not get eventkey from server!\n");
return -1;
}
return 0
if (! @tmccresults);
#
# There should be just one string. Ignore anything else.
#
if ($tmccresults[0] =~ /EVENTKEY KEY=\'([\w]*)\'/) {
$eventkey = $1;
}
else {
warn "*** WARNING: Bad eventkey line: $tmccresults[0]";
return -1;
}
#
# Write a file so the node knows the key.
#
my $oldumask = umask(0227);
if (system("echo -n '$eventkey' > ". TMEVENTKEY)) {
warn "*** WARNING: Could not write " . TMEVENTKEY . "\n";
umask($oldumask);
return -1;
}
umask($oldumask);
return 0;
}
#
# Get the nodeid
#
......@@ -2440,8 +2482,9 @@ sub bootsetup()
#
# Get the key
#
print STDOUT "Checking Testbed key ...\n";
print STDOUT "Checking Testbed keys ...\n";
dokeyhash();
doeventkey();
#
# Router Configuration.
......@@ -2546,8 +2589,9 @@ sub jailsetup()
print STDOUT "Checking Testbed sync server setup ...\n";
dosyncserver();
print STDOUT "Checking Testbed key ...\n";
print STDOUT "Checking Testbed keys ...\n";
dokeyhash();
doeventkey();
print STDOUT "Checking Testbed RPM configuration ... \n";
dorpms();
......@@ -2694,8 +2738,9 @@ sub plabsetup()
print STDOUT "Checking Testbed hostnames configuration ... \n";
dohostnames();
print STDOUT "Checking Testbed key ...\n";
print STDOUT "Checking Testbed keys ...\n";
dokeyhash();
doeventkey();
print STDOUT "Checking Testbed group/user configuration ... \n";
doaccounts();
......
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