]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fstrim: Add hardening settings to fstrim.service
authorAndreas Henriksson <andreas@fatal.se>
Thu, 22 Nov 2018 10:13:58 +0000 (11:13 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 22 Nov 2018 10:13:58 +0000 (11:13 +0100)
This limits what the fstrim process has access to when it runs.

PrivateUsers can't be enabled because of:
"If this mode is enabled, all unit processes are run without privileges
in the host user namespace[...]"

Further improving this with additional option or making
things even tighter is most likely possible.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/fstrim.service.in

index fb5a831ff55184787ab22dc590b2549fd642a96f..d58accd7f4a67b3f33b2700392ab58fac9ed77a1 100644 (file)
@@ -5,3 +5,13 @@ Documentation=man:fstrim(8)
 [Service]
 Type=oneshot
 ExecStart=@sbindir@/fstrim --fstab --verbose
+ProtectSystem=strict
+ProtectHome=yes
+PrivateDevices=no
+PrivateNetwork=yes
+PrivateUsers=no
+ProtectKernelTunables=yes
+ProtectKernelModules=yes
+ProtectControlGroups=yes
+MemoryDenyWriteExecute=yes
+SystemCallFilter=@default @file-system @basic-io @system-service