Which UIDs should setuid attribute set?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Which UIDs should setuid attribute set?

Post by mariuszp »

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).
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: Which UIDs should setuid attribute set?

Post by jnc100 »

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.
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: Which UIDs should setuid attribute set?

Post by mariuszp »

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.
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: Which UIDs should setuid attribute set?

Post by jnc100 »

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.
Post Reply