Files
kernel-automation/agent/kernelwatch-livepatch.service
patrickandClaude Sonnet 5.5 b59336d7e2
CI / tests (Python 3.10) (pull_request) Successful in 22s
CI / tests (Python 3.11) (pull_request) Successful in 22s
CI / tests (Python 3.12) (pull_request) Successful in 21s
CI / tests (Python 3.13) (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 2s
Collect Ubuntu Livepatch status in the agent
kernelwatch-livepatch.service runs canonical-livepatch as root with no
network and a read-only filesystem, and a small python3 helper keeps the
running kernel's state, check state, support, end-of-support date and fix
count in /run/kernelwatch/livepatch. The agent (0.4.0) reads that file the
way it reads needrestart's and never runs the snap itself.

NoNewPrivileges=yes can't be used: snap-confine fails under it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 21:37:42 -04:00

31 lines
1.3 KiB
Desktop File

[Unit]
Description=Read Ubuntu Livepatch status (for kernelwatch)
# Pulled in by kernelwatch-agent.service before each report. Skipped cleanly on
# hosts without the Livepatch snap (or python3); the dashboard then treats a
# pending kernel reboot as it always did.
ConditionPathExists=/snap/bin/canonical-livepatch
ConditionPathExists=/usr/bin/python3
[Service]
Type=oneshot
# `canonical-livepatch status` needs root and a snap cgroup, so it can't run in
# the agent's unprivileged unit. The helper keeps only the running kernel's
# fields. If Livepatch isn't enabled or fails, no file is written and the agent
# reports nothing for it.
ExecStart=/bin/sh -c '/snap/bin/canonical-livepatch status --format json | /usr/bin/python3 -I /usr/local/sbin/kernelwatch-livepatch > /run/kernelwatch/livepatch.new && mv /run/kernelwatch/livepatch.new /run/kernelwatch/livepatch || { rm -f /run/kernelwatch/livepatch.new; exit 1; }'
RuntimeDirectory=kernelwatch
RuntimeDirectoryMode=0755
RuntimeDirectoryPreserve=yes
UMask=0022
TimeoutStartSec=2min
# Root, no network. Snap's confinement (setuid snap-confine, mount namespaces)
# rules out NoNewPrivileges, a capability bound, RestrictNamespaces and a
# syscall filter, so the sandbox is limited to a read-only filesystem and no
# network.
User=root
PrivateNetwork=yes
ProtectSystem=strict
ProtectHome=read-only
PrivateTmp=yes