Skip to content

Commit 95ff65c

Browse files
committed
feat(systemd): Enhance security with sandboxing/capability restrictions
Added sandboxing options, restricted file system access, and granted capabilities for real-time scheduling and privileged ports. Improves security and tightens service isolation. Signed-off-by: Sven Sager <s.sager@kunbus.com>
1 parent 11406ef commit 95ff65c

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

systemd/pimodbus-master.service

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,18 @@ User=revpi-modbus
1616
Group=revpi-modbus
1717
SupplementaryGroups=dialout picontrol
1818

19+
# Sandboxing options
20+
ProtectSystem=strict
21+
ProtectControlGroups=yes
22+
ProtectKernelModules=yes
23+
ProtectKernelTunables=yes
24+
25+
# Restrict file system access to the following directories
26+
InaccessiblePaths=/boot /home /root
27+
28+
# Allow realtime scheduling
29+
LimitRTPRIO=99
30+
LimitRTTIME=infinity
31+
1932
[Install]
2033
WantedBy=multi-user.target

systemd/pimodbus-slave.service

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,22 @@ User=revpi-modbus
1616
Group=revpi-modbus
1717
SupplementaryGroups=dialout picontrol
1818

19+
# Sandboxing options
20+
ProtectSystem=strict
21+
ProtectControlGroups=yes
22+
ProtectKernelModules=yes
23+
ProtectKernelTunables=yes
24+
25+
# Restrict file system access to the following directories
26+
InaccessiblePaths=/boot /home /root
27+
28+
# Allow realtime scheduling
29+
LimitRTPRIO=99
30+
LimitRTTIME=infinity
31+
32+
# Allow bind to ports < 1024
33+
AmbientCapabilities=CAP_NET_BIND_SERVICE
34+
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
35+
1936
[Install]
2037
WantedBy=multi-user.target

0 commit comments

Comments
 (0)