[comp.std.unix] "#!" magic number

Chuck.Phillips@FtCollins.NCR.COM (Chuck.Phillips) (02/04/91)

Submitted-by: Chuck.Phillips@FtCollins.NCR.COM (Chuck.Phillips)

>>>>> On 22 Jan 91 21:28:49 GMT, guy@auspex.uucp (Guy Harris) said:

Guy> I don't strongly care where it's done (although I *do* prefer having
Guy> "execl()" AND "execv()" capable of running scripts, even if it's done by
Guy> having them be wrappers around kernel traps with the wrappers checking
Guy> for the "#!" line if they get ENOEXEC), but it *would* be nice if the
Guy> system didn't inappropriately try to run files that happened to have
Guy> execute permissions as scripts if, in fact, they aren't scripts. 

Essentially, "#!" becomes a magic number.  I would also prefer this be in
the kernal.

Invitation for discussion: If the path after the "#!" doesn't begin with
"/", "./" or "../", should PATH be searched for the execuatble?  If so, how
best could this be implemented?

The reason I bring this up is in SVr4 (OSF/1?), there have been changes in
the directory hierarchy and commands are not necessarily where they've
historically been.  Of course, all scripts that are part of the OS can (and
should!) contain absolute path names.  It would be nice for application
developers to be able to write hierarchy independent scripts.  Even nicer
would be for applications developers to be able to write their own
interpreters without caring where the user installs the interpreter (as
long as the interpreter's directory is in PATH).
--
Chuck Phillips  MS440
NCR Microelectronics 			chuck.phillips%ftcollins.ncr.com
2001 Danfield Ct.
Ft. Collins, CO.  80525   		...uunet!ncrlnk!ncr-mpd!bach!chuckp

Volume-Number: Volume 22, Number 107

Chuck.Phillips@FtCollins.NCR.COM (Chuck.Phillips) (02/12/91)

Submitted-by: Chuck.Phillips@FtCollins.NCR.COM (Chuck.Phillips)

>>>>> On 4 Feb 91 11:50:07 GMT, Chuck.Phillips@FtCollins.NCR.COM (Chuck.Phillips) said:
Chuck> Invitation for discussion: If the path after the "#!" doesn't begin
Chuck> with "/", "./" or "../", should PATH be searched for the execuatble?
Chuck> If so, how best could this be implemented?

Based on feedback from Ernest Hua (thanks!), I'd like to ammend this.  SUID
scripts under no circumstances should allow PATH searching for '#!'
arguments -- even if not SUID root.

Continuing the earlier thread, not only are directory structures
non-portable, but some interpreters (e.g. pearl, gawk, bash) have no POSIX
or otherwise defined directory location.  '#!' path searching also allows
vendors to write their own interpreters for scripts without forcing a
particular directory structure on admin.  Further, it allows different
versions of the same interpreter to be used simultaneously based on each
user's path.
--
Chuck Phillips  MS440
NCR Microelectronics 			chuck.phillips%ftcollins.ncr.com
2001 Danfield Ct.
Ft. Collins, CO.  80525   		...uunet!ncrlnk!ncr-mpd!bach!chuckp

Volume-Number: Volume 22, Number 123