my $killuser = $ENV{GRUNTMASTER_KILL_USER};
my @sudo;
-@sudo = (shellwords ($ENV{GRUNTMASTER_SUDO}), '--') if $ENV{GRUNTMASTER_SUDO};
+@sudo = (shellwords ($ENV{GRUNTMASTER_SUDO}), '--') if $ENV{GRUNTMASTER_SUDO} && $nobody;
$mlimit = 1_000_000_000 if @sudo; # sudo wants a lot of address space
my $ret = fork // die 'Cannot fork';
setrlimit RLIMIT_NPROC, $nproc, $nproc or die $! if $nobody;
POSIX::setgid $nobody ? 65534 : USER;
POSIX::setuid $nobody ? 65534 : GROUP;
- unshift @ARGV, @sudo if $nobody;
+ unshift @ARGV, @sudo;
+ say STDERR "Execing: ", join ' ', map { "'$_'" } @ARGV;
exec @ARGV;
}