lkml.org 
[lkml]   [1998]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: High UID support for Linux
Date
From
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/

\
 
 \ /
  Last update: 2005-03-22 13:45    [W:1.028 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site