Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Oct 2008 19:33:44 +0100
From:      =?utf-8?Q?Fr=C3=A9d=C3=A9ric_Perrin?= <frederic.perrin@resel.fr>
To:        freebsd-questions@freebsd.org
Subject:   Behaviour of su(1)
Message-ID:  <86mygklilz.fsf@chameau.maisel.enst-bretagne.fr>

next in thread | raw e-mail | index | archive | help
Hello,

When I =C2=AB=C2=A0su -=C2=A0=C2=BB to root (after being logged in as my no=
rmal user), the
LOGNAME env variable is still set to my previous user, as in :

,----
| fred@chameau:~% /usr/bin/su -l
| Password:
| root@chameau:~# echo $USER - $LOGNAME
| root - fred
`----

As far as I can tell, this contradicts the fine manual that says :

,----
| -l      Simulate a full login.  The environment is discarded except for
|         HOME, SHELL, PATH, TERM, and USER.
`----

So I would have expected LOGNAME to be either empty or set by some shell
startup script to be root. So, why is LOGNAME still equal to my previous
user ? (and where is it set ? =C2=AB grep -r LOGNAME /etc =C2=BB doesn't tu=
rn up
anything...)

This is an issue because emacs, for instance, uses $LOGNAME to load the
init-file. I could always add =C2=AB export LOGNAME=3Droot =C2=BB to my she=
ll
startup file, but this doesn't quite feel right...

GNU su (as it is ocnfigured in Debian at least) resets LOGNAME to root
in the same situation. (and by the way, GNU su seems broken : if I =C2=AB=
=C2=A0gsu
-l root=C2=A0=C2=BB, I always get a 'Password incorrect' answer).

As a side question, is it considered bad practice to set root's shell
and locales to something else then the default ?

--=20
Fred



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86mygklilz.fsf>