Commit d776153b authored by Leigh B Stoller's avatar Leigh B Stoller

Rework the wrapper fork/wait that tries to catch immediate errors. The

shellinaboxd daemon and/or the wrapper is doing something strange that
makes apache unhappy.
parent b27aad2f
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2008-2015 University of Utah and the Flux Group. # Copyright (c) 2008-2016 University of Utah and the Flux Group.
# #
# {{{GENIPUBLIC-LICENSE # {{{GENIPUBLIC-LICENSE
# #
...@@ -133,6 +133,7 @@ open(KEY, "/usr/testbed/etc/sshauth.key") or ...@@ -133,6 +133,7 @@ open(KEY, "/usr/testbed/etc/sshauth.key") or
fatal("Could not open sshauth.key"); fatal("Could not open sshauth.key");
my $sshauthkey = <KEY>; my $sshauthkey = <KEY>;
chomp($sshauthkey); chomp($sshauthkey);
close(KEY);
# #
# Dig out the authentication object. It is a json object. # Dig out the authentication object. It is a json object.
...@@ -273,45 +274,25 @@ if ($debug) { ...@@ -273,45 +274,25 @@ if ($debug) {
# The point of this is to capture the initial STDERR of shellinaboxd # The point of this is to capture the initial STDERR of shellinaboxd
# and send it out to syslog or file. # and send it out to syslog or file.
# #
pipe(READER, WRITER); open(PIPE,"$cmd 2>&1 |") or
WRITER->autoflush(1); fatal("Could not start '$cmd'");
my $pid = fork(); #
if ($pid) { # We better see these two lines, or something went wrong.
close WRITER; #
close STDOUT; while (<PIPE>) {
close STDIN; if ($_ =~ /^(.*:\d+)\r$/) {
# # This line means good startup, send the session:port to the browser.
# The read seems to get stuck, leaving a defunct child and this print "Content-type: text/plain\n\n";
# script hanging out. Not sure why, so cancel the read after a print $1 . "\n";
# a bit and go on. close(PIPE);
# exit(0);
local $SIG{ALRM} = sub { }
info("Timed out waiting for $pid to say something"); else {
waitpid($pid, 0);
info("After waitpid: $?");
unlink($tempfile)
if (defined($tempfile));
exit($? >> 0);
};
alarm 30;
while (<READER>) {
info($_); info($_);
} }
alarm 0;
info("Before waitpid for $pid");
waitpid($pid, 0);
info("After waitpid: $?");
unlink($tempfile)
if (defined($tempfile));
exit($? >> 0);
}
else {
# Need the parent to run first so it can close STDOUT. Better
# ways to do this of course.
select(undef, undef, undef, 0.2);
close READER;
close STDERR;
open(STDERR, ">&WRITER") || fatal("can't dup to stderr");
close WRITER;
} }
exec($cmd); close(PIPE)
or fatal(($! ?
"Error closing shellinaboxd pipe: $!" :
"Exit status $? from shellinaboxd"));
exit($? >> 0);
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