SUID permission on Bash script

Polytropon freebsd at edvax.de
Sat Aug 29 02:27:06 UTC 2009


On Fri, 28 Aug 2009 20:10:59 -0600, Tim Judd <tajudd at gmail.com> wrote:
> Dunno, but this dawns on me..
> 
> what defines a script?  I've always defined a script that starts with
> a #! shebang.
> 
> So the script can be SUID, but the interpreter/shell isn't.  Is that
> why it doesn't work?

What is the difference of the script and the interpreter? The
script is read and executed by the shell, the script itself isn't
runnable at all.

The itnerpreter specified by #! is executed and then starts to
process the script. Is the interpreter running at SUID? Are the
commands (child processes) that it executes (fork) running at
SUID?

But let us continue this consideration:

If the shell process would be replaced by the command that is
called, would it make a difference? Compare

	#!/bin/sh		<- this starts /bin/sh
	shutdown -p now		<- /bin/sh starts child shutdown

to

	#!/bin/sh		<- this starts /bin/sh
	exec shutdown -p now	<- /bin/sh replaced by shutdown

Hmmm... do I see this correctly?



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list