Skip to content

Commit e19312d

Browse files
committed
Document and handle include ordering for stop-processing
Stop-processing block prefixes (!!, ++, ::) can only suppress rules that follow in the parsed order. A snippet in /etc/syslog.d/ cannot gate rules that were already parsed from the main config file above the include line. Fix this by moving the include directive in the shipped syslog.conf to sit before the general catch-all rules, so snippets are evaluated first and their stop-blocks take effect. Document the ordering constraint in two places in syslog.conf(5): in the include description, where the interaction is explained and the shipped file's structure is called out; and in the Stop Processing example section, where a direct note warns users who place stop-blocks in syslog.d/ snippets. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent 2ae1a49 commit e19312d

2 files changed

Lines changed: 45 additions & 8 deletions

File tree

man/syslog.conf.5

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,28 @@ The
390390
option can be used to include all files with names ending in '.conf' and
391391
not beginning with a '.' contained in the directory following the
392392
keyword. This keyword can only be used in the first level configuration
393-
file. The included example
393+
file. Included files are parsed in glob order and their rules are
394+
inserted into the rule list at the position of the
395+
.Ql include
396+
line.
397+
.Pp
398+
This ordering matters for stop-processing blocks
399+
.Pq Ql !! , ++ , ::
400+
\&: such a block can only suppress rules that appear
401+
.Em after
402+
it in the parsed list. Rules already processed before the
403+
.Ql include
404+
line are unaffected. For snippets in
405+
.Pa /etc/syslog.d/
406+
to be able to prevent messages from reaching the general catch-all rules
407+
in the main configuration file, the
408+
.Ql include
409+
line must appear
410+
.Em before
411+
those catch-all rules. The shipped
394412
.Pa /etc/syslog.conf
395-
has the following at the end:
413+
is structured accordingly.
414+
.Pp
396415
.Bd -literal -offset indent
397416
#
398417
# Drop your subsystem .conf file in /etc/syslog.d/
@@ -908,6 +927,20 @@ are routed to their own log and nowhere else:
908927
daemon.info /var/log/spamd
909928
!*
910929
.Ed
930+
.Pp
931+
.Sy Note:
932+
stop-processing only suppresses rules that follow the matching rule in
933+
the parsed order.
934+
A stop-block placed in a snippet under
935+
.Pa /etc/syslog.d/
936+
cannot suppress rules already parsed from the main configuration file
937+
above the
938+
.Ql include
939+
line.
940+
Place the
941+
.Ql include
942+
directive before any general catch-all rules so that snippets are
943+
evaluated first.
911944
.Ss Critical
912945
This stores all messages of priority
913946
.Ql crit

syslog.conf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
# First some standard log files. Log by facility.
88
#
99
auth,authpriv.* /var/log/auth.log
10-
*.*;auth,authpriv.none -/var/log/syslog
10+
11+
#
12+
# Include all config files in /etc/syslog.d/ before the catch-all rules
13+
# below. This allows snippets to use stop-processing block prefixes
14+
# (!!, ++, ::) to capture messages exclusively, preventing them from
15+
# also being matched by the general rules that follow.
16+
#
17+
include /etc/syslog.d/*.conf
1118

1219
#cron.* /var/log/cron.log
1320
#daemon.* -/var/log/daemon.log
@@ -16,6 +23,8 @@ kern.* -/var/log/kern.log
1623
mail.* -/var/log/mail.log
1724
#user.* -/var/log/user.log
1825

26+
*.*;auth,authpriv.none -/var/log/syslog
27+
1928
#
2029
# Logging for the mail system. Split it up so that
2130
# it is easy to write scripts to parse these files.
@@ -77,8 +86,3 @@ secure_mode 1
7786
#
7887
#rotate_size 1M
7988
#rotate_count 5
80-
81-
#
82-
# Include all config files in /etc/syslog.d/
83-
#
84-
include /etc/syslog.d/*.conf

0 commit comments

Comments
 (0)