Skip to content

debhelper 13 source package, hardened lockfile gates (F2), immutable releases (7.3.4) - #7

Merged
ks98 merged 29 commits into
mainfrom
chore/debian-packaging
Sep 25, 2026
Merged

ks98 merged 29 commits into
mainfrom
chore/debian-packaging

Conversation

@ks98

@ks98 ks98 commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Converts linuxmuster-radius to a classic debhelper 13 source package (version 7.3.4), following the hub plan work/plans/venv-debian-umbau.md (checkpoints 1–7), and in the same PR fixes finding F2 of the cold verification of stage A (work/verification/cold-stage-a.md), hardens the release step against mutable releases (F1), and adds the squid 7.3.4 git precaution to the postinst.

What

debhelper conversion (commits build(debian): … to ci(release): ship the source artefacts, …)

  • debian/ with compat 13, Rules-Requires-Root: no, 3.0 (native); make deb = dpkg-buildpackage -us -uc -tc plus -I patterns that keep untracked local state (.venv, tool caches, .crabbox, .claude/settings.local.json, keytabs, e2e test keys) out of the source tarball.
  • packaging/build-venv.sh builds the venv into debian/linuxmuster-radius/opt/linuxmuster-radius/venv without root; debian/venv-relocate (byte-identical to the hub reference, sha256 b2eb131c5edaab444bfa16c8fd741b599202276e7bae7ebb1b8f22b4d31ccbbc) relocates it to /opt/linuxmuster-radius/venv, and --verify runs right before dh_builddeb.
  • debian/rules = the hub's rules.template, only PKG differs: no dh_strip/dwz/strip-nondeterminism/makeshlibs in the venv, dh_fixperms -X the venv, no dh_installsystemd (the maintainer scripts keep handling the unit, unit stays in /lib/systemd/system).
  • Architecture: amd64 (cp312 x86_64 extension modules), Depends: ${misc:Depends}, ${shlibs:Depends}, python3 (>= 3.12), python3 (<< 3.13), …, Homepage, lintian overrides with reasons, debian/copyright with a note on the bundled PyPI distributions.
  • Maintainer scripts moved unchanged plus one #DEBHELPER# line each.
  • CI: apt-get build-dep . && make deb, md5sums gate, lintian --fail-on error on the .deb, new permanent file-tree job (in ci.yml and release.yml, identical run blocks; release needs it), ruff on debian/venv-relocate, shellcheck on debian/* and scripts/tests/*.sh. The release carries the .deb, .changes, .buildinfo, .dsc and source tarball.

F2: lockfile check and build could be bypassed (fix(packaging): …, test(packaging): …)
Up to 7.3.3 an indented zzzevil @ file:///…whl#sha256=… line passed scripts/check-lockfiles.sh (column-1 greps only), and the build's freeze == lock comparison crashed inside a process substitution that set -e never saw, so the .deb shipped the foreign package. Now scripts/lockfile_gate.py (stdlib) is used by both:

  • lint: every byte printable ASCII or \n (pip splits with str.splitlines(), so CR/FF/U+2028 inside a comment would start a line pip reads), every line empty, a comment, name==version \ or a --hash=sha256:<64 hex> continuation. Indented lines, URL requirements, -i/--index-url, --extra-index-url, -f/--find-links, -e, -r, -c, markers, pins without hash etc. fail. check-lockfiles.sh runs it first and stops there; --lint runs only this step.
  • pypi (build): every hash is one PyPI publishes for that exact version (pip only checks the file it downloads, so a changed sdist hash would pass pip).
  • freeze (build): pip freeze --all written to a file, exit status checked, compared pin by pin; every line must be a plain name==version.
  • closure (build): every installed distribution is required by lmnradius or pip, so an extra pin with PyPI's genuine hashes fails too.
    No pipeline or process substitution is left in the gate; each step's status is checked explicitly under set -euo pipefail.

Release immutability (ci(release): publish only a release that comes out immutable): the release step is the hub template's (templates/release.yml at 19b9e4c), only the assets list differs. With the optional secret IMMUTABLE_CHECK_TOKEN the job refuses to publish while GET repos/$GH_REPO/immutable-releases does not say enabled == true (GITHUB_TOKEN cannot read that endpoint); without it, a notice. After publishing it re-reads the release by id and fails unless immutable == true.

postinst (fix(postinst): …): maintenance.auto false and gc.auto 0 in the instance store before its first commit and on every configure; git as lmnradius runs without an inherited XDG_CONFIG_HOME.

Renovate is disabled (Kevin, 2026-09-25): comments and docs no longer claim it opens PRs.

How it was tested (all reproducible)

  • Build in ghcr.io/linuxmuster/lmndev-runner:24.04@sha256:6b0c8ac9…209e, as root (like CI) and as the image's non-root user build: both green and byte-identical (linuxmuster-radius_7.3.4_amd64.deb sha256 2717495adbbe597b0ba5d29242d2127beb224928083c4bcaa86b8531ba85a1a0). Log: lint ok: … 36 pins, 919 hashes, pypi ok: 923 hashes are files PyPI publishes, freeze ok: … 37 locked pins, closure ok: all 38 distributions are required, venv-relocate: 21 files rewritten, 1714 .pyc recompiled, 17 RECORD rows re-hashed, venv-relocate --verify: no build path, 2183 RECORD hashes match, 1714 .pyc valid, pip check ok.

  • Against the released 7.3.3 .deb (hub compare-release.sh): file tree differs only by usr/share/doc/linuxmuster-radius/{changelog.gz,copyright}, usr/share/lintian/overrides/linuxmuster-radius, their directories, the lmnradius-7.3.4.dist-info name and the mode of ./; control only Version/Architecture/Depends/Homepage; content only the dist-info, a comment in models.py and the three new files; 1714/1714 .pyc identical after the 16-byte header; prerm/postrm +1 empty line, postinst +1 empty line plus the git precaution. lintian --fail-on error exit 0. The file-tree gate code from ci.yml: nothing lost, no mode/owner change.

  • Upgrade 7.3.3 (_all) → this build (_amd64) with the hub's upgrade-test.sh in ubuntu:24.04@sha256:008173c2…: Unpacking linuxmuster-radius (7.3.4) over (7.3.3), upgrade linuxmuster-radius:all 7.3.3 7.3.4, state byte-identical, modes/owners unchanged, store history kept, no :all left, dpkg --verify/--audit silent, no orphans, pip check ok → == upgrade test linuxmuster-radius: OK.

  • F2 regression (scripts/tests/lock_gates.sh, in the fast job): for each tampered lockfile, check-lockfiles.sh and build-venv.sh must fail for the expected reason. With LOCK_GATES_DEB=1 inside the runner image the whole make deb must fail without leaving a .deb:

    case check-lockfiles.sh build-venv.sh make deb
    indented zzzevil @ file:///…whl#sha256=… exit 1 (lint) exit 1 (lint) exit 2, no .deb
    --extra-index-url https://evil.example/simple exit 1 (lint) exit 1 (lint) exit 2, no .deb
    hashes of the first pin removed exit 1 (lint) exit 1 (lint) exit 2, no .deb
    last hash of the first pin changed (annotated-doc's sdist) exit 1 (not published by PyPI) exit 1 (pypi gate) exit 2, no .deb
    extra pin six==1.16.0 with PyPI's genuine hashes exit 1 (pins differ from a fresh resolution) exit 1 (closure gate) exit 2, no .deb
    six==1.16.0 without hash exit 1 (lint) exit 1 (lint) exit 2, no .deb

    lock gates: 62 ok, 0 wrong with LOCK_GATES_DEB=1, 56 ok, 0 wrong without. Reproduce:

    docker run --rm -u root -v "$PWD":/src:ro ghcr.io/linuxmuster/lmndev-runner:24.04@sha256:6b0c8ac994cf1d2da44b0b36ebd7b3b125094886e78293e04b9db5e515b8209e bash -c '
      cp -r /src /w && cd /w && apt-get update -qq && apt-get build-dep -y -qq . >/dev/null &&
      python3 -m venv /t && /t/bin/pip install -q uv==0.12.18 && chown -R build:build /w &&
      runuser -u build -- env PATH=/t/bin:$PATH HOME=/home/build LOCK_GATES_DEB=1 bash scripts/tests/lock_gates.sh'
    

    The same edits against the old check-lockfiles.sh (origin/main) exit 0 for the indented URL, --extra-index-url and removed-hashes cases.

  • postinst (container, XDG_CONFIG_HOME=/root/.config exported): 7.3.3 prints warning: unable to access '/root/.config/git/ignore': Permission denied, 7.3.4 prints none on upgrade, fresh install and dpkg-reconfigure; the store has maintenance.auto=false, gc.auto=0; history kept.

  • Fast tier (ci.yml's run blocks in a fresh ubuntu:24.04, Python 3.12, pinned tools): ruff, ruff format, mypy, pytest 184 passed, lock gates 56/0, ruff on venv-relocate, shellcheck, reuse all green.

  • Source tarball: untracked .venv/, caches, __pycache__, *.egg-info, .crabbox/, .claude/settings.local.json, deploy/e2e/certs/out/, *.keytab and .github/ are not in linuxmuster-radius_7.3.4.tar.xz.

Not tested / open

  • crabbox: no crabbox script builds the .deb in this repo, nothing to adapt (crabbox is not usable at the moment anyway).
  • The release job itself only runs on a tag; it is exercised here via workflow_dispatch (all jobs up to release, which is skipped without a tag). The repo has no IMMUTABLE_CHECK_TOKEN secret yet, so a tag release will use the notice path plus the hard post-publish check.
  • The lockfile job (uv re-resolution) is not in release.yml's needs; the build now refuses malformed lockfiles, unpublished hashes and venv drift by itself.

Not merged, not tagged.

Kevin Stenzel added 29 commits September 25, 2026 11:29
Classic debian/ as the package conventions require (debhelper-compat 13,
Rules-Requires-Root: no, 3.0 native), built by `make deb` =
dpkg-buildpackage. The hermetic venv stays under /opt/linuxmuster-radius/venv
(linuxmusterDEV work/plans/venv-debian-umbau.md):

- packaging/build-venv.sh builds it into debian/linuxmuster-radius, without
  root. The pip calls, `pip check` and the freeze == lock gate are those of
  build-deb.sh; only the target directory is now an argument.
- debian/venv-relocate (byte-identical to the hub reference, sha256
  b2eb131c...cbbc) rewrites the build path in shebangs, activate scripts
  and pyvenv.cfg, recompiles the .pyc files as checked-hash for /opt and
  re-hashes the RECORD rows it touched. `--verify` runs right before
  dh_builddeb and fails the build on a leftover build path, a RECORD
  mismatch (a debhelper tool changed a pip-installed file), a stale .pyc
  or a failing `pip check`.
- dh_strip, dh_dwz, dh_strip_nondeterminism and dh_makeshlibs stay out of
  the venv, dh_fixperms skips it (the wheels' .so files stay 0755), and
  dh_installsystemd is off: the maintainer scripts keep handling the unit.
- Architecture: amd64, because the venv carries cp312 x86_64 extension
  modules; Depends python3 (>= 3.12), python3 (<< 3.13), since the venv
  runs /usr/bin/python3 and is built for 3.12; ${shlibs:Depends} adds
  libc6 and libgcc-s1.
- lintian overrides for the venv under /opt, each with its reason.
- debian/copyright notes that the bundled PyPI distributions carry their
  licenses in their *.dist-info directories.
- The Makefile keeps untracked local state (.venv, tool caches, crabbox
  state, .claude/settings.local.json, keytabs, e2e test keys) out of the
  source tarball.

Checked in lmndev-runner:24.04@sha256:6b0c8ac9 as the image's non-root
user: both venv-relocate steps run (21 files rewritten, 1714 .pyc, 17
RECORD rows; --verify: 2183 RECORD hashes, 1714 .pyc), lintian
--fail-on error exit 0, and against the released 7.3.3 .deb the file tree
differs only by the doc/changelog, copyright and lintian override files
and their directories plus the mode of ./, all 1714 .pyc are identical
after the 16-byte header.
packaging/debian/{postinst,prerm,postrm} move to debian/ unchanged, plus one
#DEBHELPER# line right before the final `exit 0` (never inside a comment:
debhelper replaces every occurrence of the token). No debhelper tool adds a
snippet here (no dh_installsystemd, no dh_python3, no conffiles), so the
built DEBIAN/postinst, prerm and postrm equal those of the released 7.3.3
.deb plus one empty line each, which compare-release.sh confirms.
debian/rules and packaging/build-venv.sh replace the hand-rolled dpkg-deb
build, debian/control replaces packaging/debian/control (the maintainer
scripts moved in the previous commit). packaging/systemd/ stays: debian/install
takes the unit from there. .gitignore also ignores debhelper's build stamp.
CLAUDE.md and README describe the debhelper package: `make deb` =
dpkg-buildpackage without root, packaging/build-venv.sh builds the venv into
the package tree, debian/venv-relocate makes it correct for /opt and proves
with --verify that no debhelper tool changed a pip-installed file, and the
artefacts land next to the checkout. The download and install examples in
install.md and operations.md name the _amd64.deb, the comments in
build-requirements.in, check-lockfiles.sh and renovate.json and ADR-016 name
build-venv.sh, and the threat model no longer names the removed script.
…n any venv drift

The cold verification of stage A (linuxmusterDEV
work/verification/cold-stage-a.md, F2) built a .deb with a foreign package
in its venv: an indented `zzzevil @ file:///...whl#sha256=...` line in
controlplane/requirements.lock passed scripts/check-lockfiles.sh, whose
pins()/hashes() only read lines starting in column 1, while pip strips the
indentation and installs the URL requirement (its #sha256= fragment
satisfies --require-hashes). The freeze == lock comparison of the build
then crashed with ValueError inside a process substitution, which `set -e`
never sees, and diff compared two equally truncated lists. The check was
also green for an --extra-index-url line and for a pin whose hashes were
removed.

scripts/lockfile_gate.py (stdlib only) now does the reading for both:

- lint: every byte is printable ASCII or \n (pip splits lines with
  str.splitlines(), so a CR, form feed or U+2028 inside a comment would
  start a line pip reads), and every line is empty, a comment, a pin
  `name==version \` as uv writes it, or a `    --hash=sha256:<64 hex>`
  line continuing that pin. Everything else fails: indented lines, URL
  requirements, -i/--index-url, --extra-index-url, -f/--find-links, -e, -r,
  -c and any other option, markers, a pin without hash, a pin twice.
  check-lockfiles.sh runs it first and stops there (no uv run on a file
  that fails it); `check-lockfiles.sh --lint` runs only this step.
- pypi: every hash is one PyPI publishes for exactly that version. pip
  compares only the hash of the file it downloads, so a replaced hash of
  the sdist or of another platform's wheel would have passed the build.
- freeze: `pip freeze --all` (written to a file, its exit status checked)
  equals the lock pins minus setuptools plus lmnradius, every line a plain
  name==version pin, compared pin by pin.
- closure: every distribution in the venv is required, directly or
  through others, by lmnradius or pip (markers and extras evaluated in the
  venv), so an extra pin that carries PyPI's genuine hashes fails too.

build-venv.sh runs lint and pypi before pip reads a lockfile and freeze
and closure after the install, each with an explicit status check; no
pipeline or process substitution is left in the gate. ADR-016 and the
threat model describe the hardened gates.
…ession test

scripts/tests/lock_gates.sh runs in the fast job (uv pinned there as in the
lockfile job) and in `run.sh quick` when uv is installed. Each case of the
cold verification's F2 matrix edits controlplane/requirements.lock in a copy
of the tree, and both scripts/check-lockfiles.sh and
packaging/build-venv.sh must refuse it for the expected reason, not just
exit non-zero:

  indented `    zzzevil @ file:///...whl#sha256=...`   lint (check and build)
  `--extra-index-url https://evil.example/simple`      lint (check and build)
  every hash of the first pin removed                  lint (check and build)
  last hash of the first pin changed (the sdist of     check: hashes PyPI does not
    annotated-doc, a file pip never downloads)         publish; build: pypi gate
  six 1.16.0 added with PyPI's genuine hashes          check: pins differ from a
                                                       fresh resolution; build:
                                                       closure gate
  `six==1.16.0` without hash                           lint (check and build)

Plus the gates of scripts/lockfile_gate.py one by one: lint against URL
requirements in column 1, -i/--index-url, -f/--find-links, -e, -r, -c,
--trusted-host, indented options, ${VAR}, requirements hidden behind CR,
form feed or U+2028 in a comment, tab, NUL, uppercase names, markers,
malformed hashes, orphan hashes, duplicate pins (and that empty lines and
comments stay allowed); pypi against a changed first hash and an unknown
version; freeze against URL and editable installs, extra, missing and
different pins, a leftover setuptools, a missing lmnradius and a CR; closure
against an extra distribution, one needed only by an unrequested extra and
a missing one. The script never skips; a missing uv fails it.

LOCK_GATES_DEB=1, run in the build image, also runs the whole `make deb`
on each tampered tree and requires it to fail without leaving a .deb.
…o root XDG path

Taken over from linuxmuster-squid 7.3.4 as a precaution. The postinst
already changes ownership before any git command and runs git as lmnradius,
but git 2.47 and later start auto-maintenance after a commit as a detached
process that creates and removes objects/maintenance.lock; if one is still
running while the next configure's `chown -R` walks the tree, the vanished
file fails the configure under `set -e` (squid 7.3.1-7.3.3 hit exactly this
with the PPA's git). The instance store now has maintenance.auto false and
gc.auto 0 in its repository config, set before its first commit and on
every configure, so neither the postinst nor the service's own commits
leave a git process behind. A change log of a few commits needs no gc.

runuser resets HOME but not XDG_CONFIG_HOME: with it pointing into /root
(GitHub runners set it, `sudo -E` keeps it) every git call as lmnradius
warned "unable to access '/root/.config/git/...': Permission denied".
The git calls drop it now. operations.md mentions the setting.
The Renovate workflow is disabled (Kevin, 2026-09-25) until Renovate is
re-enabled with a GitHub App. Comments in ci.yml, release.yml,
build-image.yml, the Makefile, build-venv.sh, check-lockfiles.sh, the
Dockerfile, DEFAULT_IMAGE in models.py and the deploy examples, and the
text in CLAUDE.md, install.md, operations.md, architecture.md, the threat
model and ADR-010/013/016/017 still said that Renovate proposes new
digests, SHAs, pins and lockfiles as pull requests. They now say that these
are raised by hand in a reviewed PR. renovate.yml keeps its description for
the day it is re-enabled, under a note that it is disabled; renovate.json
stays unchanged.
- package: `apt-get build-dep .` + `make deb` (dpkg-buildpackage) in the
  digest-pinned lmndev-runner; the .deb, .changes, .buildinfo, .dsc and
  source tarball are collected from the parent directory. The md5sums gate
  (DEBIAN/md5sums lists every regular file) and `lintian --fail-on error`
  on the .deb only (the .changes would fail on the unknown lmn73).
- file-tree (new, permanent): the newest published release and the build
  are compared as `mode owner path[ -> target]`; a lost path or a changed
  mode/owner fails. Venv rules: ./ is skipped (dpkg never applies its mode),
  the own lmnradius-<version>.dist-info is compared under a fixed name, and
  a vanished third-party path under site-packages (a lock bump) is reported,
  not failed, since venv-relocate --verify and the freeze gates prove those.
- fast: ruff on debian/venv-relocate (no .py extension, so `ruff check .`
  skips it), shellcheck on debian/{postinst,prerm,postrm} and
  scripts/tests/*.sh.
- The lockfile job's comment says what only it notices now that the build
  refuses malformed lockfiles and venv drift by itself.

install-smoke and upgrade-smoke are unchanged: both install
./packages/*.deb, which now is the _amd64.deb, and the upgrade from the
released _all.deb is logged by dpkg as `upgrade linuxmuster-radius:all`.
The build job builds exactly like ci.yml's package job (build-dep, make deb,
md5sums gate, lintian on the .deb; the run blocks are identical), and the
file-tree job is the same as in ci.yml; the release job needs it, so a tag
is never published while the gate is red (a tag starts both workflows, and
only release.yml publishes). The release carries the .deb plus the .changes
and the files it lists with their checksums: .dsc, source tarball and
.buildinfo, so the .changes never names a file nobody can download.
The cold verification of stage A (linuxmusterDEV
work/verification/cold-stage-a.md, F1) found no published release immutable:
the setting was switched on after each release, it only acts on releases
published later, and this job only warned about it and ended green.

The release step is now the hub template's (templates/release.yml), unchanged
but for the list of assets:

- Before publishing, while the release is still a draft: with the optional
  secret IMMUTABLE_CHECK_TOKEN (fine-grained, this repo only,
  "Administration: Read-only") the job reads GET
  repos/$GH_REPO/immutable-releases and stops, leaving the draft
  unpublished, unless `enabled` is true or when the call fails. GITHUB_TOKEN
  cannot read that endpoint (HTTP 403 even with write-all), so without the
  secret the job says so in a notice and relies on the check after
  publishing.
- After publishing it re-reads the release by id with GITHUB_TOKEN and fails
  unless `immutable` is true: an error, never a warning.
The admin-facing summary of the debhelper conversion (same files, amd64,
python3 (>= 3.12), (<< 3.13)), the hardened lockfile gates, the git
precaution in the postinst and immutable releases.
The cold verification of the debian conversion (linuxmusterDEV
work/verification/cold-debian-squid.md F1, cold-debian-radius.md; task
nachbesserung-kalte-pruefung-umbau.md K1) showed the danger of installing a
lockfile into the venv before the set/closure check: a distribution pinned
in the build lock can ship a .pth and bin/ scripts, and its .pth runs in
every interpreter of that venv. On the pre-K1 head an extra build-lock pin
whose wheel carried a .pth ran it 18 times while lmnradius's own wheel was
built, before the post-install closure gate caught the extra pin.

packaging/build-venv.sh now runs, in this order and before it creates the
shipped venv: grammar (lockfile_gate lint) and published-hash (lockfile_gate
pypi) on both locks; then installs uv into an isolated venv from
controlplane/uv-requirements.lock -- a file that holds only uv, verified by
lint, pypi and the new `lockfile_gate only`, installed with --require-hashes
and never put on PATH; then runs check-lockfiles.sh with that uv (absolute
path, PATH without any venv bin/) to prove the pin set equals the resolved
closure of pyproject.toml / build-requirements.in. Only then is the venv
created and the locks installed. The post-install freeze and closure gates
stay as a second layer. So no interpreter from a lock-populated venv runs
until both locks are fully verified; an extra pin -- even with a real PyPI
hash and a shipped wheel -- is rejected before any lock wheel is unpacked.

check-lockfiles.sh takes uv by absolute path (env UV), defaulting to the
bare name only outside the build. controlplane/uv-requirements.lock carries
every PyPI hash of uv 0.12.18; it is not re-resolved (a fresh resolver would
need itself) and is asserted to hold exactly one pin. ADR-016, the threat
model and CLAUDE.md describe the rule.
…h a real extra pin (finding 4)

scripts/tests/lock_gates.sh gains the K1 cases: a wheel crafted in the test
(self-contained, permanent) that ships bin/ scripts (diff, comm, sort, awk,
grep, cut, cp, python3, uv) and a marker-writing .pth, pinned with a real
name and hash in the build lock (variant 1) or in both locks (variant 2).
Its publication on PyPI is simulated only inside the throwaway copy, by
monkeypatching that copy's lockfile_gate published(); the repo's real build
path is untouched, so real builds are not weakened. Each case must fail the
set-closure check, and under LOCK_GATES_DEB the whole `make deb` must fail,
ship no .deb, and leave the marker absent -- the .pth never ran.

Also fixes cold-debian-radius.md finding 4: a genuine extra pin sitting in a
committed lock was not caught by the fast tier (lock_gates.sh only lint- and
pypi-checked the committed files, and its crafted extra-pin case used six,
which failed on "pinned twice", an artefact). A new positive check runs the
full check-lockfiles.sh on the committed locks, so a real extra pin fails the
fast tier, not only the ci `lockfile` job and the build. The extra-pin build
case now expects the earlier set-closure refusal (build-venv checks the
closure before it installs).
…release on lockfile consistency

- fast and lockfile jobs install uv with --require-hashes from
  controlplane/uv-requirements.lock instead of a bare `pip install uv==...`
  (K1: the resolver itself is hash-pinned).
- new lock-gates-build job runs scripts/tests/lock_gates.sh with
  LOCK_GATES_DEB=1 in the pinned image, as the build user, with uv from the
  uv lock on PATH: it proves through a real `make deb` that a tampered lock
  (an extra build-lock pin whose wheel ships a .pth) is rejected before the
  venv is populated, so no .deb is built and the .pth never runs.
- release.yml gains the lockfile job and needs it (cold-debian-radius.md
  finding 5): a tag could be published while a lock drifted from its inputs,
  because release.yml neither ran check-lockfiles.sh nor depended on the ci
  lockfile job. The build refuses a malformed lock, an unpublished hash and
  any venv drift on its own, but the P7D age rule and set==closure are proven
  only by the uv re-resolution, now a release gate.
A local `make deb` on a working checkout put .gitignored and untracked files
into the source tarball (cold-debian-radius.md finding 3: venv/,
deploy/secrets/krb5.conf, deploy/**/ssl_db/, .env, dist/, build/, ...). The
enumerated -I ignore list was whack-a-mole. packaging/make-deb.sh now, in a
git checkout, exports the tracked tree with `git archive` (of `git stash
create`, so uncommitted changes to tracked files are built too, but never an
untracked or ignored file) into a canonically named linuxmuster-radius-<ver>
directory and builds there; .github and .claude (workflows and developer
tooling with internal endpoints/token ids) are the only deliberate
exclusions, plus the .gitignore files dpkg-source drops by default. It then
asserts the source tarball holds exactly that set and fails otherwise.
Outside a git checkout (an unpacked .dsc) it builds in place. Proven on a
junk-filled repo: the tarball is exactly the tracked files minus the
exclusions, no secret or junk leaks, and the .deb file tree is unchanged.
…/K3 hardening

