Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

harden both systemd services without impacting functionality #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions atop-rotate.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,26 @@ Description=Restart atop daemon to rotate logs
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl try-restart atop.service

NoNewPrivileges=yes
CapabilityBoundingSet=
MemoryDenyWriteExecute=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service

PrivateDevices=yes
PrivateUsers=yes
PrivateNetwork=yes

ProtectSystem=strict
ProtectClock=yes
ProtectControlGroups=yes
ProtectHome=true
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes

RestrictAddressFamilies=AF_UNIX
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
31 changes: 30 additions & 1 deletion atop.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,37 @@ EnvironmentFile=/etc/default/atop
ExecStartPre=/bin/sh -c 'test -n "$LOGINTERVAL" -a "$LOGINTERVAL" -eq "$LOGINTERVAL"'
ExecStartPre=/bin/sh -c 'test -n "$LOGGENERATIONS" -a "$LOGGENERATIONS" -eq "$LOGGENERATIONS"'
ExecStart=/bin/sh -c 'exec /usr/bin/atop ${LOGOPTS} -w "${LOGPATH}/atop_$(date +%%Y%%m%%d)" ${LOGINTERVAL}'
ExecStartPost=/usr/bin/find "${LOGPATH}" -name "atop_*" -mtime +${LOGGENERATIONS} -exec rm -v {} \;
ExecStartPost=/usr/bin/find "${LOGPATH}" -name "atop_*" -mtime +${LOGGENERATIONS} -delete
KillSignal=SIGUSR2

NoNewPrivileges=yes
CapabilityBoundingSet=
SystemCallArchitectures=native
SystemCallFilter=@system-service perf_event_open acct

PrivateDevices=yes
PrivateUsers=yes
PrivateNetwork=yes
PrivateTmp=yes

ProtectSystem=strict
ProtectClock=yes
ProtectControlGroups=yes
ProtectHome=true
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes

RestrictAddressFamilies=~AF_INET AF_INET6 AF_PACKET
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes

LogsDirectory=atop
MemoryDenyWriteExecute=yes

CacheDirectory=atop.d
LogsDirectory=atop

[Install]
WantedBy=multi-user.target