[TUHS] Shell control through external commands

Ron Natalie ron at ronnatalie.com
Sun Sep 11 11:24:37 AEST 2016


Traditionally, the shell recognized shell scripts and ran them in a new
instance of the shell rather than calling exec on them.
It was a Berkeley hack to add a new exec magic number that happened to
correspond to the characters #!.    The shells typically still recognized
scripts (the #!   was syntactically a comment) and invoked them, but if they
were passed to exec (i.e., from something other than the shell that was to
interpret the), the kernel recognized the magic number and invoked what
followed as the name of an interpreter to handle the file.

Not only did this allow arbitrary interpretters (other than /bin/sh or any
shell), but it also allowed things like setuid bits to work, and scripts to
be invoked by things that didn't just feed the file name to a shell to
invoke.

-----Original Message-----
From: TUHS [mailto:tuhs-bounces at minnie.tuhs.org] On Behalf Of Dave Horsfall
Sent: Saturday, September 10, 2016 6:44 PM
To: The Eunuchs Hysterical Society
Subject: Re: [TUHS] Shell control through external commands

On Sat, 10 Sep 2016, Dario Niedermann wrote:

> I never knew that a shell script could work without a shebang line.

I believe it was used to specify an interpreter other than /bin/sh (the
default).

--
Dave Horsfall DTM (VK2KFU)  "Those who don't understand security will
suffer."




More information about the TUHS mailing list