K2 (cold-debian-radius.md finding 2): "apt holds the package back" is only
true for `apt upgrade`; a full distribution upgrade (apt full-upgrade,
do-release-upgrade) removes the package, leaving its configuration and state
in place. The dependency-check bullet now also notes the pre-install
set==closure check that stops an extra package before its code can run.
…ml bareword

The K1 change installs uv from controlplane/uv-requirements.lock with
--require-hashes instead of `pip install uv==0.12.18`, so uv is no longer a
bare `uv==` pin in ci.yml. The Renovate-contract test asserted it was; it now
asserts uv is absent from the ci.yml barewords and, in a new test, that the
uv lockfile holds exactly uv with sha256 hashes and that ci.yml installs from
that file.
… the tracked-tree export

A container build (the CI package/build jobs, run as root over a bind-mounted
checkout) hit git's "dubious ownership" guard, so make-deb.sh fell to the
in-place branch: the source tarball's top directory was the checkout basename
and the tracked-only assertion did not run (it was still clean because CI
checks out only tracked files, but the K3 guarantee was not enforced there).
make-deb.sh now runs its git calls with -c safe.directory='*', so a git
checkout is always detected and built from the git-archive export with the
canonical linuxmuster-radius-<version>/ top directory and the assertion.
Verified as root over a foreign-owned repo with junk: git-archive path,
tarball holds exactly the 113 tracked files minus the exclusions, no leak.
…ler's environment

