Fix apt refresh on apt 2.7+ and check the security repository #30

Merged
patrick merged 3 commits from feat/security-repo-check into main 2026-11-01 20:08:36 +00:00
Owner

Problem

kernelwatch-apt-update.service has been failing on every run on hosts with
apt 2.7+ (Ubuntu 24.04+, Debian 13): 10 of 13 hosts.

E: seteuid 42 failed - seteuid (1: Operation not permitted)
E: Method http has died unexpectedly!

User=root together with NoNewPrivileges=yes and any of the seccomp-based
sandbox options stops apt dropping to its _apt user. Each one alone is fine
(bisected with systemd-run on ares). The dashboard never showed it:

  • the - prefix on ExecStart swallowed the exit code 100
  • apt touches lists/partial even when the update fails, and the agent counted
    that as a refresh

On Ubuntu, apt-daily refreshed the lists anyway. argus (Debian 13) relies on
this unit alone, and its trixie-security list was 88h old while the dashboard
showed fresh lists.

Separately, security_count is only meaningful if apt actually has the
release's security suite. A host without it, or whose apt can't fetch it, shows
"0 security updates" forever.

Changes

  1. Fix the unit. Drop User=root (root is the default). A failed update
    now fails the unit; the report still goes out because the agent only
    Wants= it. On success the unit touches update-success-stamp.
  2. Package list age trusts success stamps only. lists/partial is used
    only when a host has no success stamp at all.
  3. Security repository check (agent 0.9.0).
    • The agent finds apt's list for <codename>-security by its
      Suite:/Codename: field (file names vary by mirror) and reports the
      age of its Date:.
    • The host goes to update if the list is missing, or older than
      security_repo_stale_after_days (default 7, 0 disables) while the other
      lists refresh.
    • Releases past end of support and ESM suites are skipped.
    • New "Security repository" row on the host page.

Ran the collector by hand on all 13 hosts: each found the right suite,
including zeus's mirror+file: source.

Deploying

Update the server, then run agent/deploy.sh for all hosts; it reinstalls the
unit. Then systemctl show -p ExecMainStatus kernelwatch-apt-update should
print 0 on every host.

🤖 Generated with Claude Code

## Problem `kernelwatch-apt-update.service` has been failing on every run on hosts with apt 2.7+ (Ubuntu 24.04+, Debian 13): 10 of 13 hosts. E: seteuid 42 failed - seteuid (1: Operation not permitted) E: Method http has died unexpectedly! `User=root` together with `NoNewPrivileges=yes` and any of the seccomp-based sandbox options stops apt dropping to its `_apt` user. Each one alone is fine (bisected with `systemd-run` on ares). The dashboard never showed it: - the `-` prefix on `ExecStart` swallowed the exit code 100 - apt touches `lists/partial` even when the update fails, and the agent counted that as a refresh On Ubuntu, `apt-daily` refreshed the lists anyway. argus (Debian 13) relies on this unit alone, and its `trixie-security` list was 88h old while the dashboard showed fresh lists. Separately, `security_count` is only meaningful if apt actually has the release's security suite. A host without it, or whose apt can't fetch it, shows "0 security updates" forever. ## Changes 1. **Fix the unit.** Drop `User=root` (root is the default). A failed update now fails the unit; the report still goes out because the agent only `Wants=` it. On success the unit touches `update-success-stamp`. 2. **Package list age trusts success stamps only.** `lists/partial` is used only when a host has no success stamp at all. 3. **Security repository check (agent 0.9.0).** - The agent finds apt's list for `<codename>-security` by its `Suite:`/`Codename:` field (file names vary by mirror) and reports the age of its `Date:`. - The host goes to `update` if the list is missing, or older than `security_repo_stale_after_days` (default 7, 0 disables) while the other lists refresh. - Releases past end of support and ESM suites are skipped. - New "Security repository" row on the host page. Ran the collector by hand on all 13 hosts: each found the right suite, including zeus's `mirror+file:` source. ## Deploying Update the server, then run `agent/deploy.sh` for all hosts; it reinstalls the unit. Then `systemctl show -p ExecMainStatus kernelwatch-apt-update` should print 0 on every host. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick added 3 commits 2026-11-01 20:07:12 +00:00
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>
apt touches /var/lib/apt/lists/partial on every update attempt,
including ones that fail, and the agent took the newest of it and the
two success stamps. So a host whose apt update failed hourly reported
lists an hour old. Use the success stamps (update-success-stamp,
update-stamp) and fall back to lists/partial only when neither exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check that the release's security repository is configured and fresh
CI / tests (Python 3.10) (pull_request) Successful in 36s
CI / tests (Python 3.11) (pull_request) Successful in 36s
CI / tests (Python 3.12) (pull_request) Successful in 37s
CI / tests (Python 3.13) (pull_request) Successful in 37s
CI / lint (pull_request) Successful in 4s
c9912d5fbc
security_count is only meaningful if apt has the release's security
suite. A host missing it from its sources shows 0 security updates
forever, and one whose apt can't fetch it (expired key, wrong URL after
a release upgrade, a mirror that fell behind) keeps the last copy while
the update stamps and other lists move on, so neither the simulation nor
the package list age notices.

The agent (0.9.0) now finds apt's list for <codename>-security by its
Suite: (Ubuntu) or Codename: (Debian) field, since file names depend on
the mirror (mirror+file: sources, several mirrors), and reports
security_repo_suite and security_repo_age_seconds from its Date:, the
newest copy winning. The server puts the host in update when there's no
such list, or when it's older than security_repo_stale_after_days
(default 7) while the package lists are otherwise fresh; if all of
them are old, the existing "package lists N days old" reason covers
it. Releases past the end of support are skipped: their suite has
stopped publishing, and support.check already says so. ESM suites
publish too rarely to judge by date and aren't checked.

The host page gets a "Security repository" row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
patrick merged commit ad310a4948 into main 2026-11-01 20:08:36 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: patrick/kernel-automation#30