[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/45430: ash uses argv as $0 for scripts without #!
The following reply was made to PR bin/45430; it has been noted by GNATS.
From: David Laight <david%l8s.co.uk@localhost>
Subject: Re: bin/45430: ash uses argv as $0 for scripts without #!
Date: Wed, 5 Oct 2011 19:47:57 +0100
On Wed, Oct 05, 2011 at 01:40:01PM +0000, spbnick%gmail.com@localhost wrote:
> >Number: 45430
> >Category: bin
> >Synopsis: ash uses argv as $0 for scripts without #!
> ash shell uses argv as $0 in scripts lacking shebang line, located
> during $PATH lookup, while using full file path for the scripts with
> shebang line.
This isn't a bug!
For a normal program binary argv is whatever the user typed, this
also applies to non #! scripts executed by the shell.
The execution of #! scripts is done by the kernel which has to
pass the interpreter the full pathname of the script file.
For suid #! scripts the kernel will pass the name of an open fd
(as /dev/fd/n) as argv to be absolutely sure the correct file
is opened (no symlink dances).
This has the 'odd' side effect that you normally need 'rx' permissions
to run a #! script - unless it is suid and you aren't the owner, in
which case 'x' is enough.
David Laight: david%l8s.co.uk@localhost
Main Index |
Thread Index |