[sudo-workers] sudo ignores child return code

Radovan Sroka rsroka at redhat.com
Wed Aug 31 05:34:50 MDT 2016


> $ sudo ./test.sh
> sudo: unable to execute ./test.sh: No such file or directory

> this is because execve(2) returns ENOENT for a missing interpreter,
> not ENOEXEC.

Yes, but sudo also returns 0.

---------------------------------------------------------

Radovan Sroka
Security Technologies | Red hat, Inc.

----- Original Message -----
From: "Todd C. Miller" <Todd.Miller at courtesan.com>
To: "Radovan Sroka" <rsroka at redhat.com>
Cc: sudo-workers at sudo.ws
Sent: Wednesday, August 31, 2016 1:26:53 PM
Subject: Re: [sudo-workers] sudo ignores child return code

On Wed, 31 Aug 2016 03:32:47 -0400, Radovan Sroka wrote:

> There is a typo in script
> 
> $ cat test.sh
> #/bin/asdsadsa --> should be #!/bin/asdsadsa
> #useless script
> 
> I'm not talking about unrecognized interpreter line, I'm talking about use ca
> se where
> interpreter doesn't exist.
> 
> Sorry for misunderstanding.
> 
> So if interpreter doesn't exist "bash -c ./test.sh" this will fail.
> 
> What do you think about that?
> Should sudo fail as well?

Sudo does fail in this case:

$ sudo ./test.sh
sudo: unable to execute ./test.sh: No such file or directory

this is because execve(2) returns ENOENT for a missing interpreter,
not ENOEXEC.

 - todd


More information about the sudo-workers mailing list