Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 648992 - net-analyzer/nrpe-3.2.1 configure line causes /usr/lib/tmpfiles.d/nrpe.conf to change ownership of /run to nagios:nagios
Summary: net-analyzer/nrpe-3.2.1 configure line causes /usr/lib/tmpfiles.d/nrpe.conf t...
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sysadmin Bugs
URL: https://github.com/NagiosEnterprises/...
Whiteboard:
Keywords:
Depends on:
Blocks: 662624
  Show dependency tree
 
Reported: 2018-02-27 21:43 UTC by Troy Ablan
Modified: 2019-03-15 10:18 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info of affected system (emerge-info.txt,4.67 KB, text/plain)
2018-02-27 21:43 UTC, Troy Ablan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Troy Ablan 2018-02-27 21:43:36 UTC
Created attachment 521348 [details]
emerge --info of affected system

In /usr/portage/net-analyzer/nrpe/nrpe-3.2.1.ebuild line 34, the configure line has the option:

        --with-piddir=/run \

This causes /usr/lib/tmpfiles.d/nrpe.conf to look like this:

#Type	Path			Mode	UID				GID				Age	Argument
d		/run	0755	nagios	nagios	-	-

as the file in the source tree startup/tmpfile.conf.in looks like this:

#Type   Path                    Mode    UID                             GID                             Age     Argument
d               @piddir@        0755    @nrpe_user@     @nrpe_group@    -       -

This all results in /run being owned by nagios:nagios instead of root:root, which breaks some things.  In particular net-dns/pdns-recursor does not start if /run is not owned by root:root for some reason.

Before I discovered that this was the culprit changing ownership of /run, I had some problems starting nrpe via service file, and I overrode the nrpe.service file so that it didn't specify a pid file.  Since it's a simple non-forking service, it doesn't actually need one.

I believe the fix would be to change --with-piddir to be set to /run/nrpe as it's evident that upstream nrpe doesn't expect to have this set to /run.  The service file should also automatically point to the new location.
Comment 1 Michael Orlitzky gentoo-dev 2018-08-02 13:07:30 UTC
I reported the issue upstream... I think the easiest way to solve it is to drop the unnecessary tmpfiles.d entry.

OpenRC users do want the PID file to be created (as root) in a directory that's owned by root:root, so changing --with-piddir to /run/nrpe would only halfway solve the problem. OpenRC now honors tmpfiles.d entries, so the permissions would get set wrong on /run/nrpe in that case.
Comment 2 Michael Orlitzky gentoo-dev 2018-09-29 22:13:00 UTC
Does the tmpfiles.d file even get installed by default with our ebuild?

I don't get one on my machine, but I'm not using systemd.
Comment 3 Troy Ablan 2018-09-30 00:03:50 UTC
Yes,

It does not appear on an openrc system, but it does on a systemd system.  I believe it's because nrpe's ./configure script detects the currently running init type at build time, and when it equals systemd, it sets src_tmpfile=tmpfile.conf (configure line 3819), while src_tmpfile remains unset when under any other init type.

-Troy
Comment 4 Michael Orlitzky gentoo-dev 2018-09-30 00:22:46 UTC
(In reply to Troy Ablan from comment #3)
> Yes,
> 
> It does not appear on an openrc system, but it does on a systemd system.  I
> believe it's because nrpe's ./configure script detects the currently running
> init type at build time, and when it equals systemd, it sets
> src_tmpfile=tmpfile.conf (configure line 3819), while src_tmpfile remains
> unset when under any other init type.
> 

Thanks. That behavior is incorrect in the first place, because (for example) OpenRC uses the tmpfiles.d entries too. But the guesswork is in general a bad idea because it makes bugs like this hard to spot. I'll see if I can (a) disable all of the guessing so that the build is consistent, and (b) patch out the PID file line from the systemd service, because it doesn't look like upstream is going anywhere.
Comment 5 Larry the Git Cow gentoo-dev 2018-09-30 12:29:29 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2ddfa65c2244d92429897a51b1d8a8e3dc8a92dc

commit 2ddfa65c2244d92429897a51b1d8a8e3dc8a92dc
Author:     Michael Orlitzky <mjo@gentoo.org>
AuthorDate: 2018-09-30 12:26:56 +0000
Commit:     Michael Orlitzky <mjo@gentoo.org>
CommitDate: 2018-09-30 12:27:53 +0000

    net-analyzer/nrpe: new revision to eliminate PID files with systemd.
    
    The NRPE systemd service is "simple," which means that it runs in the
    foreground. As a result, no PID file is needed to later kill it.
    Nevertheless, the systemd service file that ships with NRPE tries to
    create one. And in order to do that, it messes with some permissions
    (Gentoo bug 648992) that shouldn't be messed with. This commit adds a
    patch to remove the PID file from the service.
    
    A related problem that this revision fixes is the automagic detection
    of the operating system, distribution, and init system by the NRPE
    autotools. The new revision hard-codes all of these to "unknown,"
    which should result in behavior that is consistent across machines. In
    particular, it should cause the problematic tmpfiles.d entry
    (associated with the PID file) to not be installed.
    
    Bug: https://bugs.gentoo.org/648992
    Package-Manager: Portage-2.3.49, Repoman-2.3.10
    Signed-off-by: Michael Orlitzky <mjo@gentoo.org>

 .../files/nrpe-3.2.1-eliminate-systemd-pid.patch   | 38 +++++++++
 net-analyzer/nrpe/nrpe-3.2.1-r1.ebuild             | 89 ++++++++++++++++++++++
 2 files changed, 127 insertions(+)
Comment 6 Michael Orlitzky gentoo-dev 2018-09-30 12:30:55 UTC
Can you please give that -r1 a try? I made some changes to the build system that I hope will prevent the tmpfiles.d entry from being installed (and that I hope won't break anything else...)

I then added a custom patch to avoid creating the unused PID file in the first place.