Page MenuHomeFreeBSD

Add CAP_EVENT to pidfiles.
ClosedPublic

Authored by dab on Jun 19 2020, 5:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 9, 3:11 AM
Unknown Object (File)
Sun, Dec 8, 4:00 AM
Unknown Object (File)
Wed, Dec 4, 11:10 AM
Unknown Object (File)
Sat, Nov 23, 1:15 PM
Unknown Object (File)
Nov 21 2024, 1:55 PM
Unknown Object (File)
Nov 19 2024, 2:25 PM
Unknown Object (File)
Nov 6 2024, 8:24 PM
Unknown Object (File)
Nov 6 2024, 3:55 PM
Subscribers

Details

Summary

CAP_EVENT was omitted on pidfiles (in
pidfile_open()). There seems no reason why a process that creates
and writes a pidfile cannot monitor events on that file. This mod adds
the capability.

As a concrete example of why one might want to do this: at $JOB there
is a daemon that is started very early in the rc sequence; in
particular it is started before rc.d/cleanvar. When cleanvar runs, it
removes the pidfile for the daemon. If an attempt is made to start
that daemon later, it checks for the existence of the pidfile, but the
pidfile no longer (apparently) exists, so the daemon starts up and
there are now two copies of the daemon running. In order to avoid
this, I attempted to have the daemon monitor its pidfile via kevent
and re-create it if it is deleted but found that the attempt to
register the event failed since the process lacked the CAP_EVENT
capability. Adding it (as here) fixed the issue.

Test Plan

Verified working at $JOB

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 31833
Build 29393: arc lint + arc unit

Event Timeline

dab requested review of this revision.Jun 19 2020, 5:43 PM

I'm supportive of the capability change in general.

Do delete events actually notify on the deleted file? I would expect to receive a notification on the pid's parent directory, but am not sure about the pid file itself.

This revision is now accepted and ready to land.Jun 19 2020, 8:38 PM
In D25363#559516, @cem wrote:

Do delete events actually notify on the deleted file? I would expect to receive a notification on the pid's parent directory, but am not sure about the pid file itself.

I am getting a notice due to deletion of the file in my test.

This revision was automatically updated to reflect the committed changes.