Commit 999686cd authored by Leigh B Stoller's avatar Leigh B Stoller

If the only execute service is greater then max length (tinytext),

switch to the other path (generating a wrapper script) instead of
throwing an error back to the user. I meant to do this a few years
back, guess I forgot.
parent 07e149d8
#!/usr/bin/perl -wT
#
# Copyright (c) 2008-2016 University of Utah and the Flux Group.
# Copyright (c) 2008-2017 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
......@@ -1584,75 +1584,83 @@ sub GetTicketAuxAux($$$$$$$$$$$)
}
}
if ($startupCount == 1 && defined($startupCommand)) {
if (! TBcheck_dbslot($startupCommand, "virt_nodes","startupcmd",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR)) {
$response =
GeniResponse->Create(GENIRESPONSE_BADARGS, undef,
"Invalid startup command: " . TBFieldErrorString());
goto bad;
if ($startupCount) {
if ($startupCount == 1 && length($startupCommand) < 240) {
if (! TBcheck_dbslot($startupCommand,
"virt_nodes", "startupcmd",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR)){
$response =
GeniResponse->Create(GENIRESPONSE_BADARGS, undef,
"Invalid startup command: " .
TBFieldErrorString());
goto bad;
}
$nodeblob->{'startupcmd'} = $startupCommand;
}
$nodeblob->{'startupcmd'} = $startupCommand;
} else { # BEGIN TEMPORARY ELSE
my $count = 0;
my $startfile = $slice_experiment->UserDir() .
"/geni_startup." . $node_nickname;
$nodeblob->{'startupcmd'} = $startfile;
else {
my $count = 0;
my $startfile = $slice_experiment->UserDir() .
"/geni_startup." . $node_nickname;
$nodeblob->{'startupcmd'} = $startfile;
if (!open(STARTUP, ">$startfile")) {
$response = GeniResponse->Create(GENIRESPONSE_ERROR, undef,
if (!open(STARTUP, ">$startfile")) {
$response =
GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Error creating startfile");
goto bad;
}
print STARTUP "#!/bin/sh\n\n";
print STARTUP "# Redirect all output to a file\n";
print STARTUP "exec &> /var/tmp/startup.log\n\n";
#
# It would be nice to interleave "install" with "execute", but
# Emulab's tarfiles support arranges to copy the files locally,
# and rewrites the names. Need to hook into that support somehow,
# but for now tarfiles are all installed as a block above.
#
foreach my $service (@services) {
my $type = $service->{'type'};
if ($type eq "execute") {
my $shell = $service->{'shell'};
my $cmd = $service->{'cmd'};
my $log = "/var/tmp/startup-${count}.txt";
my $stat = "/var/tmp/startup-${count}.status";
goto bad;
}
print STARTUP "#!/bin/sh\n\n";
print STARTUP "# Redirect all output to a file\n";
print STARTUP "exec &> /var/tmp/startup.log\n\n";
#
# Support only sh and csh. Maybe perl later.
# It would be nice to interleave "install" with
# "execute", but Emulab's tarfiles support arranges to
# copy the files locally, and rewrites the names. Need to
# hook into that support somehow, but for now tarfiles are
# all installed as a block above.
#
if (! (defined($shell) &&
($shell eq "csh" || $shell eq "sh" ||
$shell eq "/bin/csh" || $shell eq "/bin/sh"))) {
$response =
GeniResponse->Create(GENIRESPONSE_BADARGS, undef,
foreach my $service (@services) {
my $type = $service->{'type'};
if ($type eq "execute") {
my $shell = $service->{'shell'};
my $cmd = $service->{'cmd'};
my $log = "/var/tmp/startup-${count}.txt";
my $stat = "/var/tmp/startup-${count}.status";
#
# Support only sh and csh. Maybe perl later.
#
if (! (defined($shell) &&
($shell eq "csh" || $shell eq "sh" ||
$shell eq "/bin/csh" ||
$shell eq "/bin/sh"))) {
$response =
GeniResponse->Create(GENIRESPONSE_BADARGS,
undef,
"Invalid shell in execute");
goto bad;
}
if (! ($shell =~ /bin/)) {
$shell = "/bin/$shell";
goto bad;
}
if (! ($shell =~ /bin/)) {
$shell = "/bin/$shell";
}
print STARTUP "echo -n 'Services execution $count at '\n";
print STARTUP "date\n\n";
print STARTUP "$shell -c \"$cmd\" >$log 2>&1\n";
print STARTUP "status=\$?\n";
print STARTUP "echo \"\$status\" > $stat\n";
print STARTUP
"echo \"Execution $count exited with status \$status\"\n";
print STARTUP "echo '----------------------------------'\n";
$count++;
}
}
print STARTUP "echo -n 'Services execution $count at '\n";
print STARTUP "date\n\n";
print STARTUP "$shell -c \"$cmd\" >$log 2>&1\n";
print STARTUP "status=\$?\n";
print STARTUP "echo \"\$status\" > $stat\n";
print STARTUP
"echo \"Execution $count exited with status \$status\"\n";
print STARTUP "echo '----------------------------------'\n";
$count++;
print STARTUP "exit 0\n";
close(STARTUP);
chmod(0755, $startfile);
}
}
print STARTUP "exit 0\n";
close(STARTUP);
chmod(0755, $startfile);
} # END TEMPORARY ELSE
}
my $elabsettings = GeniXML::GetElabInElabSettings($ref);
......
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