I tried googling this and all i'm getting is that the setuid attribute shall set the user to the owner. But which UIDs should I actually set? Just the effective UID? Or also the real UID and saved-set-UID?
I'm guessing that it should be just effective, because otherwise programs like "sudo" wouldn't be able to tell who started them. But then again, the real UID must be set for things like "kill" to work.
So how am I supposed to do this? Also please give me a source if possible, because I actually cannot find what POSIX says about this (looking at some sudo code, it seems to assume that the real UID is of the user who actually started the process).
Which UIDs should setuid attribute set?
Re: Which UIDs should setuid attribute set?
It sets all 3. seteuid() was designed to just set the effective uid. See the notes here for more info on how to handle the case of kill().
Regards,
John.
Regards,
John.
Re: Which UIDs should setuid attribute set?
I know that setuid() function sets all 3, i was asking about the setuid attribute (mask 04000). Thats the one that executables like sudo need to get root permissions.
Re: Which UIDs should setuid attribute set?
Apologies, I should read more carefully. The same reference holds however (see the discussion of System V in the rationale) however it acts like the 2nd case, i.e. being called by an unprivileged user and only sets the effective uid (also see here).
kill requires that the real or effective uid of the sending process is equal to the real or saved setuid of the receiving process (or that kill is run as root), thus just setting the effective uid should also work.
Regards,
John.
kill requires that the real or effective uid of the sending process is equal to the real or saved setuid of the receiving process (or that kill is run as root), thus just setting the effective uid should also work.
Regards,
John.