Cold verification r2 (F1, F2, F3, F9; round 3 R1, R2, R5, R7):

- scripts/check-lockfiles.sh is the one lock gate. It verifies all three
  lockfiles itself -- grammar, the uv lock holds exactly the uv== of
  uv-requirements.in with hashes PyPI publishes, then uv from it into an
  isolated venv called by absolute path, pins == closure of the declared
  inputs, every hash published -- instead of trusting a `uv` from PATH.
- The gate and packaging/build-venv.sh set a fixed PATH, drop VIRTUAL_ENV,
  PYTHON*, UV_* and PIP_*, ignore pip/uv config files, run /usr/bin/python3 -I
  (also for `-m venv`) and give uv --python /usr/bin/python3 --no-config.
- CI: the fast tier runs the gate as its first step and no longer installs
  the uv lock into the tool interpreter; the ci.yml and release.yml
  `lockfile` jobs are only the gate, nothing is installed before it.
- run.sh runs the gate first in a clean /bin/bash; lint and unit (and the
  .venv prefix) only after it passed.
- PyPI queries time out after 10 s with short retries and stop at the first
  unreadable pin: without network the build fails in seconds, not minutes.
- CLAUDE.md and ADR-016 state where the gate runs and its limit (another
  real release, older or newer, passes; only review catches it).
