tests: strengthen T17's over-grant check, add T21 modes, cross-file contract in T19

T17's package-remove assertion could not fire: it used a sleeper that had already
exited, so pkcheck returned 127 and the check printed 'info' rather than a
verdict. A negative assertion that cannot fail is worse than none. It now owns a
sleeper (setsid + exec -a, pid confirmed via /proc before pkcheck is trusted),
and 127 or any unexpected code is a FAIL rather than a pass. Verified capable of
failing by injecting package-remove into the rule: pkcheck went rc=2 -> rc=0 and
the assertion went red; the rule was then restored (sha256 unchanged).

T21 asserts both scripts are recorded as 100755 in the index. core.fileMode=false
means a Windows checkout silently drops the executable bit, so a fresh Linux
clone got non-executable files.

T19 now reads update_local_repo.OFFLINE_UPDATE_SCRIPT and asserts the preseed
names the same path. Both files hard-code it, and nothing tied them together, so
a rename would leave auto_update.sh printing 'not installed yet' with everything
else green.

Final: 107 passed, 0 failed, 2 skipped. The skips stay honest (T12 needs gpg;
T13's ks.cfg assertion is vacuous because the file is not in the repo).
This commit is contained in:
Mistercoolertyper committed 2026-11-04 10:38:17 +01:00
1 parent e9a447da4d
commit be6379107f
2 files changed
+167 -10

No files matched your search

+50 -1
View File
@@ -40,6 +40,7 @@ not a pass**, and the summary says so.
| 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 |
| T20 | `make-iso.sh` builds a bootable ISO with the preseed baked in (skips without a netinst ISO) |
| T21 | The executable bit is recorded as `100755` **in git**, not just on disk |
| 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
@@ -117,7 +118,6 @@ Being explicit matters more than the green summary.
`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.
11. **Actually booting the built ISO.** T20 proves the image is structurally
correct and the preseed is on it, but it never boots it in a VM. Whether the
installer runs unattended end to end, and whether the inventory prompt behaves,
@@ -258,6 +258,21 @@ 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.
That refusal is checked three ways, because a negative assertion is easy to
write in a way that cannot fail:
1. The rule **text** must not mention the action (T16).
2. polkit itself must refuse it: T17 starts its **own** detached sleeper owned by
the sudo-group user, proves `/proc/<pid>` is owned by that user, then asks
`pkcheck --action-id ...package-remove --process <pid>` and requires rc=2.
A missing process or any unexpected rc is a **FAIL**, never a pass - a 127
must not be able to masquerade as "denied".
3. **The check was proven able to fail.** With `package-remove` added to the
rule by hand and polkit restarted, `pkcheck` returned **rc=0** (granted), so
assertion 2 goes red. Restored afterwards and verified by sha256. Without
this step the assertion would only be known to pass, not known to be capable
of failing.
`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.
@@ -398,6 +413,40 @@ residue. So at startup, under the lock, the harness sweeps any
`zz-vdi-test-*.list` whose target directory is gone, and says so. That is safe
precisely because the lock guarantees no peer run is alive at that moment.
## T21: executable on disk is not executable in a clone
This repo is developed on a Windows checkout with `core.fileMode=false`, so git
records mode `100644` regardless of the mode on disk. Both scripts were
executable locally and non-executable in the index - a fresh Linux clone gets
`Permission denied` running `./debian/test/run-tests.sh`.
T21 asserts `git ls-files -s` reports `100755` for `debian/test/run-tests.sh`
and `debian/make-iso.sh`. It skips honestly when git is unavailable or the
directory is not a checkout. Fix a failure with:
```sh
git update-index --chmod=+x <path>
```
## T19 cross-checks the preseed against the installer
T19 asserts the generated `auto_update.sh` delegates to
`/usr/local/sbin/vdi-offline-update`. That string is hard-coded in the preseed,
while the *installer* of that path lives in `update_local_repo.py` - two
independent files with nothing tying them together. If the installer's path ever
changed, the preseed would keep pointing at the old one and `auto_update.sh`
would degrade to printing `vdi-offline-update not installed yet`:
gracefully, silently, with every other assertion still green.
So T19 reads `update_local_repo.OFFLINE_UPDATE_SCRIPT` and asserts the generated
script names that same path. It skips if that constant does not exist.
What T19 still does **not** prove: that the helper exists and runs on a real
target. It is installed by `update_local_repo.py` at first cron run, so on a
fresh install `auto_update.sh` may legitimately find it absent. That ordering is
by design, not a defect, but it means T19 is evidence about the *contract*
between the two files, not about the end state of an installed machine.
## Requirements
- Debian 13 (trixie), root.