Operating System - HP-UX
1850277 Members
3229 Online
104053 Solutions
New Discussion

ps does not show effective uid

 
Rohan_7
Advisor

ps does not show effective uid

Hi,

I am seeing a problem with 'ps' utility when a program changes its effective UID and GID.
It does not show changed effective UID, instead it shows the original (probably real) UID.
Though, the UID change is successful and any file created by the program has owenership of effective UID.

Any explainations to the problem?

I have HP-UX 11.11i.
Attached a sample test program which changes the UID to 'rohan' and waits for input before exit. Following is 'ps' output when the program is waiting,
bash-2.05b# ps -aef|grep test_sw
root 13895 2904 1 14:49:32 pts/td 0:00 grep test_sw
root 13876 14520 0 14:48:45 pts/tg 0:00 ./test_sw_uid


Thanks in advance
Rohan
3 REPLIES 3
G. Vrijhoeven
Honored Contributor

Re: ps does not show effective uid

Hi Rohan,

You could use -u or -U :

-u uidlist Select processes whose effective user ID numbers
or login names are given in uidlist.

-U uidlist (XPG4 Only.) Select processes whose real user ID
numbers or login names are given in uidlist.

HTH,

Gideon
Rohan_7
Advisor

Re: ps does not show effective uid

hi,

Thanks for quick response.
Actually, I tried that. But it does not show required process if you specify changed effective UID to -u.
bash-2.05b# ps -u rohan |grep test_sw

No output!

I am running the program as root, so
bash-2.05b# ps -u root |grep test_sw
13876 pts/tg 0:00 test_sw_uid


-Rohan
Dietmar Konermann
Honored Contributor

Re: ps does not show effective uid

Rohan,

you use the -f option of ps... man ps:

-f
Show columns user, pid, ppid, cpu, stime, tty, time, and args, in that order.

user
The login name of the effective process owner.

EXTERNAL INFLUENCES
Environment Variables
UNIX95 specifies to use the XPG4 behavior for this command. The changes for XPG4 include support for the entire option set specified above and include the following behavioral changes:

+ The uid or user column displayed by -f or -l will display effective user rather than real user.

So, what you are seeing seems to be the expected behaviour. What happens if you set UNIX95?

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)