Subject: Re: "Don't login as root, use the su command."
To: David Brownlee , <current-users@netbsd.org>
From: Geoff Adams <gadams@avernus.com>
List: current-users
Date: 02/12/2000 04:17:43
On Thu, 10 Feb 2000, David Brownlee wrote:

> > Maybe an environment varialbe SU_USER which is set when su su's you. ??
> 
>     How about 'SU_FROM'?
>     (I like this idea :)

At this point, I was going to write in to mention LOGNAME, which exists just
for this purpose.  Several shells define LOGNAME when you log in, and know
better not to set ever again.  In fact, my favorite shell, zsh, marks that
env variable read-only.

A number of utilities honor this environment variable, using it for just the
sort of accounting that it was meant for -- rcs included.  Fortunately,
someone else mentioned this.

On Fri, 11 Feb 2000, David Brownlee wrote:

> tcsh sets LOGNAME, so I'd ideally prefer something that works
> for both csh and tcsh (hence the SU_FROM :)

Our csh does set LOGNAME if not already set.  Unfortunately, our sh does
not.

I think the solution, then, is to update sh to set up LOGNAME.  Then, the
likelihood of anyone executing su with LOGNAME not already set would be very
small.  Unfortunately, LOGNAME is not one of the few environment variables
preserved by 'su -'.  I guess it could be added.

Unless these two changes violate any applicable standards.

I agree that LOGNAME should never be *modified* by su.  But, you could go
one step further that what I'm suggesting, and have su set up LOGNAME to the
best of its ability if it's not already set.  Would that be worse in any
situation than having no LOGNAME set at all?

- Geoff