…ng from .git, says what it built

Cold verification r2 (radius F5, F6, F7, squid F1, F4, F6; round 3 R3, R4):

- No safe.directory='*' any more: git's ownership guard stays on, so a
  checkout owned by another user is refused (and nothing its .git/config
  names runs as root). CI trusts exactly $GITHUB_WORKSPACE in the package and
  release build steps.
- The export copies the files of the git index from the working tree
  (no stash/archive/status): core.fsmonitor and hooks are switched off and
  no clean/smudge filter can run; differences are found with
  hash-object --no-filters and diff-index --cached.
- A .git that git cannot use (a worktree whose repository is not mounted, a
  refused owner) stops the build with a message instead of packing the tree
  as it is. The documented container command mounts the common git dir, so
  it works in a git worktree.
- Modes as git records them (0644/0755, directories 0755) whatever the umask,
  mtimes = the changelog date, tracked symlinks stay symlinks (the tarball
  check counts them).
- Every difference from HEAD (modified, deleted, staged new, exec bit) and
  every untracked file (not built) is printed as a WARNING before and after
  the build, with a note that the version stays the changelog's; a failing
  git step fails the build instead of silently falling back to HEAD.
- The Makefile runs /bin/bash; make-deb.sh fixes PATH and drops PYTHON*,
  UV_*, PIP_* and GIT_* like the lock gate.
