[Unit] Description=Refresh apt package lists (for kernelwatch) # Pulled in by kernelwatch-agent.service before each report, so updates show up # within the hour instead of whenever apt-daily next refreshes the lists (on # Debian, by default, never). Enabled by `install.sh --with-apt-update`. ConditionPathExists=/etc/kernelwatch/apt-update Wants=network-online.target After=network-online.target [Service] Type=oneshot # Same as `apt-get update`: downloads lists, installs nothing. A failure (no # network, lock held by an admin's apt run) fails this unit but not the report, # since kernelwatch-agent.service only Wants= it. The stamp then stops moving # and the dashboard flags the lists as old. ExecStart=/usr/bin/apt-get -q update # Reached only when apt succeeded. It's the stamp Ubuntu's update-notifier hook # writes after every successful apt update, and the agent reads it as the lists' # age; Debian has nothing else that writes it. lists/partial, the agent's last # resort, changes even when the update fails. ExecStartPost=/bin/sh -c 'mkdir -p /var/lib/apt/periodic && touch /var/lib/apt/periodic/update-success-stamp' # Records how the run ended, success or not, so the agent can report failures, # which are otherwise silent while apt-daily keeps the lists fresh. ExecStopPost=/usr/local/sbin/kernelwatch-unit-result apt-update RuntimeDirectory=kernelwatch RuntimeDirectoryMode=0755 RuntimeDirectoryPreserve=yes UMask=0022 TimeoutStartSec=5min Nice=10 IOSchedulingClass=idle # apt needs root to write /var/lib/apt and drops to _apt for downloads, so this # runs as root (the default) but loses everything apt update doesn't touch. # Don't add User=root: with it, NoNewPrivileges and any of the seccomp-based # options below, apt 2.7+ (Ubuntu 24.04, Debian 13) can't switch to _apt # ("seteuid 42 failed - seteuid (1: Operation not permitted)") and every update # fails. NoNewPrivileges=yes ProtectHome=yes PrivateTmp=yes PrivateDevices=yes ProtectKernelTunables=yes ProtectKernelModules=yes ProtectKernelLogs=yes ProtectControlGroups=yes ProtectClock=yes ProtectHostname=yes RestrictNamespaces=yes RestrictRealtime=yes LockPersonality=yes RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK SystemCallArchitectures=native