[sudo-workers] sudo ignores child return code
Todd C. Miller
Todd.Miller at courtesan.com
Tue Aug 30 11:08:19 MDT 2016
On Tue, 30 Aug 2016 11:20:23 -0400, Radovan Sroka wrote:
> What shell are you using?
I've tried bash, dash, ksh and zsh on a fedora 23 VM. They all
behave the same for me.
> When I run this command via bash/sh result will be:
> $ sh|bash ./test.sh
> $ echo $?
> But in this use case bash|sh will not exec our script just interpret it.
> "bash -c ./test.sh" exec it and will fail.
> So I still think that if sudo exec this script it should fail too.
Sorry, I don't agree. This would break scripts that don't include
the interpreter line. Lots of people rely on this. Furthermore,
the sudo behavior is consistent with how the exec(3) family of
functions behave. From the exec(3) manual on fedora 23:
If the header of a file isn't recognized (the attempted
execve(2) failed with the error ENOEXEC), these functions will
execute the shell (/bin/sh) with the path of the file as its
first argument. (If this attempt fails, no further searching
More information about the sudo-workers