On 2014-04-04 Fri 12:01 PM |, Todd wrote:
> I think this should work
>
> sudo su - user
>
Yes, going via root works.
How do I get the same user environment with something like:
"sudo -H -i -u username"
See below:
> > >
> > > When I use sudo in this manner, settings such as $PATH, $MAIL
> > > & umask aren't being honoured:
> > >
> > > $ sudo -H -i -u david
> > > $ echo $LOGNAME; echo $PATH; echo $MAIL; umask
> > > david
> > > /usr/bin:/bin:/usr/sbin:/s...../bin:/usr/site/sbin:/home/craig/bin
^^^^^
> > > /var/mail/craig
^^^^^
> > > 027
not: 022
> > >
> > >
> > > sudo(8):
> > >
> > > Command Environment
"By default, the env_reset option is enabled." .....
> > > ................... On BSD systems, if the use_loginclass option is
> > > enabled, the environment is initialized based on the path and setenv
> > > settings in /etc/login.conf. The new environment contains the TERM,
> > > PATH, HOME, MAIL, SHELL, LOGNAME, USER, USERNAME and SUDO_* variables
> > >
> > > $ egrep 'env_|Defaults' /etc/sudoers | grep -v ^#
> > > .....
> > > Defaults always_set_home, ignore_dot, use_loginclass
> > >
HOME, SHELL, LOGNAME, USER, USERNAME are being set.
PATH & MAIL are not.
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
Is it necessary to go through root?
e.g: "sudo vi /etc/pf.conf" -vs- "sudoedit /etc/pf.conf"