Commit 08192e6b authored by Kirk Webb's avatar Kirk Webb

tbadb: Stuff for building and a rollup (squash commit) of fixes.

parent 94a1c59e
......@@ -32,6 +32,7 @@ PELABSUPPORT = @PELABSUPPORT@
PGENISUPPORT = @PROTOGENI_SUPPORT@
ISMAINSITE = @TBMAINSITE@
SPEWFROMOPS = @SPEWFROMOPS@
MOBILESUPPORT = @MOBILESUPPORT@
SYSTEM := $(shell uname -s)
include Makeconf
......@@ -53,7 +54,7 @@ SUBDIRS = \
db assign www @optional_subdirs@ clientside ipod security sensors \
pxe tbsetup account tmcd utils backend tip ipod vis \
sensors os xmlrpc autofs install/newnode_sshkeys \
tools/svn wiki collab/exp-vis node_usage install
tools/svn collab/exp-vis node_usage install
ifeq ($(ISMAINSITE),1)
SUBDIRS += tools/rmanage tools/whol
endif
......@@ -127,9 +128,11 @@ post-install:
@$(MAKE) -C www post-install
ifeq ($(EVENTSYS),1)
@$(MAKE) -C event post-install
endif
ifeq ($(MOBILESUPPORT),1)
@$(MAKE) -C mobile
endif
@$(MAKE) -C tools post-install
@$(MAKE) -C wiki post-install
@$(MAKE) -C collab post-install
@$(MAKE) -C utils post-install
ifeq ($(NODE_USAGE_SUPPORT),1)
......
......@@ -244,6 +244,7 @@ AC_SUBST(MIN_UNIX_UID)
AC_SUBST(MIN_UNIX_GID)
AC_SUBST(DELAYTHRESH)
AC_SUBST(PELABSUPPORT)
AC_SUBST(MOBILESUPPORT)
AC_SUBST(ELVIN_COMPAT)
AC_SUBST(ISOLATEADMINS)
AC_SUBST(DYNAMICROOTPASSWORDS)
......@@ -408,6 +409,7 @@ MIN_UNIX_UID=10000
MIN_UNIX_GID=6000
DELAYTHRESH=2
PELABSUPPORT=0
MOBILESUPPORT=0
ELVIN_COMPAT=0
ISOLATEADMINS=1
DYNAMICROOTPASSWORDS=1
......@@ -999,6 +1001,16 @@ else
optional_subdirs="$optional_subdirs pelab";
fi
#
# Mobile networking support.
#
if test $MOBILESUPPORT -eq 0; then
mobilefiles="";
else
mobilefiles="mobile/GNUmakefile";
optional_subdirs="$optional_subdirs mobile";
fi
#
# Enable Windows support.
# Right now this means NTFS support in imagezip, maybe more things later.
......@@ -1361,6 +1373,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
$eventfiles \
$winfiles \
$pelabfiles \
$mobilefiles \
apache/GNUmakefile apache/php.ini \
xmlrpc/GNUmakefile xmlrpc/emulabclient.py xmlrpc/emulabserver.py \
xmlrpc/sshxmlrpc_client.py xmlrpc/sshxmlrpc_server.py \
......
......@@ -114,6 +114,8 @@ PROTOGENI_LOCALUSER=1
# Portal for the Cloudlab Cluster.
CLUSTER_PORTAL="boss.emulab.net"
CLUSTER_PUBSUBD_PORT=16506
# Mobile networking support (PhantomNet)
MOBILESUPPORT=1
#
# SSL Certificate stuff. Used to customize config files in ssl directory.
......
......@@ -45,7 +45,7 @@ all: $(BIN_SCRIPTS) $(LIB_FILES)
include $(TESTBED_SRCDIR)/GNUmakerules
install: \
$(addprefix $(INSTALL_BINDIR)/, $(BIN_SCRIPTS))
$(addprefix $(INSTALL_BINDIR)/, $(BIN_SCRIPTS)) \
$(addprefix $(INSTALL_LIBDIR)/, $(LIB_FILES))
post-install:
......
......@@ -32,8 +32,10 @@ use Data::Dumper;
use lib "@prefix@/lib";
use libjsonrpc;
use EmulabConstants;
use Image;
use User;
use Node;
use Image;
# Func prototypes
sub cmd_setup($@);
......@@ -56,6 +58,7 @@ my $TBADB_PROXYCMD = "/usr/testbed/sbin/tbadb_proxy";
my $TBADB_HELLO_TMO = 10;
my $TBADB_CHECKIMAGE_TMO = 30;
my $TBADB_LOADIMAGE_TMO = 120;
my $TBADB_FORWARD_TMO = 15;
my $TBADB_REBOOT_TMO = 60;
my $CHILD_WAIT_TMO = 10;
my $SCP = "/usr/bin/scp";
......@@ -88,8 +91,7 @@ delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# We don't want to run this script unless it's the real version.
#
if ($EUID != 0) {
die("*** $0:\n".
" Must be setuid! Maybe it's a development version?\n");
die("$0: Must be setuid! Maybe it's a development version?\n");
}
#
......@@ -114,7 +116,7 @@ $libjsonrpc::debug = 1 if $debug;
my $node_id = $opts{'n'} ? $opts{'n'} : "";
if ($node_id) {
die "$0: malformed node_id argument!\n"
if ($node_id !~ /^([-\w]{$MINHLEN, $MAXHLEN})$/);
if ($node_id !~ /^([-\w]{$MINHLEN,$MAXHLEN})$/);
$node_id = $1;
}
......@@ -122,8 +124,8 @@ if ($node_id) {
my ($CMD, @ARGS) = @ARGV;
# Untaint command
die "$tbadb: malformed command!\n"
if (!$CMD =~ /^([-\w]{$MINCMDLEN,$MAXCMDLEN})$/);
die "$0: malformed command!\n"
if ($CMD !~ /^([-\w]{$MINCMDLEN,$MAXCMDLEN})$/);
$CMD = $1;
die "$0: unknown command: $CMD\n"
......@@ -214,7 +216,7 @@ sub cmd_loadimage($@) {
if (!SendRPCData($rpcout,
EncodeCall("checkimage",
{
IMG_PROJ => $imgpid,
IMG_PROJ => $imagepid,
IMG_NAME => $imagename,
IMG_TIME => $mtime,
IMG_SIZE => $size,
......@@ -233,6 +235,10 @@ sub cmd_loadimage($@) {
# Transfer the image to the remote host if necessary (SCP).
if ($data->{RESULT}->{NEED_IMG} == 1) {
my $rhost;
$node->TipServer(\$rhost);
die "tbadb::cmd_loadimage: Could not lookup control server for $node!\n"
if (!$rhost);
print "tbadb: Sending $imagepath to $rhost\n";
my $rpath = $data->{RESULT}->{REMOTE_PATH};
die "tbadb::cmd_loadimage: Failed to transfer image to $rhost: $imagepath\n"
......@@ -245,8 +251,8 @@ sub cmd_loadimage($@) {
if (!SendRPCData($rpcout,
EncodeCall("loadimage",
{
IMG_PROJ => $imgpid,
IMG_NAME => $imgname,
IMG_PROJ => $imagepid,
IMG_NAME => $imagename,
NODE_ID => $node_id,
})));
die "tbadb::cmd_loadimage: Failed to receive response for 'loadimage'\n"
......@@ -282,6 +288,18 @@ sub cmd_forward($@) {
if ($tport !~ /^(\d+)$/ || $1 < 1 || $1 > 65535);
$tport = $1;
# Make sure user has access to requested node
my $node = Node->Lookup($node_id);
die "tbadb::cmd_forward: Invalid node name $node_id!\n"
if (!defined($node));
die("tbadb::cmd_forward: You do not have permission to reboot $node\n")
if (!$node->AccessCheck($this_user, TB_NODEACCESS_REBOOT));
# Grab the RPC pipe.
my ($rpcin, $rpcout) = GetRPCPipeHandles($node);
die "tbadb::cmd_reboot: Failed to get valid SSH pipe filehandles!\n"
if (!$rpcin || !$rpcout);
# Request adb port forwarding on device's control host.
die "tbadb::cmd_forward: Failed to send 'forward' RPC!\n"
if (!SendRPCData($rpcout,
......@@ -370,14 +388,17 @@ sub GetRPCPipeHandles($) {
if (!$conserver);
if (!exists($SSHPIPES{$conserver})) {
$SSHPIPES{$conserver} =
TBADB::SSHPipe($conserver, $TBADB_PROXYCMD);
TBADB::SSHPipe->New($conserver, $TBADB_PROXYCMD);
}
my $sshpipe = $SSHPIPES{$conserver};
# Open the SSH Pipe if necessary.
if (!$sshpipe->isopen()) {
my $pdu;
my $SAVEUID = $UID;
$EUID = $UID = 0; # Flip to root to run!
($rpcin, $rpcout) = $sshpipe->GetPipe();
$EUID = $UID = $SAVEUID; # Flip back.
my $pdu;
my $res = RecvRPCData($rpcin, \$pdu, $TBADB_HELLO_TMO);
if ($res == -1) {
die "tbadb: Timeout while opening SSH Pipe!\n";
......@@ -414,7 +435,10 @@ sub cleanexit($) {
if (@tokill) {
warn "tbadb: Killing SSH pipe processes: @tokill\n";
my $SAVEUID = $UID;
$EUID = $UID = 0; # Flip to root to kill!
kill("TERM", @tokill);
$EUID = $UID = $SAVEUID; # Flip back.
my $stime = time();
while (keys %SSHPIPES) {
......
......@@ -25,13 +25,12 @@
use strict;
use English;
use libjsonrpc;
use tbadb_rpc;
# Drag in Emulab clientside path stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
use libjsonrpc;
use tbadb_rpc;
# Function prototypes
sub send_error($$$);
......@@ -70,6 +69,7 @@ my $ADB = "/usr/bin/adb";
my $FASTBOOT = "/usr/bin/fastboot";
my $TOUCH = "/usr/bin/touch";
my $IPTABLES = "/sbin/iptables";
my $HOST = "/usr/bin/host";
my $TBADB_IMAGE_CACHE_DIR = "/z/adb_img_cache";
my $WM_HIGH = 50 * 1000 * 1000 * 1000; # 50 GB
my $WM_LOW = 40 * 1000 * 1000 * 1000; # 40 GB
......@@ -82,7 +82,7 @@ $| = 1;
#
# Only allow root to run the script.
#
die("tbadb_proxy: May only be run as root!\n");
die("tbadb_proxy: May only be run as root!\n")
if ($UID != 0);
# Read in the node_id -> serial number map.
......@@ -237,7 +237,7 @@ sub rpc_loadimage($) {
my $node_id = $data->{ARGS}->{NODE_ID};
my $imgname = $data->{ARGS}->{IMG_NAME};
my $proj = $data->{ARGS}->{IMG_PROJ};
if (!$imgname || !$node || !$proj) {
if (!$imgname || !$node_id || !$proj) {
warn "tbadb_proxy::rpc_loadimage: missing RPC arguments!\n";
send_error($data->{FID}, RPCERR_BADARGS, "Missing arguments.");
exit 1;
......@@ -268,7 +268,7 @@ sub rpc_loadimage($) {
my $userdata_image = "$sysdir/pnet-userdata.img";
my $cache_image = "$sysdir/pnet-cache.img";
if (!-r $recovery_image || !-r $boot_image ||
!-r $userdata_image || !-r $cache_image || ) {
!-r $userdata_image || !-r $cache_image ) {
warn "tbadb_proxy::rpc_loadimage: one or more core images missing!\n";
send_error($data->{FID}, RPCERR_INTERNAL, "Missing core images.");
exit 1;
......@@ -373,8 +373,8 @@ sub rpc_forward($) {
send_error($data->{FID}, RPCERR_BADARGS, "One or more arguments missing.");
exit 1;
}
if ($dport < 1 || $dport > 65535) {
warn "tbadb_proxy::rpc_forwardadb: requested port is out of range: $dport!\n";
if ($tport < 1 || $tport > 65535) {
warn "tbadb_proxy::rpc_forwardadb: requested port is out of range: $tport!\n";
send_error($data->{FID}, RPCERR_BADARGS, "Requested port is out of range.");
exit 1;
}
......@@ -543,7 +543,7 @@ sub enter_fastboot($) {
sleep 5;
$state = `$FASTBOOT devices 2>&1`;
return 1 if $state =~ /$serial\s+fastboot/;
if ($time() - $stime > $FASTBOOT_TMO) {
if (time() - $stime > $FASTBOOT_TMO) {
warn "tbadb_proxy::enter_fastboot: timed out waiting for $node_id\n";
return 0;
}
......
......@@ -28,7 +28,11 @@ use Exporter;
@ISA = "Exporter";
@EXPORT =
qw ( RPCERR_BADARGS RPCERR_BADFUNC RPCERR_NOTIMPL RPCERR_INTERNAL );
qw ( RPCERR_BADARGS RPCERR_BADFUNC RPCERR_NOTIMPL
RPCERR_NODE_ERR RPCERR_INTERNAL
IMG_RECOVERY IMG_BOOT IMG_USERDATA IMG_CACHE
IMG_SYSTEM );
use strict;
use English;
......
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