more secure?: "#!/bin/sh -" or "#!/bin/sh"

more secure?: "#!/bin/sh -" or "#!/bin/sh"

Post by Tom Rodm » Tue, 07 Mar 2000 04:00:00



Sorry if it's in the FAQ, but which is  better for the first line
of a script?:

   #!/bin/sh -

      or

   #!/bin/sh

I thought I read somewhere that "#!/bin/sh -" was more
secure; if so why?

thanks in advance,


 
 
 

more secure?: "#!/bin/sh -" or "#!/bin/sh"

Post by Jon Hal » Wed, 08 Mar 2000 04:00:00



> Sorry if it's in the FAQ, but which is  better for the first line
> of a script?:

>    #!/bin/sh -

>       or

>    #!/bin/sh

> I thought I read somewhere that "#!/bin/sh -" was more
> secure; if so why?

> thanks in advance,



#!/bin/sh - (or #!/bin/sh -- on some implementations of UNIX) will stop
unwanted options being passed to the interpreter. This can help to make
setuid scripts more secure. See FAQ.

Cheers

Jon

 
 
 

1. ":" v. "#!/bin/sh"

What's the difference between using ":" as opposed to "#!/bin/sh"
on the first line of a shell script?  I'm running SunOS 4.1.3 and
I noticed the behavior is different with the 'dirname' command
if it is run from a Bourne shell.  Test the following scripts.
Be sure you are in a different directory from where the script
is located.

Script #1
---------
:
dirname $0

Script #2
---------
#!/bin/sh
dirname $0


2. RedHat 6.1 and @home service...

3. Why does "cd /usr/////bin" = "cd /usr/bin"?

4. Restricting access to certain URLs

5. dowhat=`expr "dowhat.sh" : "\(.*\)\.sh$"`;

6. Disk Mirroring

7. Is "sh file" equivalent to "cat file | sh"

8. Sony Clie -- does it work with linux?

9. GETSERVBYNAME()????????????????????"""""""""""""

10. sh says: test "$1" = "" when $1="-b"

11. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

12. INIT:Cannot Execute "/bin/sh"

13. kill a "/bin/sh -c foo bar"