$HOME is not set correctly for plug-ins

Alexander Haas alex at geloet.de
Thu Nov 25 00:12:49 CET 2010


Hi Jon,

thank you for getting back on me. Of course I did do a su - nagios for 
my tests. I fact all my console tests run fine. I think it's Nagois 
doing some kind of su in its internals which causes my plug-in to get a 
wrong $HOME inherited. The bad behavior only occurs when executed by the 
actual Nagios setup.

Best,

Alex


On 24.11.2010 22:04, Jon Adcock wrote:
> Alexander,
>   It sounds like you are saying that you login as root, then su to 
> nagios.  If that's the case, make sure that you use su - nagios
> The hyphen tells su to use the environmental variables of the user 
> that you are switching to.  Without using the hyphen, it continues to 
> use the environmental variables of the base user (root in this case).
>
> Jon Adcock
> Network Systems Administrator
> MIS / Systems Team
> Leon County
> (850) 606-5500
> >>> Alexander Haas <alex at geloet.de> 11/24/2010 3:39 PM >>>
> Hi Nagios users,
>
> this is my first post. I encountered a behavior I am not able to
> understand. Well, I guess I did understand it, but I don't know how to
> counter it :)
>
> When I write a plug-in for Nagios it is executed as nagios:nagios. Yet
> $HOME is set to "/root".
>
> My /etc/password and nagios's home-directory are ok. It works well when
> I log in as user nagios and execute the plug-in there.
>
> I did expect to find some attributes for command definitions to set the
> home directory, but I could not find any.
>
> I guess the whole thing has to do with su and the way it does (not)
> handle the home directory or environment in general.
>
> Currently I work around that behavior using this code:
> if [ "$HOME" == "/root" ] && [ "`whoami`" == "nagios" ]
> then
>      HOME="/usr/local/nagios"
> fi
>
> But as you might guess I am not very satisfied.
>
> Thanks in advance,
>
> Alex
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> _______________________________________________
> 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
>
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App&  Earn a Chance To Win $500!
> Tap into the largest installed PC base&  get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
>
>
> _______________________________________________
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20101125/ecc1c658/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
-------------- next part --------------
_______________________________________________
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