Date: Fri, 31 Oct 2008 12:27:37 -0700 From: Fred Condo <fcondo@quinn.com> To: =?ISO-8859-1?Q?Fr=E9d=E9ric_Perrin?= <frederic.perrin@resel.fr> Cc: freebsd-questions@freebsd.org Subject: Re: Behaviour of su(1) Message-ID: <6F644950-947E-4D7E-85D7-E992E2A80A8D@quinn.com> In-Reply-To: <86mygklilz.fsf@chameau.maisel.enst-bretagne.fr> References: <86mygklilz.fsf@chameau.maisel.enst-bretagne.fr>
next in thread | previous in thread | raw e-mail | index | archive | help
Use this syntax (both equivalent): su - root su -l root You do have to specify the user with -l. Perhaps the man page could =20 clarify that. On Oct 31, 2008, at 11:33 AM, Fr=E9d=E9ric Perrin wrote: > Hello, > > When I =AB su - =BB to root (after being logged in as my normal 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 =20 > except for > | HOME, SHELL, PATH, TERM, and USER. > `---- > > So I would have expected LOGNAME to be either empty or set by some =20 > shell > startup script to be root. So, why is LOGNAME still equal to my =20 > previous > user ? (and where is it set ? =AB grep -r LOGNAME /etc =BB doesn't = turn up > anything...) > > This is an issue because emacs, for instance, uses $LOGNAME to load =20= > the > init-file. I could always add =AB export LOGNAME=3Droot =BB to my = shell > 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 =AB = =20 > gsu > -l root =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 > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to = "freebsd-questions-unsubscribe@freebsd.org=20 > " >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6F644950-947E-4D7E-85D7-E992E2A80A8D>