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
@@ -126,6 +126,167 @@ back to a no-op if it is missing, but without `apt-utils` or `python3` the cron
|
||||
job fails every 10 minutes with the reason only visible in
|
||||
`/var/log/update_local_repo.log`.
|
||||
|
||||
## Updates
|
||||
|
||||
The Fedora clients update through PackageKit: `pkcon refresh`, `pkcon update`, and
|
||||
an offline update that is downloaded in the background and applied at the next
|
||||
boot. Debian does the same, with one addition (a polkit rule) and one rewrite (the
|
||||
scheduler).
|
||||
|
||||
### Updating without a password
|
||||
|
||||
A user in the `sudo` group can refresh and install updates from the desktop
|
||||
without being asked for a password, as on Fedora. This needs a polkit rule,
|
||||
because Debian's shipped policy does not cover it:
|
||||
|
||||
- `/usr/share/polkit-1/rules.d/org.freedesktop.packagekit.rules` grants passwordless
|
||||
access only to `upgrade-system` and `trigger-offline-update`.
|
||||
- `system-sources-refresh` (what `pkcon refresh` uses) and `system-update` (what
|
||||
`pkcon update` uses) are `auth_admin`, so a desktop user *is* prompted.
|
||||
- `/usr/share/polkit-1/rules.d/50-default.rules` makes `unix-group:sudo` the admin
|
||||
identity, so the prompt is for the user's own password.
|
||||
|
||||
`update_local_repo.py` therefore installs
|
||||
`/etc/polkit-1/rules.d/60-vdi-no-password-updates.rules`, allowing
|
||||
`system-sources-refresh`, `system-update` and `package-install` for members of
|
||||
group `sudo`. Deliberately **not** granted: `package-remove`,
|
||||
`package-reinstall`, `package-install-untrusted` - a normal user still cannot
|
||||
remove packages or install an untrusted one without a password.
|
||||
|
||||
Measured with `pkcheck`: with the rule, `pkcheck --action-id
|
||||
org.freedesktop.packagekit.system-sources-refresh` returns 0 (authorised); with the
|
||||
rule removed it returns 2 (authentication required). The test harness asserts both
|
||||
directions, because a check that cannot fail proves nothing.
|
||||
|
||||
One thing that did *not* work and is worth knowing: the rule was first written
|
||||
with `subject.local == true`, to limit it to seats physically in front of the
|
||||
machine. That clause never matches in this environment - the rule silently did
|
||||
nothing and users were still prompted - so it was removed and the reasoning is
|
||||
recorded in the source. The consequence is that a `sudo`-group user on a remote
|
||||
session can also update without a password, which is the same trust level that
|
||||
group already has through `sudo`.
|
||||
|
||||
Root never needs a password either, which is what makes the cron job and the
|
||||
timer work.
|
||||
|
||||
### The offline update
|
||||
|
||||
Debian 13's PackageKit 1.3.1 supports the same offline-update mechanism the Fedora
|
||||
clients use, so the approach ports directly:
|
||||
|
||||
1. `pkcon refresh force` - refresh the package index.
|
||||
2. `pkcon update --only-download` - download the updates without installing.
|
||||
3. `pkcon offline-get-prepared` - confirm a payload is ready.
|
||||
4. `pkcon offline-trigger` - arm the update.
|
||||
|
||||
Step 4 creates `/system-update` as a symlink to
|
||||
`/var/lib/PackageKit/prepared-update`, and systemd's
|
||||
`packagekit-offline-update.service` (wired into `system-update.target`, shipped by
|
||||
the `packagekit` package) applies it on the next boot. The desktop is never
|
||||
sitting on a half-applied transaction.
|
||||
|
||||
Step 3 is load-bearing, not ceremony: `offline-get-prepared` exits **4** when
|
||||
nothing is prepared, and triggering anyway fails and can leave a dangling
|
||||
`/system-update` symlink, which breaks the next boot. The `if` is what prevents
|
||||
that.
|
||||
|
||||
Two details that differ from the Fedora script:
|
||||
|
||||
- `pkcon` exit code **5** means "no packages to update", which is the normal
|
||||
answer on a patched machine. It is not a failure and is not logged as one.
|
||||
- The download runs under `systemd-inhibit --what=sleep:idle --mode=block` so the
|
||||
machine does not suspend mid-download. No `DISPLAY` is needed, which matters
|
||||
because the timer runs outside any session.
|
||||
|
||||
### Who runs it, and when
|
||||
|
||||
| | Fedora | Debian |
|
||||
|---|---|---|
|
||||
| Citrix repo refresh | cron, 10 min | cron, 10 min |
|
||||
| offline update | `@reboot` via `/root/auto_update.sh` | `vdi-offline-update.timer`, 6 h + boot, throttled |
|
||||
|
||||
On Debian the offline update is a systemd timer (`vdi-offline-update.timer`,
|
||||
`OnBootSec=15min`, `OnUnitActiveSec=6h`, `Persistent=true`,
|
||||
`RandomizedDelaySec=15min`) running `/usr/local/sbin/vdi-offline-update`. systemd
|
||||
owns the scheduling, output goes to the journal, and a failure is visible in
|
||||
`systemctl status vdi-offline-update.service`. The script also keeps a 6-hour
|
||||
throttle stamp at `/var/lib/vdi-offline-update.last` so a manual run and the timer
|
||||
cannot pile up.
|
||||
|
||||
`/root/auto_update.sh` is kept for parity with Fedora and simply execs
|
||||
`/usr/local/sbin/vdi-offline-update`, so there is one implementation rather than
|
||||
two copies of the `pkcon` sequence.
|
||||
|
||||
**Note on scope:** these files are installed by `update_local_repo.py`, not only by
|
||||
the preseed. That means machines already provisioned before this change pick up
|
||||
the polkit rule and the timer on their next 10-minute cron run - the same
|
||||
back-fill approach `configure_kde.py` already uses for the Plasma settings. The
|
||||
preseed additionally enables the timer directly so a fresh install has offline
|
||||
updates from the first boot.
|
||||
|
||||
### Why not `unattended-upgrades`
|
||||
|
||||
Debian's usual answer for automatic updates is `unattended-upgrades`, and it is
|
||||
the wrong instrument here: it *installs* security updates silently while the user
|
||||
is working, which is the thing the offline-update flow exists to avoid, and it
|
||||
does not give a desktop user a no-password update button. It is left uninstalled.
|
||||
`pkgsel/update-policy` is set to `none` in the preseed for the same reason.
|
||||
|
||||
## Building an install ISO
|
||||
|
||||
On Fedora, `ks.cfg` is handed to the installer on a second medium or over the
|
||||
network. Debian's equivalent is to bake `preseed.cfg` into the installation ISO
|
||||
and point the boot menu at it, so the stick is self-contained.
|
||||
|
||||
```
|
||||
apt-get install xorriso
|
||||
./debian/make-iso.sh debian-13.7.0-amd64-netinst.iso vdi-debian.iso
|
||||
```
|
||||
|
||||
The script copies the preseed to `/preseed.cfg` on the image and adds this to
|
||||
every kernel line in every boot menu:
|
||||
|
||||
```
|
||||
auto=true priority=critical preseed/file=/cdrom/preseed.cfg
|
||||
```
|
||||
|
||||
- `auto=true` is an alias for `auto-install/enable`; it delays the locale and
|
||||
keyboard questions so the preseed can answer them.
|
||||
- `priority=critical` is an alias for `debconf/priority`; nothing below critical
|
||||
is asked.
|
||||
- `preseed/file=/cdrom/preseed.cfg` reads the preseed from the ISO itself. The
|
||||
`preseed-md5` checksum parameter is deliberately not used: it must match
|
||||
exactly and breaks the moment the preseed is edited.
|
||||
|
||||
The script verifies its own output instead of trusting `xorriso`'s exit status:
|
||||
the preseed is byte-identical on the image, every kernel line carries the
|
||||
parameters, both El Torito boot images (BIOS and UEFI) are present, and no file
|
||||
from the source ISO is missing. It exits non-zero rather than writing an ISO that
|
||||
would boot to an interactive prompt.
|
||||
|
||||
Two things worth knowing if you modify it:
|
||||
|
||||
- **Every menu file is patched, not a fixed list.** On a Debian netinst the BIOS
|
||||
menu is `isolinux/isolinux.cfg`, which contains only `include menu.cfg` and
|
||||
`default vesamenu.c32`; the entry that actually boots by default is in
|
||||
`isolinux/gtk.cfg` (`label installgui`, `menu default`). Patching only the
|
||||
obvious files leaves the default BIOS entry unpatched and the machine still
|
||||
stops to prompt. The script discovers every `*.cfg` under `/isolinux` and
|
||||
`/boot/grub` and patches the ones with kernel lines.
|
||||
- **The image is not extracted and rebuilt.** `xorriso -as mkisofs` over an
|
||||
extracted tree grows a netinst from 792 MB to 988 MB, because Debian's ISO
|
||||
shares identical file extents between paths and extraction duplicates them all.
|
||||
Instead the original session is copied and only the changed files are mapped
|
||||
over it (`-indev SRC -outdev DST -boot_image any replay -map ...`), which keeps
|
||||
the deduplication and the boot record intact.
|
||||
|
||||
Verified against `debian-13.7.0-amd64-netinst.iso`: 20 of 20 BIOS kernel lines and
|
||||
20 of 20 UEFI kernel lines patched, all 1010 source files present, preseed
|
||||
byte-identical, both boot images intact, output 792 MB.
|
||||
|
||||
The inventory number is still asked for on the console. The preseed cannot guess
|
||||
it, and it has to be read from a human.
|
||||
|
||||
## configure_kde.py
|
||||
|
||||
Writes KWin's `[Libinput][Defaults][Touchpad]` group (so it applies to every
|
||||
|
||||
Reference in new issue
Block a user