I'm running a check with Nagios and when being scheduled through NRPE it tries to read the config file from the home directory of the root user instead of the nagios user that NRPE is running as.
My guess is that this happens because the $HOME environment variable doesn't get re-initialized properly when NRPE daemonizes/starts.
As long as $HOME is set at all Python won't check with the OS where the user's home folder is. See the documentation for os.path.expanduser, and unless it's given the path in ~user/some/path format it won't figure out who the current user is.
My plan will be to:
Current OS is Windows
Use os.path.expanduser
Current OS is not Windows:
Figure out what the UID running the script is os.geteuid
I'm running a check with Nagios and when being scheduled through NRPE it tries to read the config file from the home directory of the root user instead of the nagios user that NRPE is running as.
My guess is that this happens because the
$HOME
environment variable doesn't get re-initialized properly when NRPE daemonizes/starts.As long as
$HOME
is set at all Python won't check with the OS where the user's home folder is. See the documentation for os.path.expanduser, and unless it's given the path in~user/some/path
format it won't figure out who the current user is.My plan will be to:
os.path.expanduser
os.path.expanduser