Re: permission denied on exec of unexistent file?

From: Oleg Drokin (green@ccssu.ccssu.crimea.ua)
Date: Sun Mar 26 2000 - 00:48:41 EST


Hello!

Alessandro Suardi wrote:

> > I just found something that looks somewhat weird:
> > mordor:~$ /bin/nonexistent_binary
> > bash: ./nonexistent_binary: Permission denied
> > mordor:~$ nonexistent_binary
> > bash: nonexistent_binary: command not found
> >
> > Shouldn't first attempt also say "command not found"?
> > BASH_VERSION='2.03.0(1)-release'
> > I'm running 2.3.99-pre3
> Not a kernel problem (TM).
Not likely. execve(2) returns permission denied.
But it should return ENOENT (from man execve(2):)
       ENOENT The file filename or a script or ELF interpreter
               does not exist.

See:
mordor:~$ strace -e trace=stat bash -c '/bin/nonexistent_binary'
stat("/home/green", {...}) = 0
...
stat("/bin/nonexistent_binary", 0xbffff77c) = -1 ENOENT (No such file or directory)
BUT!
mordor:~$ strace -e trace=execve bash -c '/bin/nonexistent_binary'
execve("/usr/bin/bash", ["bash", "-c", "/bin/nonexistent_binary"], [/* 29 vars */]) = 0
execve("/bin/nonexistent_binary", ["/bin/nonexistent_binary"], [/* 27 vars */])
= -1 EACCES (Permission denied)
bash: /bin/nonexistent_binary: Permission denied

Bye,
    Oleg

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:16 EST