sudo changing environment variables

King, Daniel Daniel.King at
Tue May 7 14:11:33 EDT 2002

See 'set_logname' in the sudoers man page:

      set_logname Normally, sudo will set the LOGNAME and USER environment
                  variables to the name of the target user (usually root
                  unless the -u flag is given).  However, since some
                  programs (including the RCS revision control system) use
                  LOGNAME to determine the real identity of the user, it may
                  be desirable to change this behavior.  This can be done by
                  negating the set_logname option.

This may be a partial answer to your question.

A. Daniel King, System Analyst
Fiserv - Atlanta Center
1475 Peachtree Street, NE - Suite 700
Atlanta, GA 30309
404-873-2851 x2034

>Date: Tue, 7 May 2002 19:42:07 +0300
>From: Tom Alsberg <alsbergt at>
>To: sudo-users at
>Subject: sudo changing environment variables
>Reply-To: Tom Alsberg <alsbergt at>
>Hi there.
>Is there, or will there be, a way to configure sudo not to change
>environment variables like LOGNAME, USER, MAILPATH, etc., except for
>patching the source?
>I think this would be a more sensible behaviour, and should at least
>be configurable to be that way...
>The way su doesn't change those variables, it seems more sensible, so
>that the user's environment is more preserved, and for example
>some applications use the preferences/rc files of the user issuing the
>su command (usually the desired behaviour), and RCS gets the author's
>correct identity...

More information about the sudo-users mailing list