Optionally refresh apt package lists before each report
CI / tests (Python 3.10) (pull_request) Successful in 15s
CI / tests (Python 3.11) (pull_request) Successful in 15s
CI / tests (Python 3.12) (pull_request) Successful in 15s
CI / tests (Python 3.13) (pull_request) Successful in 15s
CI / lint (pull_request) Successful in 3s

The agent's dist-upgrade simulation already finds new-ABI kernels and
security updates, but only once apt's lists know about them. Debian
doesn't refresh lists by default, so a kernel security release could
stay invisible until someone ran apt update.

install.sh --with-apt-update adds a marker that enables
kernelwatch-apt-update.service, a sandboxed root oneshot the agent pulls
in before each report. Failures (no network, apt lock held) are ignored
so the report still goes out. deploy.sh now ships the unit; a test keeps
deploy.sh's file list in sync with what install.sh uses.

Agent 0.3.2, server 0.3.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-10-17 17:13:55 -04:00
1 parent e9c8f889c7
commit f35cc007f5
8 files changed
+104 -11

No files matched your search

+20 -1
View File
@@ -53,7 +53,7 @@ How the agent works it out:
two capabilities needrestart needs, and list-only mode, so it never restarts
anything. It writes its results to `/run/kernelwatch/needrestart`, and the
unprivileged agent unit runs it just before each report and reads the file.
Neither unit has both root and network access. Fix it on the host:
The agent never runs as root, and needrestart never gets network access. Fix it on the host:
`sudo needrestart -r a` (or restart the listed services), and the next report
clears it.
- **Agent version**: each report includes it. Hosts running an older agent
@@ -63,6 +63,14 @@ How the agent works it out:
no locks and writes no cache files. `dist-upgrade` is used so that new-ABI kernel
packages pulled in by the meta-package show up. Lines whose origin contains
`-security` count as security updates.
- **Fresh package lists**: the simulation only knows what apt's package lists
say, and the agent can't refresh them itself. Ubuntu refreshes them about once
a day. Debian doesn't by default unless `unattended-upgrades` is set up, so a
new kernel or security update can stay invisible until someone runs
`apt update`. Install with `--with-apt-update` and
`kernelwatch-apt-update.service` runs `apt-get update` just before each
report, so updates show up within the hour. Either way, lists older than
`apt_stale_after_hours` put the host in `update`.
- **Phased updates** (Ubuntu only): Ubuntu rolls some updates out gradually and
holds them back from a share of machines at first. apt doesn't offer these to
the host yet, so they aren't counted as available updates. They appear as
@@ -305,6 +313,12 @@ needs this; Ubuntu already has needrestart). It installs needrestart if
missing and sets it to *list* services after apt upgrades instead of asking
interactively. Delete `/etc/needrestart/conf.d/kernelwatch.conf` to undo that.
Add `--with-apt-update` to refresh apt's package lists before each report
(recommended on Debian, see above). It's the same as running `apt update`
hourly: lists only, nothing is installed. If apt is busy, the refresh is
skipped and the report goes ahead. `--without-apt-update` turns it off;
re-running the installer with neither keeps the current setting.
Useful on a host:
```sh
@@ -333,6 +347,7 @@ agent/deploy.sh web01 # upgrade one
agent/deploy.sh --rotate web01 # new token, reinstall
agent/deploy.sh --dry-run # show the plan
agent/deploy.sh -- --with-needrestart # pass options through to install.sh
agent/deploy.sh -- --with-apt-update # refresh package lists before each report
```
For each host it copies the agent into a private temp directory and runs
@@ -374,6 +389,10 @@ sudo kernelwatch list-users
capability set of just `CAP_SYS_PTRACE` + `CAP_DAC_READ_SEARCH` (to read other
processes' memory maps), a read-only filesystem except `/run/kernelwatch`,
and `-r l` (list, never restart).
- **apt-get update** (with `--with-apt-update`) runs as root with network
access, like apt's own `apt-daily.service`, but sandboxed: no access to home
directories, devices or kernel settings. apt drops to its `_apt` user for the
downloads, and nothing gets installed.
- **The agent** runs as a throwaway unprivileged user (`DynamicUser=yes`) with
no capabilities, a read-only filesystem view and a syscall filter. The token
reaches it through `LoadCredential=` and goes to curl on stdin, so it never