I realised I've missed a subtlety with user IDs (UID) and effective user IDs (EUID) and need some clarification. N.B. I'm working on macOS, although I suspect everything makes sense in a Linux world as well.
I've created a binary and set the setuid bit on it (with chmod +s
). If I run this binary and log the values from getuid()
and geteuid()
then I see UID=501 (my regular user) and EUID=0 (root). I can futher call setuid(0)
to set UID=0.
My question is, when would I need to do that? i.e. What can my process do with (UID, EUID)=(0,0) that it can't do with (UID, EUID)=(501,0)?
nosuid
... – Mark Setchell