Random things, I think I know

Configure sudo to set $HOME to the home directory of the target user.

According to the documentation if the Defaults        env_reset is set, the $HOME will be set to the home directory of the target user. On the surface it might look straight forward, but if you read carefully, you might notice that the contents of env_keep and env_check also affects this behavior.

The problem is, even if you don't see env_keep configured in your sudoers file, there is a default list that comes when you install sudo. To check the default env_keep variables, login as root sudo su and run sudo -V. Under the section Environment variables to preserve: you will see the list of environment variables that get preserved when you run a sudo command.


So, even though the $HOME is set to the home directory of the target user initially, it gets over-written by these default env_keep variables.

To avoid this, you can configure the Defaults with always_set_home. So setting Defaults        always_set_home will set the $HOME to home directory of the target user despite the list of env_keep variables.

No comments:

Post a Comment