# Shell scripts with SUID



## tmw (Oct 26, 2009)

Hello,
I have a question, when i set suid bit to an executable file everything looks normal (the program will work with owner of the files privilage). When I set suid bit on a shell script it has the normal privilage (not owner of the file privilage) when i run the script. Can anyone explain me why shell scripts act different from executable files with suid set on? Below are the code of shell script and program written in C.

Shell scripts

```
cat /etc/master.passwd
```

Program written in C

```
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
int status;

if( (status = system(argv[1])) < 0)
        exit(0);

return 0;
}
```

I now that they are not secure i just want to now the different betwen them when suid is set.

Best regards


----------



## SirDice (Oct 26, 2009)

Running a suid shell script opens up a couple of huge security holes and is therefor disabled.

See http://www.freebsd.org/doc/en/books/handbook/permissions.html Chapter 3.3.3 and the note it contains.


----------



## tmw (Oct 26, 2009)

Hello,
Thanks for the answer ! 

Best regards


----------

