Re: High UID support for Linux

Jason Riedy (ejr@cise.ufl.edu)
Thu, 03 Dec 1998 01:49:20 -0500


And Jim Bourne writes:
-
- Without a controlling tty, it of course wouldn't work, and in an su
- situation it would return the real user not the user su'd to... But this
- might be a better method then using environment vars.

Anything's better than environment variables (that's a loaded statement,
but..). The USER environment variable does _not_ identify the user.
There is also no special connection between USER and HOME.

>From one shell (Solaris, but it doesn't matter for this discussion):
> lotus:1% echo $USER
> ejr
> lotus:2% export USER=blah
> lotus:3% echo $USER
> blah
> lotus:4% xterm&
> [1] 1850

>From that xterm:
> lotus:1% echo $USER
> blah
> lotus:2% whoami
> ejr
> lotus:3% echo $HOME
> /home/cs/ejr

Once, I actually tried changing HOME to adapt for different architectures
(export HOME=${HOME}/home-${archos}), but it broke things in non-uniform
ways.

I've always thought that whatever method the BSDish whoami command uses
on a particular system was the canonical way to get the current user...
It uses geteuid on Solaris, Irix, and AIX, at least. I don't have a
Linux version on hand at the moment. The SysV ``who am i'' command does
exactly what you describe, or at least all that I've seen. Try ``ssh
localhost csh -i'' and then ``who am i'' to test it.

I tend to use HOME for the home directory of the current user; it's the
lazy solution. Most things I've written find _other_ users' home
directories, however, and that variable is meaningless there...

Jason

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/