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.