Results 1 to 7 of 7
If SUID is set: the application always runs as the owner of the application, no matter who runs the application.
I tried a simple script, seems it's not working as ...
- 08-19-2011 #1Just Joined!
- Join Date
- Aug 2011
- Posts
- 4
SUID question
If SUID is set: the application always runs as the owner of the application, no matter who runs the application.
I tried a simple script, seems it's not working as I expected. Could someone tell me if I did wrong?
I created a script file test_suid.sh, with just one command inside:
touch test
And changed the owner of the file test_suid.sh to be "wwwrun".
And set SUID bit on. (chmod u+s test_suid.sh)
But when I ran it, the "test" file created still belong to my username, but not "wwwrun".
Can someone explain why? Is there other "trick"? or my understanding is not right?
Thanks
- 08-20-2011 #2
Well, there's your UID and your EUID. The EUID is your "effective UID" and may be different from your real UID. I'm not sure but I think setting suid changes only the EUID. It's like using su as against su -. Try putting the commands
into your script and see what happens.Code:echo $UID echo $EUID
"I'm just a little old lady; don't try to dazzle me with jargon!"
- 08-22-2011 #3Just Joined!
- Join Date
- Aug 2011
- Posts
- 4
- 08-23-2011 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,845
I'm pretty sure that the kernel as of (a long time ago...) does not allow scripts to run with the setuid bit. You'll have to convert your script to a C prog and setuid that guy - at least that was my solution when I ran into this.
- 08-23-2011 #5Just Joined!
- Join Date
- Aug 2011
- Posts
- 4
- 08-24-2011 #6
Ah yes! I'd forgetton that wrinkle. The reason SUID/SGID is not supported for scripts is to prevent "script kiddies" from writing malicious software that could run with root permissions.
Writing C programs is much more difficult than writing bash scripts, so less likely to be abused. It's for the same reason that the exec bit is not honoured for files on floppy disks."I'm just a little old lady; don't try to dazzle me with jargon!"
- 08-24-2011 #7Just Joined!
- Join Date
- Aug 2011
- Posts
- 4


Reply With Quote
