Antwort: Re: $HOME is not set in init script
Daniel Meyer
eagle at cyberdelia.de
Thu Jan 25 15:54:22 CET 2007
On Thu, 25 Jan 2007, TKocher at spirit21.de wrote:
> Daniel,
>
> nagios is started in /etc/init.d/nagios with "su - nagios -c nagios", so the process
> inherits the environment varialbes of the root user, which executes the su command.
> ($HOME is /root)
[root at server ~]# echo $HOME
/root
[root at server ~]# su - nagios
-sh-3.00$ echo $HOME
/var/log/nagios
Nope, the environment get changed to the values valid for the user...
> so the ssh wants to open ~/.ssh/known_hosts which is /root/.ssh/known_hosts which is
> not readable by the nagios user.
sh-3.00$ cd ~/.ssh
sh: cd: /var/log/nagios/.ssh: No such file or directory
Nope, it looks right into the home directory of the nagios user.
> If you look into /etc/init.d/nagios a lot of environment varialbes are set, it is no
> big deal to set in addition the $HOME variable.
Maybe it would help to know which distro you are using - the examples in
my mail are from CentOS 4.4. But its the nature of su to behave as it does
here:
"By default, `su' does not change the current directory. It sets the
environment variables `HOME' and `SHELL' from the password entry for
USER, and if USER is not the super-user, sets `USER' and `LOGNAME' to
USER. By default, the shell is not a login shell."
(from the su info page)
And my most important point stays: do you really want to have a daemon
accessing security related files within roots homedir?
Danny
--
Q: Gentoo is too hard to install = http://www.cyberdelia.de
and I feel like whining. = eagle at cyberdelia.de
A: Please see /dev/null. =
(from the gentoo installer FAQ) = \o/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list