Skip to content

Commit 9bdf02f

Browse files
committed
Add documentation for ExecPaths in systemd units
In systemd unit files, I had missed some paths to commands that are potentially executed in response to events. These commands are arbitrary and configurable in clamd.conf and freshclam.conf. Each of these options invoke an appropriate path to a configured executable when - for example - a scan is complete or signature update fails. In order for these executables to run, systemd should allow it. It is necessary to add these paths to `ExecPaths` in systemd service unit files. This change adds comments instructing users and administrators how to do that and generally helps make sense of the defaults. - Plus some formatting changes
1 parent bb44904 commit 9bdf02f

5 files changed

+42
-4
lines changed

Diff for: clamd/clamav-daemon.service.in

+14-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,25 @@ ExecStart=@prefix@/sbin/clamd --foreground=true
1111
# Reload the database
1212
ExecReload=/bin/kill -USR2 $MAINPID
1313
TimeoutStartSec=420
14-
# Security options
15-
# Remove ProtectSystem, ProtectHome, and ReadWritePaths..
16-
# if you want clamav to be able to remove infected files.
14+
15+
##
16+
## Security Hardening Options
17+
##
18+
19+
# Remove `ProtectSystem`, `ProtectHome`, and `ReadWritePaths`
20+
# if you want ClamAV to be able to remove infected files.
1721
ProtectSystem=strict
1822
ProtectHome=read-only
1923
ReadWritePaths=/var/log/
24+
2025
NoExecPaths=/
26+
# If you want to run commands or execute binaries on event,
27+
# append the full path of the binary or executable to `ExecPaths`
28+
# Commonly, this is used for `VirusEvent` in clamd.conf or `VirusAction`
29+
# in clamav-milter.conf.The binaries must be space separated like so:
30+
;ExecPaths=@prefix@/sbin/clamd /bin/kill /usr/local/bin/send_sms /usr/local/bin/my_infected_message_handler
2131
ExecPaths=@prefix@/sbin/clamd /bin/kill
32+
2233
ProtectClock=yes
2334
ProtectKernelTunables=yes
2435
ProtectKernelModules=yes

Diff for: etc/clamav-milter.conf.sample

+3
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ Example
202202
# Note #2: the process is invoked in the context of clamav-milter
203203
# Note #3: clamav-milter will wait for the process to exit. Be quick or fork to
204204
# avoid unnecessary delays in email delivery
205+
# Note #4: When using systemd to manage ClamAv daemon, ensure that the full path to
206+
# the VirusAction target binary / executable is listed in ExecPaths in the service
207+
# file clamav-daemon.service in order for the process to be able to execute it.
205208
# Default: disabled
206209
#VirusAction /usr/local/bin/my_infected_message_handler
207210

Diff for: etc/clamd.conf.sample

+3
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ Example
213213
# be replaced with the virus name and %f will be replaced with the file name.
214214
# Additionally, two environment variables will be defined: $CLAM_VIRUSEVENT_FILENAME
215215
# and $CLAM_VIRUSEVENT_VIRUSNAME.
216+
# Note: When using systemd to manage ClamAV daemon, ensure that the full path to
217+
# the VirusEvent target binary / executable is listed in ExecPaths in the service
218+
# file clamav-daemon.service in order for the process to be able to execute it.
216219
# Default: no
217220
#VirusEvent /usr/local/bin/send_sms 123456789 "VIRUS ALERT: %v in %f"
218221

Diff for: etc/freshclam.conf.sample

+12
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,27 @@ DatabaseMirror database.clamav.net
151151

152152
# Run command after successful database update.
153153
# Use EXIT_1 to return 1 after successful database update.
154+
# Note: When using systemd to manage FreshClam service, append the
155+
# full path to the OnUpdateExecute target command to `ExecPaths` in the
156+
# service file clamav-freshclam.service in order for the process to
157+
# be able to execute it.
154158
# Default: disabled
155159
#OnUpdateExecute command
156160

157161
# Run command when database update process fails.
162+
# Note: When using systemd to manage FreshClam service, append the
163+
# full path to the OnErrorExecute target command to `ExecPaths` in the
164+
# service file clamav-freshclam.service in order for the process to
165+
# be able to execute it.
158166
# Default: disabled
159167
#OnErrorExecute command
160168

161169
# Run command when freshclam reports outdated version.
162170
# In the command string %v will be replaced by the new version number.
171+
# Note: When using systemd to manage FreshClam service, append the
172+
# full path to the OnOutdatedExecute target command to `ExecPaths`
173+
# in the service file clamav-freshclam.service in order for the process to
174+
# be able to execute it.
163175
# Default: disabled
164176
#OnOutdatedExecute command
165177

Diff for: freshclam/clamav-freshclam.service.in

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,24 @@ After=network-online.target
88

99
[Service]
1010
ExecStart=@prefix@/bin/freshclam -d --foreground=true
11-
# Security Options
11+
12+
##
13+
## Security Hardening Options
14+
##
1215
ProtectSystem=full
1316
ProtectHome=tmpfs
1417
ProtectClock=yes
1518
ProtectKernelTunables=yes
1619
ProtectKernelModules=yes
1720
ProtectKernelLogs=yes
1821
ProtectControlGroups=yes
22+
1923
NoExecPaths=/
24+
# If you want to run commands on event, append the full path of the command or
25+
# executable to `ExecPaths`. Commonly, this is used for `OnUpdateExecute`,
26+
# `OnErrorExecute`, and `OnOutdatedExecute` options in freshclam.conf. Make sure
27+
# there is only one `ExecPaths` option. The binaries must be space separated like so:
28+
;ExecPaths=@prefix@/sbin/freshclam /usr/local/bin/OnOutdated.sh /usr/local/bin/OnErrorExecute.sh
2029
ExecPaths=@prefix@/bin/freshclam
2130

2231
[Install]

0 commit comments

Comments
 (0)