How do real and effective user IDs work

setuid

When a normal user wants to make change to the passwd file, the user will by setuid be given the effective user access. User becomes root temporarily and can edit passwd.

However you can only edit your password right, and not everybody else? However your effective user access is root. So how come you're not allowed to change other passwords beside yours?

When you run a program with setuid, what does it mean actually when effective user is root, but real user id is still your name?

Best Answer

You can't change other passwords because the program won't allow you to. The program has system permissions to change any password it wants, because it is running as root, but the program has been specifically designed not to give the user any way to get it to use those permissions.

It is not quite that the user becomes root temporarily, it is that the trusted program runs with root permissions. Obviously, only programs that are specifically designed to limit users to doing only what they should be permitted to do can safely be made setuid.

Related Question