Bug 277704

Summary: net-mgmt/nrpe changes /var/ ownership to nagios when rc.d/nrpe starts
Product: Ports & Packages Reporter: Steve Rikli <sr>
Component: Individual Port(s)Assignee: Muhammad Moinur Rahman <bofh>
Status: Closed FIXED    
Severity: Affects Some People CC: o.kryvulia
Priority: --- Flags: bugzilla: maintainer-feedback? (bofh)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Proposed patch none

Description Steve Rikli 2024-03-14 19:54:30 UTC
Installed net-mgmt/nrpe 4.1.0 pkg. Using /usr/local/etc/nrpe.cfg.sample as a template for the running nrpe.cfg gives this pidfile setting:

pid_file=/var/nrpe.pid

With the included rc.d/nrpe startup script this results in /var/ directory getting chown'd to the nagios user.

Presumably it happens due to this command in rc.d/nrpe nrpe_prestart()

        install -d -o ${nrpe_user:-nagios} ${pidfile%/*}

Which results in:

$ ls -lad /var
drwxr-xr-x  26 nagios wheel 1024 Mar 14 11:39 var
$ ls -la /var/nrpe.pid 
-rw-r--r--  1 root wheel 5 Mar 14 11:39 /var/nrpe.pid

The /var/ ownership change seems bad, and the pidfile location may not be optimal. A couple ideas for a fix:

1) comment-out pid_file from nrpe.cfg and let rc.d/nrpe pidfile logic choose the location
2) set a different path for pid_file in nrpe.cfg, e.g. /var/run/nrpe/nrpe.pid

I'm presently using option #1 and it does avoid the /var/ ownership change.
Comment 1 Oleksandr Kryvulia 2024-05-30 08:20:02 UTC
Created attachment 251079 [details]
Proposed patch
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-07-28 17:11:23 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6eec36c45b04c6d437453378dac08171775b2825

commit 6eec36c45b04c6d437453378dac08171775b2825
Author:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
AuthorDate: 2024-07-28 17:08:53 +0000
Commit:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2024-07-28 17:08:53 +0000

    net-mgmt/nrpe: Fix permission on /var

    - Fix build for ports users [1]

    PR:             277704, 280180 [1]
    Reported by:    sr@genyosha.net, eugen [1]

 net-mgmt/nrpe/Makefile  | 8 +++++---
 net-mgmt/nrpe/pkg-plist | 1 -
 2 files changed, 5 insertions(+), 4 deletions(-)
Comment 3 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-07-28 17:13:44 UTC
Sorry that I missed the patch and forgot to use your name as the author.