zsh-workers
 help / color / mirror / code / Atom feed
From: Erik Johnson <palehose@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: zsh-workers@zsh.org
Subject: Re: LOGNAME not properly set on FreeBSD
Date: Wed, 2 Apr 2014 14:06:21 -0500	[thread overview]
Message-ID: <20140402190621.GA5323@gmail.com> (raw)
In-Reply-To: <20140402102348.4ceeddad@pwslap01u.europe.root.pri>

[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]

On Wed, Apr 02, 2014 at 10:23:48AM +0100, Peter Stephenson wrote:
>On Tue, 01 Apr 2014 16:22:39 -0500
>Erik Johnson <palehose@gmail.com> wrote:
>> When using "su - username" to change users, zsh is not properly setting
>> the LOGNAME environment variable on FreeBSD. Example below.
>>
>> erik@virtubsd:~% zsh --version
>> zsh 5.0.2 (amd64-portbld-freebsd9.1)
>> erik@virtubsd:~% su - root
>> Password:
>> virtubsd# echo $LOGNAME
>> erik
>
>From the code, it looks like this would only happen if getlogin() is
>returning the wrong thing, i.e. "erik", or it's not returning anything
>and the shell is having to guess and doing so wrongly.  Although that
>doesn't seem very likely it's hard to see another way this can happen
>within the shell.  Presumably
>
>python -c 'import os; print os.getlogin()'
>
>prints "root"?
>
>It might also be useful to start the shell with the "-x" option to check
>all the initialisation scripts.  I'm not sure you can do that with su
>without some fiddling but you could put "set -x" temporarily at the top
>of /etc/zshenv.
>
>pws

Python os.getlogin() does indeed show "erik" instead of "root". So this
may just be a difference between glibc and BSD libc. Either way, it
"just works" in bash, sh, csh, tcsh, and ksh, as can be seen below, so
I believe there is an argument for making it work properly in FreeBSD as
well, or at the very least adding some wording to the zshparam manpage
which makes this difference in behavior clear.


erik@virtubsd:~% sudo chpass -s /bin/sh root
Password:
chpass: user information updated
# erik@virtubsd:~% su -
Password:
# python2 -c 'import getpass; print getpass.getuser()'
root
# ^D%
# erik@virtubsd:~% sudo chpass -s /usr/local/bin/bash root
chpass: user information updated
[root@virtubsd ~]# python2 -c 'import getpass; print getpass.getuser()'
root
[root@virtubsd ~]# logout
erik@virtubsd:~% sudo chpass -s /bin/tcsh root
chpass: user information updated
erik@virtubsd:~% su -
Password:
virtubsd# python2 -c 'import getpass; print getpass.getuser()'
root
virtubsd# logout
erik@virtubsd:~% sudo chpass -s /usr/local/bin/ksh93 root
Password:
chpass: user information updated
erik@virtubsd:~% su -
Password:
# python2 -c 'import getpass; print getpass.getuser()'
root
# ^D
erik@virtubsd:~% sudo chpass -s /usr/local/bin/zsh root
chpass: user information updated
erik@virtubsd:~% su -
Password:
virtubsd# python2 -c 'import getpass; print getpass.getuser()'
erik


-- 

-Erik

"For me, it is far better to grasp the universe as it really is than to
persist in delusion, however satisfying and reassuring."  --Carl Sagan


[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2014-04-02 19:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-01 21:22 Erik Johnson
2014-04-01 21:30 ` Erik Johnson
2014-04-02  0:27 ` Phil Pennock
2014-04-02  0:50   ` Erik Johnson
2014-04-02 20:54     ` Phil Pennock
2014-04-02 21:11       ` Erik Johnson
2014-04-02  9:23 ` Peter Stephenson
2014-04-02 19:06   ` Erik Johnson [this message]
2014-04-02 20:58     ` Peter Stephenson
2014-04-02 21:14       ` Erik Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140402190621.GA5323@gmail.com \
    --to=palehose@gmail.com \
    --cc=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).