Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: USERNAME bug zsh-2.6-beta9

"Bart Schaefer" <schaefer@xxxxxxxxxx> wrote:
>On Jun 30, 10:20am, Philip Kizer wrote:
>} Subject: Re: USERNAME bug zsh-2.6-beta9
>} becker@xxxxxxxxxxxxxxxx (Paul H. Becker) wrote:
>} >One (tiny) problem I have found with zsh-2.6-beta9 (as well as
>} >zsh-2.6-beta9-hzoli9) is that when I "su" to a new user, $USERNAME stays
>} >the same as the person I initially logged in as ($LOGNAME). Previous
>} >version of zsh (zsh-2.6-beta8) correctly change $USERNAME when I "su".

>Er, sorry, but that's the correct behavior.  USERNAME and USER and
>LOGNAME and HOME and so on should only get changed when you use "su -"
>(to run the new shell as a login shell).  Otherwise the environment
>is supposed to remain that of the original user.

Well, I actually don't care about the environment variables, I only care
about the %n printed from the PROMPT or 'print -P', and anyway ... even
when I 'su -', _my_ username was getting printed instead of 'root'.
Granted, I use %# so the final character is a "#" instead of "%", but
that's why I use "%n", especially when su-ing, just as an on-screen

"%n" should show the username of the uid running the shell in my opinion as
that's what current privileges are in effect.  I guess this qualifies as a
minor change from the way it's documented, and it was just "wrong" for so
long I got used to it showing name of current uid.  Which beta release did
that actually get "fixed"...about b7?

Getting it from the utmp will always break _all_ su's, even 'su -'.  That's
why I chose the "fix" I did; logname will stay set from utmp as it is now,
but username will be set to the username of the uid running the process so
that "%n" shows the "correct" (IMO) information.

Suggestions for a cleaner way while keeping "%n" able to show "root" when
you do a "su -"?


____________________________________________________________ Philip Kizer ___
Texas A&M CIS Operating Systems Group, Unix ( 409.862.4120 ) pckizer@xxxxxxxx

"Relying on the government to protect your privacy is like asking a peeping
tom to install your window blinds." -John Perry Barlow, EFF co-founder

Messages sorted by: Reverse Date, Date, Thread, Author