Bug 298104 - syslogd quits, if a piped-to to process fails
Summary: syslogd quits, if a piped-to to process fails
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 15.1-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-09-01 21:58 UTC by Mikhail Teterin
Modified: 2026-09-02 19:35 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Teterin freebsd_committer freebsd_triage 2026-09-01 21:58:04 UTC
The failure of a started pipe should, normally, be logged peacefully with the daemon moving on. However, since the base ffad04235a76, it errors out due to being unable to get vanished child's PID. The simplest way to reproduce the problem is to configure piping into `|exit 1`.

The below patch, suggested by Claude Opus, fixes the problem for me -- by explicitly allowing PID-querying:

--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -3824,7 +3824,8 @@ p_open(const char *prog, int *rpd)
         }
         
         if (cap_rights_limit(pd,
-           cap_rights_init(&rights, CAP_PDKILL, CAP_EVENT)) == -1)
+           cap_rights_init(&rights, CAP_PDKILL, CAP_EVENT,
+           CAP_PDGETPID)) == -1)
                 err(1, "cap_rights_limit");
         *rpd = pd;
         return (pfd[1]);
Comment 1 commit-hook freebsd_committer freebsd_triage 2026-09-02 19:35:04 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=87cfe4a62078bc8ff14671fde3af347e7c7e3a26

commit 87cfe4a62078bc8ff14671fde3af347e7c7e3a26
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-09-02 14:41:02 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-09-02 19:33:56 +0000

    syslogd: Pipes need the CAP_PDGETPID right as well

    While here, use caph_rights_limit(), as syslogd already uses
    caph_enter().

    PR:             298104
    Reported by:    mi
    Fixes:          24816abb8740 ("syslogd: Limit rights on procdescs")
    MFC after:      3 days

 usr.sbin/syslogd/syslogd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)