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)
Fri, Mar 29, 5:40 PM
Unknown Object (File)
Feb 14 2024, 9:10 AM
Unknown Object (File)
Jan 15 2024, 2:14 PM
Unknown Object (File)
Jan 9 2024, 8:43 AM
Unknown Object (File)
Dec 20 2023, 6:05 AM
Unknown Object (File)
Dec 16 2023, 5:51 PM
Unknown Object (File)
Nov 17 2023, 7:13 PM
Unknown Object (File)
Oct 15 2023, 6:29 AM
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 Not Applicable
Unit
Tests Not Applicable

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.