[comp.unix.questions] who am i?

s887212@minyos.xx.rmit.oz.au (Stephen Riehm [Romulis]) (11/27/90)

I am writing a program that needs to know who is running it. at the moment
I am using getuid() to index into the /etc/passwd file for the details
needed (like name etc). However I have noticed that it doesn't always
return the right response after the process table (I assume) gets a bit
messed up. (Xterms do wonderful things to the process table dont they?! :)

Is there a GUARANTEED way of getting the information about the user?
I dont want to rely on environment variables as they can easily be forged
or not set by the user.

I am using a multimax with UMAX (SysV).

any hints?

david@bacchus.esa.oz.au (David Burren) (11/28/90)

In <6358@minyos.xx.rmit.oz.au> s887212@minyos.xx.rmit.oz.au (Stephen Riehm [Romulis]) writes:

>I am writing a program that needs to know who is running it. at the moment
>I am using getuid() to index into the /etc/passwd file for the details
>needed (like name etc). However I have noticed that it doesn't always
>return the right response after the process table (I assume) gets a bit
>messed up. (Xterms do wonderful things to the process table dont they?! :)

>Is there a GUARANTEED way of getting the information about the user?
>I dont want to rely on environment variables as they can easily be forged
>or not set by the user.

If getuid() does not return the correct value then surely your Unix is dead,
broken, ratshit, ....... _DEAD_?

Are you sure you're not losing it somewhere after the getuid()?
You're not doing a setuid(geteuid()) somewhere from within a suid program?
_____________________________________________________________________________
David Burren [Athos]                          Email: david@bacchus.esa.oz.au
Software Development Engineer                 Phone: +61 3 819 4554
Expert Solutions Australia, Hawthorn, VIC