…build, CI and a poisoned env

Cold verification r2 (radius F1, F2, F3, F8; round 3 R1, R2, R3, R4, R6):

- scripts/tests/k1_wheel.py builds the attack wheel with S_IFREG|0755
  scripts, so pip really installs its bin/ tools (diff, sort, awk, grep,
  python3, python, pip, uv, bash, ...) executable; the old 0o755 << 16 left
  them 0644 and that half of the test could never fire.
- lock_gates.sh: K1 cases for the build lock, the runtime lock, both and the
  uv lock (check, build-venv, make deb); R6 proves the wheel sharp (bin/ and
  .pth markers, build-venv.sh without the gate call writes a bin/ marker);
  R1 runs the gate, build-venv.sh, run.sh and make deb under an activated
  poisoned venv, a poisoned .venv, PYTHONPATH/PYTHONHOME and UV_*/PIP_*
  redirections: same verdicts, no marker; R2 replays the lock steps of
  ci.yml (fast, lockfile) and release.yml (lockfile) word for word
  (scripts/tests/ci_step.py) with a planted package in each lock: they stop
  at the gate, nothing is installed, no marker; without the gate step the
  install lines write a bin/ marker. The harness needs no uv any more.
- scripts/tests/make_deb_checks.sh (CI job lock-gates-build): a complete
  make deb of a dirty checkout (umask 002, a 0600 file, a tracked symlink,
  modified/deleted/staged/untracked files, fsmonitor, filters and hooks in
  .git) under the poisoned environment builds, warns about every difference,
  packs exactly the tracked files with 0644/0755 and runs nothing; a
  worktree without its repository is refused; as root, a checkout of
  another user is refused by git's ownership guard.
