Debian: passwordless updates, offline updates, and install ISO builder
Ports the update behaviour of the Fedora clients to Debian, and adds the Debian equivalent of putting ks.cfg on the installation medium. Updates ------- Debian's shipped polkit policy only lets a sudo-group user trigger upgrade-system and trigger-offline-update without a password. The actions pkcon refresh and pkcon update actually use (system-sources-refresh and system-update) are auth_admin, so a desktop user was prompted - a behavioural difference from Fedora. update_local_repo.py now installs /etc/polkit-1/rules.d/60-vdi-no-password-updates.rules granting exactly those two plus package-install to group sudo. package-remove, package-reinstall and package-install-untrusted stay auth_admin. The offline update itself ports unchanged: Debian 13 PackageKit 1.3.1 supports offline-get-prepared and offline-trigger, and packagekit-offline-update.service is wired into system-update.target. Scheduling moves from an @reboot cron line to vdi-offline-update.timer (6h, Persistent), with /root/auto_update.sh delegating to the same script so there is one implementation instead of two. Both are installed by update_local_repo.py, not only by the preseed, so already-provisioned machines pick them up on their next 10-minute cron run. install ISO ----------- debian/make-iso.sh bakes preseed.cfg into a Debian netinst ISO and adds auto=true priority=critical preseed/file=/cdrom/preseed.cfg to every boot menu entry, then verifies its own output. Measured, not assumed --------------------- * subject.local == true never matches in this environment: pkcheck returns 2 with the clause and 0 without it, same sudo-group user. It was in the first version of the rule and is removed; the reasoning is in the source. * pkcon exits 5 for "no packages to update", which is the normal answer on a patched box and was being logged as a download failure. Fixed. * offline-get-prepared exits 4 when nothing is prepared, so the Fedora "if ... offline-trigger" guard is load-bearing - triggering anyway can leave a dangling /system-update symlink that breaks the next boot. * Extracting a netinst and rebuilding with "xorriso -as mkisofs" grows it 792MB -> 988MB because Debian shares identical file extents; replaying the original session with -map keeps dedup and the boot record. * A hardcoded menu list misses isolinux/gtk.cfg, where the BIOS *default* entry lives, so the machine still prompted. Menus are discovered now. Tests: 90 passed, 0 failed, 2 skipped. T17 asserts the polkit decision in both directions (authorised with the rule, prompted without it), because a check that cannot fail proves nothing.
This commit is contained in:
1 parent
4f1a4530aa
commit
15d65183dc
6 files changed
+1335
-2
No files matched your search
Vendored
+115
-1
@@ -35,7 +35,11 @@ not a pass**, and the summary says so.
|
||||
| T12 | GPG `signed-by` path (design check; skips without a signing tool) |
|
||||
| T13 | Fedora path unregressed: tracked files identical, `sync_fedora` command sequence identical |
|
||||
| T14 | `bash -n` on every shell script the port adds |
|
||||
| T15 | Nothing was left behind: no source file, no cached indexes, no installs, no `__pycache__` |
|
||||
| T16 | polkit rule installed, mode 644, correct actions, no over-grant, balanced, idempotent |
|
||||
| T17 | A real sudo-group user is authorised **without a password** (pkcheck), with a control |
|
||||
| T18 | Offline-update script/units: bash -n, `systemd-analyze verify`, timer enabled, throttle, no dangling `/system-update` |
|
||||
| T19 | The preseed still generates a working `/root/vdi-post.sh` that delegates updates |
|
||||
| T15 | Nothing was left behind: no source file, no cached indexes, no installs, no `__pycache__`, no polkit rule or unit residue |
|
||||
|
||||
### The repo build it tests
|
||||
|
||||
@@ -97,6 +101,22 @@ Being explicit matters more than the green summary.
|
||||
strong evidence but it is not an execution test. A Fedora 44 WSL distro exists
|
||||
on the development machine and was not used.
|
||||
|
||||
8. **A real desktop session.** T17 proves polkit authorises a sudo-group user
|
||||
without a password, which is the actual requirement, but it does not open a
|
||||
GUI and click an update. `pkcon refresh` from a live Plasma session, with an
|
||||
authentication agent running, is not exercised.
|
||||
|
||||
9. **An actual offline update reboot.** T18 checks that `/system-update` is armed
|
||||
with an existing target and that `systemd-analyze verify` is clean. It does not
|
||||
reboot and let `packagekit-offline-update.service` apply anything. Whether the
|
||||
update actually installs at the next boot is untested - only that it was
|
||||
correctly prepared.
|
||||
|
||||
10. **`package-install` end to end.** The polkit rule also grants
|
||||
`package-install`, but T17 only checks `system-sources-refresh` (the action
|
||||
`pkcon refresh` uses) and that `package-remove` is *not* granted. Installing a
|
||||
package from a desktop session without a password is not exercised.
|
||||
|
||||
## Two spec'd checks that cannot fail, and what replaced them
|
||||
|
||||
This is the most important thing in this file. Two checks that look like tests
|
||||
@@ -208,6 +228,100 @@ The 256 MB file is copied into a temp directory, which is fast on native
|
||||
filesystem and slow off `/mnt/c`. If `/tmp` is small, set `TMPDIR` to somewhere
|
||||
with ~600 MB free.
|
||||
|
||||
## T17 is the test that matters, and why it needs a control
|
||||
|
||||
The user's requirement is that a desktop user can update **without an admin
|
||||
password**. Asserting that the rule file contains the right action names proves
|
||||
nothing about whether polkit acts on it - a rule can be syntactically perfect,
|
||||
in the right directory, and still never match (which is exactly what happened
|
||||
during development with a `subject.local == true` clause).
|
||||
|
||||
So T17 asks polkit itself:
|
||||
|
||||
1. Start a process owned by a real member of group `sudo` (`setsid`, so nothing
|
||||
blocks), then `pkcheck --action-id ...system-sources-refresh --process <pid>`
|
||||
as root. Assert **rc=0**.
|
||||
2. **The control:** move the rule away, restart polkit, repeat. Assert **rc=2**
|
||||
(authentication required). Then restore.
|
||||
|
||||
Without step 2 the test cannot fail: a polkit configured to answer YES to
|
||||
everything would also give rc=0. The control is what makes step 1 evidence.
|
||||
|
||||
It also asserts the rule does **not** grant `package-remove`, `package-reinstall`
|
||||
or `package-install-untrusted` - a user who can remove packages without a
|
||||
password can break the machine.
|
||||
|
||||
`pkcheck` is only conclusive because it consults the live polkitd. If polkit is
|
||||
not installed, T16 and T17 **skip** with a reason rather than passing quietly.
|
||||
|
||||
## T18: the dangerous failure mode
|
||||
|
||||
A dangling `/system-update` symlink **fails the next boot**. The offline-update
|
||||
script arms that symlink, so the harness asserts, after every run, that if
|
||||
`/system-update` exists then its `readlink -f` target exists too. It is checked
|
||||
both immediately after the run and again after the forced (stamp=0) run, which
|
||||
is the one most likely to arm it.
|
||||
|
||||
Also asserted, because it is a real behaviour and not a detail:
|
||||
|
||||
- Running the script twice in a row is **throttled** (prints "skipping").
|
||||
- Setting the stamp to `0` defeats the throttle - so it is time-based, not a
|
||||
permanent latch.
|
||||
- `pkcon` exit 5 means "no packages to update" and must not be reported as
|
||||
`download failed`. On an up-to-date box the output must not contain
|
||||
"download failed".
|
||||
|
||||
## T19: why it never executes the generated script
|
||||
|
||||
The preseed's `late_command` writes `/root/vdi-post.sh` and then runs it with
|
||||
`in-target`. That script writes `/etc/hostname`, `/etc/hosts`, `/etc/crontab`
|
||||
and systemd units **by absolute path** - running it here would reconfigure the
|
||||
machine the tests are running on.
|
||||
|
||||
T19 therefore only *regenerates* the script by running the preseed's own
|
||||
`printf` into a temp file, then checks it: `bash -n`, that it delegates to
|
||||
`/usr/local/sbin/vdi-offline-update` instead of duplicating the `pkcon`
|
||||
sequence (comments stripped first, so the explanatory comment does not produce
|
||||
a false positive), and that it still enables `cron` and
|
||||
`vdi-offline-update.timer`.
|
||||
|
||||
Extracting it is fiddly, and the naive approaches are all wrong in ways that
|
||||
look like preseed bugs:
|
||||
|
||||
- A regex that crosses `;` captures the **firefox** `printf` too, which then
|
||||
tries to write `/target/etc/firefox` and fails.
|
||||
- Splitting on `;` breaks, because the payload contains `;` and `>` inside
|
||||
quoted arguments.
|
||||
- Leaving the leading `\` of the first continuation line makes `sh -c` skip the
|
||||
`printf` entirely, producing a "No such file" that looks exactly like a
|
||||
preseed defect.
|
||||
|
||||
The harness anchors on two unambiguous markers instead: the payload's own first
|
||||
argument `'#!/bin/bash'` and the `> /target/root/vdi-post.sh` redirect. It also
|
||||
asserts the captured text does **not** contain `ManagedBookmarks`, so a future
|
||||
change to the preseed fails loudly rather than silently testing the wrong
|
||||
block.
|
||||
|
||||
## Tests that mutate the machine, and how that is undone
|
||||
|
||||
T16-T19 install a polkit rule and systemd units and can arm `/system-update`.
|
||||
T15 asserts no collateral damage, so every mutated path is **backed up before
|
||||
the test and restored at teardown**:
|
||||
|
||||
| Path | How it is handled |
|
||||
|------|-------------------|
|
||||
| `/etc/polkit-1/rules.d/60-vdi-no-password-updates.rules` | backed up, restored |
|
||||
| `/usr/local/sbin/vdi-offline-update` | backed up, restored |
|
||||
| `/etc/systemd/system/vdi-offline-update.{service,timer}` | backed up, restored |
|
||||
| `/var/lib/vdi-offline-update.last` | backed up, restored |
|
||||
| `/system-update` | backed up as a symlink target, restored; **never `rm -rf`** |
|
||||
|
||||
`restore_path` records whether a path was `present`, `absent` or a `symlink`
|
||||
before the run, so "it did not exist and must be gone" is distinguishable from
|
||||
"the backup failed". For an absent path it removes only a regular file or
|
||||
symlink - it never recurses into a directory. The same restores run in the
|
||||
`EXIT` trap, so an aborted run still cleans up.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Debian 13 (trixie), root.
|
||||
|
||||
Reference in new issue
Block a user