[wplug] SUID - I just don't get it

Robert E. Coutch robert.coutch at verizon.net
Sat Apr 24 15:00:19 EDT 2004


I must not be grasping the concept.

I'm under the impression that if root is the owner of a file and the SUID bit 
is set, the file will execute as if root was running the program no matter 
what user executed the program.

This doesn't seem to be the case.


I wrote a script and set file set ownership to root, then SUID.
I run the script as a user and I see that the script executes with user's ID 
and permissions.

So I figure maybe it only works for binary files.

I write a little C program (and a C++ just to try that out) and do the same as 
before.  Program runs with user's ID and permissions.

What am I not understanding.

FYI - The mounted partition has no EXPLICIT settings to restrict SUID (unless 
it's implied).

Here's what I did:
(as root)

chown root.root a.out
chmod u+s a.out

ls -l a.out

-rwSr--r--    1 root     root     a.out
(Yes, I removed the size and timestamp)

What's the difference when I use chmod u+xs and then see:
-rwsr--r--    1 root     root     a.out


Can you clear my head on this?


Thanks,

Bob



More information about the wplug mailing list