[sudo-users] sudo -u & environment help
Craig R. Skinner
skinner at britvault.co.uk
Mon May 26 13:17:05 MDT 2014
On 2014-05-26 Mon 09:33 AM |, Shawn McMahon wrote:
> Run sudo -V as root:
>
> sudo sudo -V
>
> That'll show you how it was compiled, in addition to how it's
> configured.
>
$ sudo sudo -V
Sudo version 1.7.2p8
Sudoers path: /etc/sudoers
Authentication methods: 'bsdauth'
Syslog facility if syslog is being used for logging: authpriv
Syslog priority to use when user authenticates successfully: notice
Syslog priority to use when user authenticates unsuccessfully: alert
Send mail if the user is not in sudoers
Lecture user the first time they run sudo
Require users to authenticate by default
Root may run sudo
Insult the user when they enter an incorrect password
Visudo will honor the EDITOR environment variable
Set the LOGNAME and USER environment variables
Length at which to wrap log file lines (0 for no wrap): 80
Authentication timestamp timeout: 5 minutes
Password prompt timeout: 5 minutes
Number of tries to enter a password: 3
Umask to use or 0777 to use user's: 022
Path to mail program: /usr/sbin/sendmail
Flags for mail program: -t
Address to send mail to: root
Subject line for mail messages: *** SECURITY information for %h ***
Incorrect password message: Sorry, try again.
Path to authentication timestamp dir: /var/run/sudo
Default password prompt: Password:
Default user to run commands as: root
Path to the editor for use by visudo: /usr/bin/vi
When to require a password for 'list' pseudocommand: any
When to require a password for 'verify' pseudocommand: all
File containing dummy exec functions: /usr/libexec/sudo_noexec.so
File descriptors >= 3 will be closed before executing a command
Reset the environment to a default set of variables
Environment variables to check for sanity:
TERM
LINGUAS
LC_*
LANGUAGE
LANG
COLORTERM
Environment variables to remove:
RUBYOPT
RUBYLIB
PYTHONINSPECT
PYTHONPATH
PYTHONHOME
TMPPREFIX
ZDOTDIR
READNULLCMD
NULLCMD
FPATH
PERL5DB
PERL5OPT
PERL5LIB
PERLLIB
PERLIO_DEBUG
JAVA_TOOL_OPTIONS
SHELLOPTS
GLOBIGNORE
PS4
BASH_ENV
ENV
TERMCAP
TERMPATH
TERMINFO_DIRS
TERMINFO
_RLD*
LD_*
PATH_LOCALE
NLSPATH
HOSTALIASES
RES_OPTIONS
LOCALDOMAIN
CDPATH
IFS
Environment variables to preserve:
XAUTHORIZATION
XAUTHORITY
TZ
PS2
PS1
PATH
MAIL
LS_COLORS
KRB5CCNAME
HOSTNAME
HOME
DISPLAY
COLORS
Locale to use while parsing sudoers: C
Local IP address and netmask pairs:
...
...
..
Despite the above, these envrionment vaiables are correctly altered:
HOME (login(1)??? & /etc/passwd)
PS1 (/etc/profile)
These are not:
PATH
MAIL
umask (/etc/login.conf --> should change to 022)
<craig at teak:bin 2>$ echo $LOGNAME; echo $PATH; echo $MAIL; umask
craig
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/site/bin:/usr/site/sbin:/home/craig/bin
/var/mail/craig
027
<craig at teak:bin 2>$ sudo -i -u david
<david at teak:~ 0>$ echo $LOGNAME; echo $PATH; echo $MAIL; umask
david
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/site/bin:/usr/site/sbin:/home/craig/bin
^^^^^
/var/mail/craig
^^^^^
027
^
<craig at teak:bin 2>$ sudo su -l david
<david at teak:~ 0>$ echo $LOGNAME; echo $PATH; echo $MAIL; umask
david
/usr/bin:/bin:/usr/local/bin:/usr/site/bin:/home/david/bin
^^^^^
/var/mail/david
^^^^^
022
^
I don't understand why "sudo su -l username" cleanly logs into the
user's environment, but "sudo -i -u username" ignores PATH, MAIL & umask
The authentication method is 'bsdauth', yet it seems to ignore some
/etc/login.conf directives and login(1) defaults. While su -l works.
Thoughts?
http://thread.gmane.org/gmane.os.openbsd.misc/211823/
More information about the sudo-users
mailing list