[Unit] Description=Check for services needing a restart (for kernelwatch) # Pulled in by kernelwatch-agent.service before each report. Skipped cleanly # when needrestart isn't installed; the dashboard then shows "unknown". ConditionPathExists=/usr/sbin/needrestart [Service] Type=oneshot # -b batch output, -r l list only: never restarts anything. ExecStart=/bin/sh -c 'needrestart -b -r l > /run/kernelwatch/needrestart.new && mv /run/kernelwatch/needrestart.new /run/kernelwatch/needrestart' # Records how the run ended, success or not, so the agent can report failures: # otherwise the results just go missing and the dashboard shows "unknown". ExecStopPost=/usr/local/sbin/kernelwatch-unit-result needrestart RuntimeDirectory=kernelwatch RuntimeDirectoryMode=0755 RuntimeDirectoryPreserve=yes UMask=0022 # Root, but only with what needrestart needs to inspect every process # (/proc//maps of other users) and nothing else. No network at all. User=root CapabilityBoundingSet=CAP_SYS_PTRACE CAP_DAC_READ_SEARCH AmbientCapabilities= NoNewPrivileges=yes PrivateNetwork=yes ProtectSystem=strict ProtectHome=read-only PrivateTmp=yes PrivateDevices=yes ProtectKernelTunables=yes ProtectKernelModules=yes ProtectKernelLogs=yes ProtectControlGroups=yes ProtectClock=yes ProtectHostname=yes RestrictNamespaces=yes RestrictRealtime=yes RestrictSUIDSGID=yes LockPersonality=yes MemoryDenyWriteExecute=yes RestrictAddressFamilies=AF_UNIX SystemCallArchitectures=native SystemCallFilter=@system-service