One way to fix $LOGNAME after `su - foo`.
Tony Olekshy
tony at oha.UUCP
Sat Jul 21 07:56:25 AEST 1990
The recent discussion on the difference between uid and $LOGNAME was prompted
by (or at least included discussion of) the fact that on SCO Xenix (and Unix,
I believe) the value of $LOGNAME after `su - foo` is the same as before the
su, when in fact it should be "foo".
I have solved this problem under SCO Xenix by adding the following incantation
to the /etc/cshrc file:
setenv LOGNAME "`id | sed 's/[^(]*(\([^(]*\)).*/\1/'`"
Please note that, under SCO Xenix, /etc/cshrc is only sourced at login time
*and* by the `su - foo` command. Under other models of Unix or other shells,
you may need to find some other condition that is only true at login and
`su - foo` times, and use that to trigger LOGNAME resetting. You might try
$0 or `env`.
As a result, by the way, the `setenv MAIL "/usr/spool/mail/$LOGNAME"` that
is embedded in my /etc/cshrc now works that way I thought it should: if I
`su foo` I am still notified of changes to my mailbox, and if I `su - foo`
I am notified of changes to foo's mailbox.
--
Yours etc., Tony Olekshy. Internet: tony%oha at CS.UAlberta.CA
BITNET: tony%oha.uucp at UALTAMTS.BITNET
uucp: alberta!oha!tony
More information about the Comp.unix.questions
mailing list