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_resetshould already have solved this. Regardless, using--set-homeworks. – Oliver Salzburg Dec 17 '14 at 00:25--set-homeis 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