Puzzled with user ID.


 
Thread Tools Search this Thread
Top Forums Programming Puzzled with user ID.
# 1  
Old 07-14-2003
Question Puzzled with user ID.

I hava been reading AUPE these days. I really am puzzled with the presentation of real user(group) ID, effective user(group) ID. How do they effect on the execution of process? What's the relationship between them? Appreciate your help.
# 2  
Old 07-14-2003
I doubt that I can explain it as well as Rich Stevens. But here is a brief and over-simplified description.

Let's say that you sign on as "lethefe". The login program will look up lethefe in /etc/passwd to get your uid, which we will say is 1000. So the login program sets the real, effective, and saved uid to be 1000.

This affects any processes that you run. For example you will not be able to write to /etc/passwd because you do not have permission.

So you want to change your password. To do that, you will run the passwd program. The passwd program has the setuid bit set. That causes the exec() system call to set the effective and saved uids to the owner of /usr/bin/passwd. The real uid is still 1000.

While the passwd program is running, it can write to /etc/passwd. So now you can change your password. But if you try to change, say, joeblow's password, it won't let you. The passwd program can look at your real uid and decide what you should be allowed to do.

The reason that the passwd program can write to the passwd file is that the effective uid is root.

So while you are running a suid program, your real uid is you. Your saved uid is whoever owned the program. The effective uid will start out also set to whoever owned the program. The program can switch the effective uid back and forth between the real and saved uids. This lets it decide which set of permissions it wants.
# 3  
Old 07-15-2003
Quote:
So while you are running a suid program, your real uid is you.Your saved uid is whoever owned the program
Do you mean that when the s-bit of the program is not set, the effective uid is the same as the real one(as me lethefe). however,even if the s-bit is set, my real uid would never change(always lethefe)? Isn't it ?
# 4  
Old 07-15-2003
Remember that I said that I was over-simplifying things a bit.

If you are not running a suid program all 3 uids should be the same. And ideally your real uid will never change.

But all 3 can be affected by various system calls. And each version of unix is a little different in this area.

Posix has attempted to tame this situation. The sequence of events that I described is the Posix concept of how this should work. If a version of unix doesn't support the sequence that I described, it is not posix compliant.

But, for example, BSD has a system call that will swap the real and effective uids. HP-UX actually allows you to fiddle with all three uids. Older versions of BSD did not even have a saved-uid. It's this variety that makes things confusing.
# 5  
Old 07-15-2003
Thanks for your guidence.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Serioulsy puzzled here.

Facebook had a mathematics problem which was as thus:- 6/2(1+2) = ? Answer is 9. My ancient Casio FX 730P mini computer written exactly as that gives 'error' only. Now take a look at shell versions, and a python version:- Last login: Wed Sep 14 18:04:04 on ttys000 AMIGA:barrywalker~>... (6 Replies)
Discussion started by: wisecracker
6 Replies

2. UNIX for Dummies Questions & Answers

Switching from root to normal user takes me to user's home dir

Whenever i switch from root to another user, by doing su - user, it takes me to home directory of user. This is very annoying as i want to be in same dir to run different commands as root sometimes and sometimes as normal user. How to fix this? (1 Reply)
Discussion started by: syncmaster
1 Replies

3. OS X (Apple)

Puzzled by Find

I'm new to playing with the command line on OS X and am puzzled by the response I am getting from the find command. I have a file structure similar to the following /Volumes/ ../Drobo/ ../../Pictures/ ../../../Image 1/ ../../../../Image 1.jpg ../../../../Previews/ ../../../../../Image... (2 Replies)
Discussion started by: Denrael
2 Replies

4. Shell Programming and Scripting

Puzzled with hexdump, hd and ln

How to create a symbolic link to a command with certain argument? When I man hexdump, it is said in the man page that "-C Canonical hex+ASCII display...Calling the command hd implies this option". Actually it is. hd equals to hexdump -C. And then I examined the ln command but find it is a... (5 Replies)
Discussion started by: vistastar
5 Replies

5. UNIX for Advanced & Expert Users

Determining if user is local-user in /etc/passwd or LDAP user

Besides doing some shell-script which loops through /etc/passwd, I was wondering if there was some command that would tell me, like an enhanced version of getent. The Operating system is Solaris 10 (recent-ish revision) using Sun DS for LDAP. (5 Replies)
Discussion started by: ckmehta
5 Replies

6. UNIX for Dummies Questions & Answers

Difference between : Locked User Account & Disabled User Accounts in Linux ?

Thanks AVKlinux (3 Replies)
Discussion started by: avklinux
3 Replies

7. Solaris

Puzzled over over the relationship between the partition and geometry of hard disk.

Not sure why solaris couldn't detect the geometry of a hard disk which has a working OS of winxp pro. Is it due to the different OS that the partition information is stored in different location? When I type '"format" it is shown as below, c3d1 < drive type unknown>... (5 Replies)
Discussion started by: just.srad
5 Replies

8. Solaris

puzzled with VxVM and iostat..

Hi all, One disk on my root disk group failed in Veritas Volume manager. I replaced it with new one, initialized it and placed it with removed one. it Synchronized plexes and everything is fine. this node was second standby node of Sun cluster. yesterday I had failure on active node with boot... (1 Reply)
Discussion started by: samar
1 Replies

9. Shell Programming and Scripting

How do i change to super user then revert back to ordinary user ,using shell script?

Hi all, I am trying to eject the cdrom from a livecd after certain stage... Now assuming that it is possible to eject,please consider my issue!!! The OS boots into a regular user by default...so i am unable to use the eject command to push out the drive... However if i try pfexec eject it... (3 Replies)
Discussion started by: wrapster
3 Replies

10. Programming

C++ Puzzled !!

#include <iostream.h> class A { public: void f(void) { cout << "hello world \n" ; } }; void main() { A *a; a = 0 ; a->f(); // OOPs...Am I mad? What am I going to do ? } (1 Reply)
Discussion started by: RipClaw
1 Replies
Login or Register to Ask a Question