FS#52873 - [nrpe] PATH and other environment variables not set with NRPE 3.x

Attached to Project: Community Packages
Opened by Moritz Bunkus (mbunkus) - Monday, 06 February 2017, 16:30 GMT
Last edited by Jonathan Steel (jsteel) - Sunday, 26 February 2017, 20:18 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Jonathan Steel (jsteel)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Since the recent upgrade of Arch's NRPE package to >= 3.0 the PATH environment variable and other environment variables aren't set if the `nrpe_user` configuration variable is set to a numeric ID instead of a user name. This is unfortunately Arch's default configuration; it ships with `nrpe_user=31`. It seems no other distribution ships with a numeric `nrpe_user` by default, otherwise this would surely have come up earlier.

This is a bug newly introduced in NRPE 3.0, to be more precise, in its function for cleaning the environment, which calls `getpwnam(nrpe_user)`, and that fails, obviously.

I've already report this upstream: https://github.com/NagiosEnterprises/nrpe/issues/96

I'm also reporting it here in order to make it easier for other affected Arch users to figure out what's wrong and why their checks are suddenly failing.

Additional info:
* package version: nrpe 3.0.1-2
* config: default configuration

Steps to reproduce:

1. Add a check to NRPE that executes a Perl script which in turn dumps %ENV somewhere
2. Restart nrpe.service
3. Execute that check via `check_nrpe -H localhost -c yourcheck`
4. Observe output generated by 1.
This task depends upon

Closed by  Jonathan Steel (jsteel)
Sunday, 26 February 2017, 20:18 GMT
Reason for closing:  Fixed
Additional comments about closing:  3.0.1-3
Comment by Jonathan Steel (jsteel) - Tuesday, 21 February 2017, 08:54 GMT
The reason I specify the uid rather than username is that nrpe sets ownership on files during the build and the user doesn't get created until the package is installed. Hopefully upstream can resolve your issue. In the meantime you could build your own package on a system that already has the nrpe user.
Comment by Moritz Bunkus (mbunkus) - Tuesday, 21 February 2017, 09:10 GMT
Well, you could modify the nrpe.cfg at the end of the build process before packaging it. A simple "sed -i -e 's/^nrpe_user=.*/nrpe_user=nagios/' -e 's/^nrpe_group=.*/nrpe_group=nagios/' path/to/nrpe.cfg" would probably suffice and protect other users from running into this particular issue.

I am aware of Arch's policy not to modify upstream. However, things such as this are done often enough as far as I can tell.

My own workaround is not to use your nrpe.cfg file but my own in which I'm using the user names. pacdiff takes care of showing me what's changed after updating the package, and I simply skip the hunks that modify nrpe_user/nrpe_group. Do I wish I wouldn't have had to spend a couple of hours debuging this (for which I definitely blame upstream, not you!)? Absolutely. Can I live with the current situation? I sure can.
Comment by Jonathan Steel (jsteel) - Wednesday, 22 February 2017, 16:17 GMT
Do you mean nrpe_user=nrpe? not nagios? I see, I assumed (I hadn't thought much into it) it would need changing during build time but if you say it's just the nrpe.cfg that needs changing then sure, I'll consider that.
Comment by Moritz Bunkus (mbunkus) - Wednesday, 22 February 2017, 16:27 GMT
"nrpe_user=nrpe", of course, not "…=nagios"; dito "nrpe_group=nrpe".

Yes, the only change needed to make this problem go away is the nrpe.cfg file. Nothing has to be changed during compilation.

Thanks!

Loading...