Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

4 Answers 4

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.

share|improve this answer
    
So in the case of I open a shell setting the uid to 0 (using setreuid), so that the effective uid will be root but the real uid is still me. Since I don't think the shell specifically has something built in which prevent me, does it mean I get access to the whole system then? –  starcorn Oct 30 '11 at 9:00
    
I wondering in context of the stack smashing attack technique. Where malicious hacker opens up a shell with superuser level. –  starcorn Oct 30 '11 at 9:02
    
@starcron: Yes. In fact, may attacks are demonstrated by showing how to use that attack to create a setuid root shell. –  David Schwartz Oct 30 '11 at 23:08
add comment

You are only allowed to change only your password inspite of having effective user id of root because at the time of password change the real user id is checked not the effective user id . You can only change the effective user id and not the real user id.
Only root user can change the real user id to run the program as non-privileged user. The real user id can not be changed as it is set at the time of session start.
That's why only your password can be changed as the real user id is not changed(as it is still yours not root's).

share|improve this answer
add comment

Please refer the given below to know more about real and effective uid.

http://stackoverflow.com/questions/8499296/realuid-saved-uid-effective-uid-whats-going-on

share|improve this answer
2  
It is better to include the relevant text here and use the link for backup/detailed information. –  Anthon Nov 6 '13 at 8:16
add comment

An early hack in Unix was to make a symbolic link to a setuid shell script and call the link -i. This results in the script being called as sh -i which instead of executing the script called -i as intended launches an interactive shell, which then gives full powers. Effective user ID can be used to modify the passwd file for any user or root itself. The best way to guard against this is to use SELinux to prevent trust scripts or programs from modifying outside the area SELinux allows them to run.

Another technique is to have an immutable bit on important files which one set cannot be modified even by the root user (apart from in single-user mode)

As root you can invite users to log on to your system without a password and appear as any user but normal privileged processes try very hard to prevent this from happening.

If you use network filing systems of some sort the root user will be treated as nobody in that file space instead of root which allows untrusted computers to join a trusted network such as a university campus.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.