Bug#3008: Telnetd sets wrong USER (funny side effects)
> I don't mind changing login to set or clear the USER variable, but any
> program that requires it is buggy. Consulting W.R. Stevens, I find
> that USER is required by neither POSIX.1 nor XPG3. LOGNAME is, and
> login dutifully sets it.
FYI, login from the shadow suite sets both. The following comment in
the code explains why:
* Export the user name. For BSD derived systems, it's "USER", for
* all others it's "LOGNAME". We set both of them.
> Programs using USER should instead use LOGNAME.
We are POSIX, but we also use many BSD sources. I agree they all
should use LOGNAME instead, but until we are sure they all have been
modified to use LOGNAME, I think it is wise to set both variables.
Some of the various /etc/X11/... scripts also use USER, not LOGNAME.