I'm setting up a Vagrant box and I noticed something I found odd.
root@box:~# sudo --user=vagrant bash
bash: /root/.bashrc: Permission denied
vagrant@box:~$ export
declare -x HOME="/root"
Why is HOME
set to /root
here? The home directory for the user vagrant is certainly not /root
:
vagrant@box:~$ grep vagrant /etc/passwd
vagrant:x:1000:1000::/home/vagrant:/bin/bash
Everything I found online talked about how to inherit environment variables, not how to prevent it. The sudoers file contains the env_reset
default. I don't know what else controls this behavior.
env_reset
should already have solved this. Regardless, using--set-home
works. – Oliver Salzburg Dec 17 '14 at 00:25--set-home
is the long name for-H
(the option mentioned in the man page). Not sure why aboutenv_reset
. If it doesn't behave as documented, report a bug. – vinc17 Dec 17 '14 at 00:27