From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19857 invoked by alias); 2 Apr 2014 19:08:09 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32519 Received: (qmail 22308 invoked from network); 2 Apr 2014 19:08:02 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FILL_THIS_FORM,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=kHMdZxhom1vyiwSjUleitoMfzeYyTRyPfOjLUvvueDQ=; b=ytI7BBDZxbb5stAzKYzkJIfFKysE9XYddYd+Yodze4Kdmqjn+Czj4X2vYZFF071vPJ hU4RJshwI7Glsuf9mKJnC3ooVdFLj+fuaNy74meK0vyKOTwj1CYvg3XqG6DO/LGci8Dx FnNH1wyTOjAzt1cizUcNEWzQSnGUv31eNcTaAfmb49FDiiCCyQbSKwgdp0IynwSCOgzQ AO1lv8A1P4mUQbySDuNdGOLFk3xWzZTxeIC3toSFa2F8mxbDbvY3N1RQLEAE/+PEkur7 qmnIQNmYTwxGi3xMTM0N0ljtCxJuxtrUTCk0x7dE8sx3TWx7WaDbX17XA4FPOZaSS2mD t5XQ== X-Received: by 10.42.20.193 with SMTP id h1mr2207385icb.70.1396465678507; Wed, 02 Apr 2014 12:07:58 -0700 (PDT) Date: Wed, 2 Apr 2014 14:06:21 -0500 From: Erik Johnson To: Peter Stephenson Cc: zsh-workers@zsh.org Subject: Re: LOGNAME not properly set on FreeBSD Message-ID: <20140402190621.GA5323@gmail.com> References: <20140401212239.GE20508@gmail.com> <20140402102348.4ceeddad@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="k1lZvvs/B4yU6o8G" Content-Disposition: inline In-Reply-To: <20140402102348.4ceeddad@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.23 (2014-03-12) --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 02, 2014 at 10:23:48AM +0100, Peter Stephenson wrote: >On Tue, 01 Apr 2014 16:22:39 -0500 >Erik Johnson 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 --=20 -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 --k1lZvvs/B4yU6o8G Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iEYEARECAAYFAlM8X60ACgkQXlWDxDeAjz8iWgCggyHuofJAmdkCFfpOv9fV61zM srEAmwTDSxGQELfROfmvlohIwzbK9Vok =NDvZ -----END PGP SIGNATURE----- --k1lZvvs/B4yU6o8G--