zsh-workers
 help / color / mirror / code / Atom feed
* USERNAME bug zsh-2.6-beta9
@ 1995-06-30 15:10 Paul H. Becker
  1995-06-30 15:20 ` Philip Kizer
  0 siblings, 1 reply; 6+ messages in thread
From: Paul H. Becker @ 1995-06-30 15:10 UTC (permalink / raw)
  To: zsh-workers

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".

As a result, prompt="%n>" will not display the correct username.

(btw: zsh is great, I really appreciate all the efforts...)

thank you
------------------------------------------------------------------------------
Paul Becker              o        Atria Software       main:    508-650-5100
(508)650-5116           /~>      24 Prime Park Way     support: 508-650-5151
becker@Atria.com     o...(\      Natick, MA  01760     fax:     508-647-1760
-----------------  ~~~~~~~~~~  -----------------------------------------------


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: USERNAME bug zsh-2.6-beta9
  1995-06-30 15:10 USERNAME bug zsh-2.6-beta9 Paul H. Becker
@ 1995-06-30 15:20 ` Philip Kizer
  1995-06-30 16:41   ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Philip Kizer @ 1995-06-30 15:20 UTC (permalink / raw)
  To: becker; +Cc: zsh-workers


becker@phobos.atria.com (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".

>As a result, prompt="%n>" will not display the correct username.
>
>(btw: zsh is great, I really appreciate all the efforts...)

Ah...I definitaly agree with you, this got me to finally track down the
change, this works for me:

*** init.c.bak	Fri Jun 30 10:18:35 1995
--- init.c	Fri Jun 30 10:18:49 1995
***************
*** 513,519 ****
  	else
  	    logname = ztrdup("");
      }
!     username = ztrdup(logname);
  
      /* Try a cheap test to see if we can *
       * initialize $PWD from $HOME        */
--- 513,519 ----
  	else
  	    logname = ztrdup("");
      }
!     username = ztrdup(pswd->pw_name);
  
      /* Try a cheap test to see if we can *
       * initialize $PWD from $HOME        */

Much better...thanks for complaining :)


-philip

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

"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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: USERNAME bug zsh-2.6-beta9
  1995-06-30 15:20 ` Philip Kizer
@ 1995-06-30 16:41   ` Bart Schaefer
  1995-06-30 17:10     ` Philip Kizer
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 1995-06-30 16:41 UTC (permalink / raw)
  To: becker, zsh-workers, pckizer

On Jun 30, 10:20am, Philip Kizer wrote:
} Subject: Re: USERNAME bug zsh-2.6-beta9
}
} becker@phobos.atria.com (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.


-- 
Bart Schaefer                                      Vice President, Engineering
schaefer@z-code.com                                Z-Code Software Corporation

What quantity of engineers is required to rotationally reconfigure an
electronically-actuated filament-enabled photon-wave generator?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: USERNAME bug zsh-2.6-beta9
  1995-06-30 16:41   ` Bart Schaefer
@ 1995-06-30 17:10     ` Philip Kizer
  1995-06-30 18:20       ` Zoltan Hidvegi
  0 siblings, 1 reply; 6+ messages in thread
From: Philip Kizer @ 1995-06-30 17:10 UTC (permalink / raw)
  To: schaefer; +Cc: becker, zsh-workers


"Bart Schaefer" <schaefer@z-code.com> wrote:
>On Jun 30, 10:20am, Philip Kizer wrote:
>} Subject: Re: USERNAME bug zsh-2.6-beta9
>}
>} becker@phobos.atria.com (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
reminder.

"%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

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

"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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: USERNAME bug zsh-2.6-beta9
  1995-06-30 17:10     ` Philip Kizer
@ 1995-06-30 18:20       ` Zoltan Hidvegi
  1995-06-30 21:55         ` Richard Coleman
  0 siblings, 1 reply; 6+ messages in thread
From: Zoltan Hidvegi @ 1995-06-30 18:20 UTC (permalink / raw)
  To: pckizer

> "%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?

I think it only came in in beta9. It happend when init.c started using
getlogin(). It used that well before beta9, but an other bug prevented it
working.

I think your patch does the right thing.

Someone else said that su should not change the environment. In fact USERNAME
is usually not in the environment, and it is reinitialized each time a new zsh
process is invoked.

Bye,
   Zoltan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: USERNAME bug zsh-2.6-beta9
  1995-06-30 18:20       ` Zoltan Hidvegi
@ 1995-06-30 21:55         ` Richard Coleman
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Coleman @ 1995-06-30 21:55 UTC (permalink / raw)
  To: zsh-workers

> > "%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?
> 
> I think it only came in in beta9. It happend when init.c started using
> getlogin(). It used that well before beta9, but an other bug prevented it
> working.

This is changed in beta10.  USERNAME always comes from pswd->pw_name
now.  Also USERNAME is now magical so that if you are root, executing

USERNAME=username

will change the username and uid the shell is executing under.  Also,
as root, you can execute command under other usernames/uid by

USERNAME=nobody command.

I'm putting the finishing touches on beta10.  There have been a lot of
internal changes and code reorganization.

rc


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1995-06-30 21:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-30 15:10 USERNAME bug zsh-2.6-beta9 Paul H. Becker
1995-06-30 15:20 ` Philip Kizer
1995-06-30 16:41   ` Bart Schaefer
1995-06-30 17:10     ` Philip Kizer
1995-06-30 18:20       ` Zoltan Hidvegi
1995-06-30 21:55         ` Richard Coleman

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).