- test_packaging.py keeps the workflow order (no lockfile install before
  the gate step, lockfile jobs are only the gate, no '*' safe.directory) and
  reads the uv lock with the gate's own parser.
…grade

Cold verification r2, F8: `grep ' upgrade linuxmuster-radius:'` matched any
upgrade line, a downgrade included (dpkg logs --allow-downgrades as an
upgrade too). The job now requires the line from the released version to the
built one and that the built version is not older. Same change in ci.yml and
release.yml, whose upgrade-smoke jobs stay identical.
apt upgrade keeps the newer Python back (not this package); a full upgrade
removes the package. The lock checks run before anything from a lockfile is
installed, in the build and in CI, with uv pinned and verified first, and
they do not catch another genuine release (older or newer) within the
declared dependencies. The release job checks immutability after
publishing. The date line stays, so SOURCE_DATE_EPOCH and every mtime in the
package are unchanged.
…e (S1)

Cold verification r3, F1: the counter-probes of lock_gates.sh (build-venv.sh
without the gate call, the fast-tier install lines without the gate step)
installed the checked-out lockfiles, run.sh quick still ran lock_gates.sh
after a failed gate, and the CI job lock-gates-build had no gate step --
a crafted lock ran code there (2 to 8 marker lines).

- The counter-probes install fixture locks that pin only the test wheel,
  never the checkout's lockfiles.
