Fix kernelwatch-apt-update failing on apt 2.7+
With User=root, NoNewPrivileges=yes and any seccomp-based sandbox option together, apt 2.7+ (Ubuntu 24.04+, Debian 13) can't drop to _apt: E: seteuid 42 failed - seteuid (1: Operation not permitted) E: Method http has died unexpectedly! so apt-get update exited 100 on every run on 10 of 13 hosts. The '-' prefix hid it, and apt touches lists/partial even when it fails, so the agent's list age looked fresh. Only hosts with older apt (22.04, Debian 12) refreshed. On Ubuntu apt-daily kept the lists fresh regardless; a Debian 13 host relying on this unit alone had lists three days old. Root is the default, so drop User=root. Let a failed update fail the unit (the agent only Wants= it, so the report still goes), and touch /var/lib/apt/periodic/update-success-stamp, the stamp Ubuntu writes after each successful apt update, only when it succeeds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
233645c738
commit
195fd035e0
2 files changed
+26
-6
No files matched your search
@@ -10,16 +10,25 @@ 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) mustn't stop the report; the
|
||||
# dashboard flags lists that stay old.
|
||||
ExecStart=-/usr/bin/apt-get -q update
|
||||
# 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'
|
||||
TimeoutStartSec=5min
|
||||
Nice=10
|
||||
IOSchedulingClass=idle
|
||||
|
||||
# apt needs root to write /var/lib/apt and drops to _apt for downloads, so this
|
||||
# keeps root but loses everything apt update doesn't touch.
|
||||
User=root
|
||||
# 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
|
||||
|
||||
Reference in new issue
Block a user