Bug 293879 - syslogd: alternation in ereregex property-based filter does not work
Summary: syslogd: alternation in ereregex property-based filter does not work
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 15.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Enji Cooper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-03-17 14:15 UTC by vvv
Modified: 2026-10-10 22:01 UTC (History)
2 users (show)

See Also:
ngie: mfc-stable14-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vvv 2026-03-17 14:15:39 UTC
Alternation in ereregex property-based filter does not work.

Steps to reproduce:

1. Add filter at the beginning of /etc/syslog.conf:
:msg, !ereregex, "substring1|substring2"

2. Apply new config:
killall -1 syslogd

3. Send message to syslog:
logger -p auth.notice "substring1"
logger -p auth.notice "substring2"
logger -p auth.notice "substring3"

Only the last message should appear in /var/log/messages.
But all messages will appear:

Mar 17 15:58:09 host user[85236]: substring1
Mar 17 15:58:14 host user[85240]: substring2
Mar 17 15:59:35 host user[85276]: substring3
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2026-03-23 01:35:44 UTC
https://github.com/freebsd/freebsd-src/pull/2088
Comment 2 commit-hook freebsd_committer freebsd_triage 2026-03-29 03:44:17 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=69042706604752f42072f422671a72c49343ac45

commit 69042706604752f42072f422671a72c49343ac45
Author:     tzyt <zyt2006613@outlook.com>
AuthorDate: 2026-03-22 08:40:57 +0000
Commit:     Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-03-29 03:43:42 +0000

    syslogd: Fix ereregex property filters and add test

    This change fixes Bug 293879, where ereregex filters in syslogd
    did not handle alternation correctly.

    The issue appears to come from mixing up two different kinds of
    flags: syslogd's internal serialized filter flags in
    usr.sbin/syslogd/syslogd.h, and the regex compilation flags from
    include/regex.h. ereregex was storing REG_EXTENDED in cmp_flags,
    even though cmp_flags is meant to carry syslogd's own FILT_FLAG_*
    values for configuration serialization and reconstruction.

    REG_EXTENDED has the same bit value as FILT_FLAG_EXCLUDE, so the
    filter could be reconstructed with the wrong semantics.

    The fix stores FILT_FLAG_EXTENDED instead, allowing syslogd to
    correctly REG_EXTENDED when compiling the regex.

    A test was also added for both ereregex and !ereregex filters.

    PR: 293879
    Signed-off-by: tzyt <zyt2006613@outlook.com>
    Fixes: 2567168dc4986
    MFC after: 1 week
    Reviewed-by: markj, ngie
    Pull-Request: https://github.com/freebsd/freebsd-src/pull/2088

 usr.sbin/syslogd/syslogd.c             |  2 +-
 usr.sbin/syslogd/tests/syslogd_test.sh | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-05-27 22:10:13 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2018defe9b98a378dbc98ab53c8d000e922fe0b8

commit 2018defe9b98a378dbc98ab53c8d000e922fe0b8
Author:     tzyt <zyt2006613@outlook.com>
AuthorDate: 2026-03-22 08:40:57 +0000
Commit:     Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-05-27 22:09:07 +0000

    syslogd: Fix ereregex property filters and add test

    This change fixes Bug 293879, where ereregex filters in syslogd
    did not handle alternation correctly.

    The issue appears to come from mixing up two different kinds of
    flags: syslogd's internal serialized filter flags in
    usr.sbin/syslogd/syslogd.h, and the regex compilation flags from
    include/regex.h. ereregex was storing REG_EXTENDED in cmp_flags,
    even though cmp_flags is meant to carry syslogd's own FILT_FLAG_*
    values for configuration serialization and reconstruction.

    REG_EXTENDED has the same bit value as FILT_FLAG_EXCLUDE, so the
    filter could be reconstructed with the wrong semantics.

    The fix stores FILT_FLAG_EXTENDED instead, allowing syslogd to
    correctly REG_EXTENDED when compiling the regex.

    A test was also added for both ereregex and !ereregex filters.

    PR: 293879
    Signed-off-by: tzyt <zyt2006613@outlook.com>
    Fixes: 2567168dc4986
    MFC after: 1 week
    Reviewed-by: markj, ngie
    Pull-Request: https://github.com/freebsd/freebsd-src/pull/2088
    (cherry picked from commit 69042706604752f42072f422671a72c49343ac45)

 usr.sbin/syslogd/syslogd.c             |  2 +-
 usr.sbin/syslogd/tests/syslogd_test.sh | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
Comment 4 Enji Cooper freebsd_committer freebsd_triage 2026-10-10 22:01:48 UTC
The proposed change doesn't apply to stable/14.