Commit cbc57916 authored by Leigh Stoller's avatar Leigh Stoller

Add sanity check to execute services, was not checking that the execute

service actually had a command in it.
parent df1cf588
......@@ -1934,7 +1934,7 @@ sub GetTicketAuxAux($)
$nodeblob->{'startupcmd'} = $startupcmd;
}
}
elsif ((my @services = GeniXML::GetServices($ref)) &&
elsif ((my @services = GeniXML::GetExecuteServices($ref)) &&
(!defined($osinfo) || $osinfo->isImageAlias() ||
$osinfo->op_mode() ne
EmulabConstants::TBDB_NODEOPMODE_ALWAYSUP())) {
......@@ -1945,6 +1945,24 @@ sub GetTicketAuxAux($)
my $startfile = "$userdir/$startname";
my $tarfile = "$userdir/startup_tarfile." . $node_nickname;
# Sanity check
foreach my $service (@services) {
my $type = $service->{'type'};
if ($type eq "execute") {
my $shell = $service->{'shell'};
my $cmd = $service->{'cmd'};
if (! (defined($shell) && defined($cmd))) {
$response =
GeniResponse->Create(GENIRESPONSE_BADARGS,
undef,
"Invalid execute service");
goto bad;
}
}
}
if (!open(STARTUP, ">$startfile")) {
$response =
GeniResponse->Create(GENIRESPONSE_ERROR, undef,
......
#!/usr/bin/perl -w
#
# Copyright (c) 2010-2018 University of Utah and the Flux Group.
# Copyright (c) 2010-2019 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
......@@ -721,6 +721,20 @@ sub GetServices($)
}
return @result;
}
sub GetExecuteServices($)
{
my ($node) = @_;
my @result = ();
my @services = GetServices($node);
return ()
if (!@services);
foreach my $service (@services) {
push(@result, $service)
if ($service->{'type'} eq "execute");
}
return @result;
}
#
# Program agents are also in the services element, but they are in the
......
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