- lock_gates.sh stops before any case if the committed lockfiles fail the
  gate (every case works on copies of them).
- run.sh stops right after a failed gate; nothing else runs.
- lock-gates-build runs the gate as its first step (after build-dep), and
  test_packaging.py requires a gate step before any step that runs
  lock_gates.sh or make_deb_checks.sh.
run.sh (the shellcheck file list) and make_deb_checks.sh (reading the
checkout, the test repositories) call git with --no-pager,
core.fsmonitor=false and core.hooksPath=/dev/null, like packaging/make-deb.sh,
so nothing a checkout's .git configures runs through the test harness either.
…nores (S1, S4)

- CLAUDE.md, ADR-016, the threat model, test-strategy, SKILL.md and the
  check-lockfiles.sh header name every consumer that runs the gate first,
  the CI job lock-gates-build included, and say that run.sh stops after a
  failed gate and the counter-probes install only fixture locks.
- The threat model no longer says nothing from any lockfile is installed
  before all three are verified: uv comes from its lock once that lock is
  verified, before the closure check of the other two.
- The texts about the caller's environment list what the gates drop (PATH,
  VIRTUAL_ENV, PYTHON*, UV_*, PIP_* including PIP_REQUIREMENT/PIP_CONSTRAINT,
  pip/uv config files) and name the limit: BASH_ENV, exported shell
  functions and proxy/CA variables are not neutralized; whoever sets them
  already runs code as the caller. Comments only in the scripts.
…ment (S1, S4)

The lock checks run before anything from a lockfile is installed in every CI
job now (lock-gates-build included); the sentence about the caller's
environment names what is ignored (PATH, an activated virtualenv, Python,
pip and uv variables) instead of claiming independence from all of it. The
source tarball holds the tracked files except the CI workflows and developer
tool settings. The date line stays.
@ks98
ks98 merged commit 5e60536 into main Sep 25, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant