LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   A question on SUID (Set User ID) (https://www.linuxquestions.org/questions/linux-newbie-8/a-question-on-suid-set-user-id-774753/)

saagar 12-10-2009 10:15 AM

A question on SUID (Set User ID)
 
Friends,

Suppose root user is setting a file script.sh with SUID permission and allowing others to have execute permissions as follows:

Code:

#ls -l /script.sh
-rwsr--r-x root root ---- script.sh

And then he is writing a script as follows:
Code:

#vi /script.sh
        #!/bin/bash
        touch /root/newfile.txt
        :wq!

Now, a normal user is logging in and executes that file:

Code:

#su - normaluser
[normaluser@linux1~]$cd /
[normaluser@linux1~]$./script.sh
touch: cannot touch `/root/newfile.txt': Permission denied

Actually, after setting SUID to a script, and if a normaluser executes that file, he should be able to write a file inside /root directory, since the effective UID is that of root user's. why is it not happening in this case? Please help.

cantab 12-10-2009 10:22 AM

I've a feeling SUID doesn't work for shell scripts, only for binary executables.

jschiwal 12-10-2009 10:29 AM

Cantab is correct. Suid isn't supported in Linux for scripts.

saagar 12-10-2009 12:51 PM

cantab and jschiwal, thanks for your respnoses.


All times are GMT -5. The time now is 03:14 PM.