Thought for the day

Aug 14, 2009 23:59

You can run a zero length file that has its execute bits set and you'll never see an error. It won't DO anything, but it'll run.

bofh

Leave a comment

Comments 6

pvaneynd August 15 2009, 08:06:39 UTC
And it will return 'success' as exit-code!

5/pvaneynd@sharrow:/tmp :) $ ls -l foo2
-rwxr-xr-x 1 pvaneynd pvaneynd 1 2009-08-15 10:05 foo2
5/pvaneynd@sharrow:/tmp :) $ ./foo2 && echo ok
ok
5/pvaneynd@sharrow:/tmp :) $

Reply

gothgeekgirl August 15 2009, 08:25:24 UTC
True.

Reply

sweh August 15 2009, 11:31:48 UTC
Exactly so; "true" is the result of running such a file.

On Solaris, if you "truss" this then you'll see that this really runs under /sbin/sh and so this is the equivalent of /sbin/sh -c "" (unless that's an artifact of "truss"...)

On Linux, "strace" refuses with ENOEXEC, but under normal operation it still runs with a zero exit code.

Reply

baljemmett August 15 2009, 22:17:37 UTC
Hmm -- leaning towards an artifact of truss there -- I'd be worried if the kernel made that decision, for some reason. What happens if you truss a noddy executable that just execs the empty file?

Reply


Leave a comment

Up