Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uw-beaver!ubc-cs!alberta!oha!tony From: tony@oha.UUCP (Tony Olekshy) Newsgroups: comp.unix.questions Subject: One way to fix $LOGNAME after `su - foo`. Message-ID: <440@oha.UUCP> Date: 20 Jul 90 21:56:25 GMT References: <316@dynasys.UUCP> <13367@smoke.BRL.MIL> Organization: Olekshy Hoover & Associates Ltd., Edmonton, Alberta, Canada. Lines: 25 In-Reply-To: Message <13367@smoke.BRL.MIL> dated 17 Jul 90 14:11:41 GMT 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@CS.UAlberta.CA BITNET: tony%oha.uucp@UALTAMTS.BITNET uucp: alberta!oha!tony