Skip to content

Commit a455b82

Browse files
raineszmdosaboy
authored andcommitted
SET-1765 Add check for rsyslog reading syslog file
It is possible to have rsyslog read from /var/log/syslog as an imfile. This is dangerous, because if we are saving logs back to /var/log/syslog this will cause an infinite loop and fill the drive. See for example LP: #2130291 Signed-off-by: Zachary Raines <[email protected]>
1 parent c1d4745 commit a455b82

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
checks:
2+
syslog_in_imfiles:
3+
input:
4+
path: "etc/rsyslog.d/*.conf"
5+
search:
6+
expr: '\s+File="/var/log/syslog"'
7+
8+
conclusions:
9+
syslog_loop_possible:
10+
decision: [syslog_in_imfiles]
11+
raises:
12+
type: SystemWarning
13+
message: >-
14+
rsyslog is configured to read from /var/log/syslog, which may cause a loop
15+
if data is being logged locally to /var/log/syslog. This may happen
16+
with a rule like "*.*;auth,authpriv.none -/var/log/syslog "
17+
which appears in the default configuration file
18+
/etc/rsyslog.d/50-default.conf on ubuntu.
19+
20+
Please make sure not to configure /var/log/syslog
21+
as an input file for rsyslog.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
target-name: rsyslog-read-syslog.yaml
2+
data-root:
3+
files:
4+
etc/rsyslog.d/45-.log: |
5+
module(load="imfile")
6+
7+
# Note StateFile is deprecated in rsyslog 8 but needed for rsyslog 7
8+
9+
input(type="imfile"
10+
File="/var/log/dpkg.log"
11+
StateFile="dpkg.log"
12+
Tag="dpkg.log")
13+
14+
input(type="imfile"
15+
File="/var/log/apt/history.log"
16+
StateFile="history.log"
17+
Tag="history.log")
18+
raised-issues: # none expected
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
data-root:
2+
files:
3+
etc/rsyslog.d/40-rsyslog-imfile.conf: |
4+
module(load="imfile")
5+
6+
# Note StateFile is deprecated in rsyslog 8 but needed for rsyslog 7
7+
8+
input(type="imfile"
9+
File="/var/log/dpkg.log"
10+
StateFile="dpkg.log"
11+
Tag="dpkg.log")
12+
13+
input(type="imfile"
14+
File="/var/log/apt/history.log"
15+
StateFile="history.log"
16+
Tag="history.log")
17+
18+
input(type="imfile"
19+
File="/var/log/syslog"
20+
StateFile="syslog"
21+
Tag="syslog")
22+
raised-issues:
23+
SystemWarning: >-
24+
rsyslog is configured to read from /var/log/syslog, which may cause a loop
25+
if data is being logged locally to /var/log/syslog. This may happen
26+
with a rule like "*.*;auth,authpriv.none -/var/log/syslog "
27+
which appears in the default configuration file
28+
/etc/rsyslog.d/50-default.conf on ubuntu.
29+
30+
Please make sure not to configure /var/log/syslog
31+
as an input file for rsyslog.

0 commit comments

Comments
 (0)