From 47509f9cd7a959c0621a87a21dd7dc8f1418ae62 Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Sun, 27 Sep 2026 15:12:42 +0200 Subject: [PATCH 01/13] fix(api): /openapi.json reports the package version, not 0.1.0 (R1) FastAPI fell back to its default version 0.1.0 in the OpenAPI document; it now carries importlib.metadata's version of lmnradius, the debian/changelog version, like GET /v1/version. Opens the 7.3.5 changelog entry. --- controlplane/lmnradius/api.py | 4 +++- controlplane/tests/test_api.py | 8 ++++++++ debian/changelog | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/controlplane/lmnradius/api.py b/controlplane/lmnradius/api.py index 9515e8d..a1b1552 100644 --- a/controlplane/lmnradius/api.py +++ b/controlplane/lmnradius/api.py @@ -50,7 +50,9 @@ def create_app( ) -> FastAPI: """Build the FastAPI app wiring routes to the store, reconciler and docker service.""" verify = make_verify_token(settings) - app = FastAPI(title="linuxmuster-radius control plane") + # The OpenAPI document carries the package version (debian/changelog via setup.py), like + # GET /v1/version; without it FastAPI reports its own default, 0.1.0. + app = FastAPI(title="linuxmuster-radius control plane", version=dist_version("lmnradius")) @app.exception_handler(DockerException) async def _docker_unreachable(_request: Request, exc: DockerException) -> JSONResponse: diff --git a/controlplane/tests/test_api.py b/controlplane/tests/test_api.py index c0ccc16..0e61596 100644 --- a/controlplane/tests/test_api.py +++ b/controlplane/tests/test_api.py @@ -34,6 +34,14 @@ def test_version(client: TestClient, auth_headers: dict[str, str]) -> None: assert resp.json() == {"version": dist_version("lmnradius")} +def test_openapi_reports_the_package_version(client: TestClient) -> None: + # Up to 7.3.4 /openapi.json said "0.1.0" (FastAPI's default), whatever the package was. + resp = client.get("/openapi.json") + assert resp.status_code == 200 + assert resp.json()["info"]["version"] == dist_version("lmnradius") + assert resp.json()["info"]["version"] != "0.1.0" + + def test_missing_token_is_401(client: TestClient) -> None: resp = client.get("/v1/instances") assert resp.status_code == 401 diff --git a/debian/changelog b/debian/changelog index c96312a..fab0e36 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +linuxmuster-radius (7.3.5) lmn73; urgency=medium + + * The API's OpenAPI document (/openapi.json, the interactive docs under + /docs) now reports the package version instead of 0.1.0, like + GET /v1/version. + + -- Kevin Stenzel Sun, 27 Sep 2026 15:12:38 +0200 + linuxmuster-radius (7.3.4) lmn73; urgency=medium * The package is now built with debhelper (dpkg-buildpackage) instead of a From 05e86299cebc5d74008b9ae3649eee01282b4b62 Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Sun, 27 Sep 2026 15:14:14 +0200 Subject: [PATCH 02/13] fix(postinst): a failing change-log git step warns on stderr and never aborts the configure (A6) Up to 7.3.4 set -e let any failing git call in /var/lib/linuxmuster-radius/instances abort the configure and leave the package half-configured. Each git step now prints one WARNING line with the step and the repository when it fails (git's own message stays above it) and the configure goes on; the service handling below is unchanged. An unusable repository is detected once with git rev-parse, and the remaining change-log steps are skipped with that warning. docs/operations.md says how to repair the repository. --- debian/changelog | 8 ++++++++ debian/postinst | 49 ++++++++++++++++++++++++++++++++++------------ docs/operations.md | 12 ++++++++++++ 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index fab0e36..0d4b5e8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,14 @@ linuxmuster-radius (7.3.5) lmn73; urgency=medium * The API's OpenAPI document (/openapi.json, the interactive docs under /docs) now reports the package version instead of 0.1.0, like GET /v1/version. + * A failing git step in the instance change log + (/var/lib/linuxmuster-radius/instances) no longer aborts the package + configuration: up to 7.3.4 it left the package half-configured. Each + failure now prints a WARNING line with the step and the repository + (below git's own message), and the configuration and the service + handling go on as usual. Until the repository is repaired (see + docs/operations.md), instance changes are not versioned or are refused + with git's message. -- Kevin Stenzel Sun, 27 Sep 2026 15:12:38 +0200 diff --git a/debian/postinst b/debian/postinst index 330e60a..20042ef 100644 --- a/debian/postinst +++ b/debian/postinst @@ -55,26 +55,51 @@ chmod 700 /etc/linuxmuster-radius/secrets /etc/linuxmuster-radius/certs # the tree on the next configure; linuxmuster-squid 7.3.1-7.3.3 failed its configure on # exactly that race. The service's own commits read the same repository config, so they # spawn none either. A change log of a few commits needs no gc. +# A failing git step never stops the configure and never passes silently: the service and the +# instance records do not depend on the change log (up to 7.3.4 `set -e` aborted the whole +# configure on it). Each failure prints one WARNING line on stderr with the step and the +# repository, below git's own message; the configure and the service handling below go on as +# without it. Until the repository is repaired (docs/operations.md), the service records +# instance changes unversioned or refuses them with git's message (Store). INST_DIR=/var/lib/linuxmuster-radius/instances if command -v git >/dev/null 2>&1; then # runuser resets HOME, not XDG_CONFIG_HOME: an admin environment pointing it into /root # (GitHub runners, `sudo -E`) would make every git call warn "unable to access # '/root/.config/git/...': Permission denied". as_lmnradius() { runuser -u lmnradius -- env -u XDG_CONFIG_HOME "$@"; } + log_git() { as_lmnradius git -C "$INST_DIR" "$@"; } + log_warn() { + echo "linuxmuster-radius: WARNING: instance change log $INST_DIR: '$1' failed;" \ + "configuring goes on; repair the repository (docs/operations.md), until then" \ + "instance changes are not versioned or are refused" >&2 || : + } + log_ok=1 if [ ! -d "$INST_DIR/.git" ]; then - as_lmnradius git -C "$INST_DIR" -c init.defaultBranch=main init -q + log_git -c init.defaultBranch=main init -q || { log_warn "git init"; log_ok=; } + elif ! log_git rev-parse --git-dir >/dev/null; then + log_warn "git rev-parse (the repository is unusable, the other change-log steps are skipped)" + log_ok= fi - as_lmnradius git -C "$INST_DIR" config user.name "linuxmuster-radius" - as_lmnradius git -C "$INST_DIR" config user.email "lmnradius@localhost" - as_lmnradius git -C "$INST_DIR" config maintenance.auto false - as_lmnradius git -C "$INST_DIR" config gc.auto 0 - # Records written while the change log was broken (staged but never committed, or - # never added) become one import commit, so `git log` is complete after the upgrade. - for f in "$INST_DIR"/*.yaml; do - [ -e "$f" ] && as_lmnradius git -C "$INST_DIR" add -- "$(basename "$f")" - done - if ! as_lmnradius git -C "$INST_DIR" diff --cached --quiet; then - as_lmnradius git -C "$INST_DIR" commit -q -m "lmnradius: import existing instance records (package configure)" + if [ -n "$log_ok" ]; then + log_git config user.name "linuxmuster-radius" || log_warn "git config user.name" + log_git config user.email "lmnradius@localhost" || log_warn "git config user.email" + log_git config maintenance.auto false || log_warn "git config maintenance.auto false" + log_git config gc.auto 0 || log_warn "git config gc.auto 0" + # Records written while the change log was broken (staged but never committed, or + # never added) become one import commit, so `git log` is complete after the upgrade. + for f in "$INST_DIR"/*.yaml; do + [ -e "$f" ] || continue + f="$(basename "$f")" + log_git add -- "$f" || log_warn "git add $f" + done + # 0: nothing staged, 1: records to commit, anything else: git could not compare. + if log_git diff --cached --quiet; then log_rc=0; else log_rc=$?; fi + if [ "$log_rc" = 1 ]; then + log_git commit -q -m "lmnradius: import existing instance records (package configure)" \ + || log_warn "git commit (import of existing instance records)" + elif [ "$log_rc" != 0 ]; then + log_warn "git diff --cached" + fi fi fi diff --git a/docs/operations.md b/docs/operations.md index 8862328..ec8c7d0 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -32,6 +32,18 @@ jedes `create`/`set-ldap-ca`/`rm` ist ein Commit, `sudo -u lmnradius git -C und Identität als `lmnradius` an, schaltet git-Hintergrundwartung im Repo ab (`maintenance.auto false`, `gc.auto 0`) und holt beim Upgrade liegengebliebene Datensätze nach). +Scheitert dabei ein git-Schritt (ab 7.3.5), bricht die `postinst` nicht ab: je Fehlschlag steht +unter der Meldung von git eine Zeile `linuxmuster-radius: WARNING: instance change log +/var/lib/linuxmuster-radius/instances: '' failed; …` auf stderr (apt zeigt sie), Paket +und Dienst werden wie sonst eingerichtet. Bis zur Reparatur versioniert der Dienst +Instanz-Änderungen nicht oder lehnt sie mit der Meldung von git ab. Reparatur: die Ursache aus +der git-Meldung beheben (`sudo -u lmnradius git -C /var/lib/linuxmuster-radius/instances status`); +ist das Repo nicht zu retten, `.git` beiseite legen und die `postinst` erneut laufen lassen: +`mv /var/lib/linuxmuster-radius/instances/.git /root/instances-git.kaputt && dpkg-reconfigure +linuxmuster-radius` (als root). Sie legt ein neues Repo an und übernimmt die vorhandenen +Datensätze in einem Import-Commit; die alte Historie bleibt im beiseitegelegten Verzeichnis. Der +Dienst wird dabei neu gestartet (wie bei einem Upgrade). + ## Erstinbetriebnahme (einmalig) Reihenfolge — jeder Schritt setzt den vorigen voraus: From 77b8046fb26173e207af1563889a6d37d7ffd935 Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Sun, 27 Sep 2026 15:15:47 +0200 Subject: [PATCH 03/13] ci(release): never advise deleting a release whose immutable state could not be read (A1) The check after publishing is taken word for word from linuxmusterDEV templates/release.yml (6cd4d2a): immutable=false still says to delete the release and re-run; an unreadable answer fails the job with 'Do not delete it' and the command to check by hand, since the release may well be immutable. The rest of release.yml is unchanged. --- .github/workflows/release.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2b4e7eb..c09aa94 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -652,7 +652,13 @@ jobs: [ "$i" = 3 ] || sleep $((i * 5)) done if [ "$immutable" != true ]; then - echo "::error::$TAG is published but NOT immutable (immutable=${immutable:-unreadable}), its assets can still be replaced: delete release $rid (the tag stays), turn immutable releases on, re-run this job" + if [ "$immutable" = false ]; then + echo "::error::$TAG is published but NOT immutable, its assets can still be replaced: delete release $rid (the tag stays), turn immutable releases on, re-run this job" + else + # Unreadable is not "false": the release may well be immutable (and then cannot be + # replaced anyway), so never tell anyone to delete it on a failed read. + echo "::error::$TAG is published, but whether it is immutable could not be read (${immutable:-no answer}). Do not delete it: check with gh api repos/$GH_REPO/releases/$rid --jq .immutable; only if that prints false, delete release $rid (the tag stays), turn immutable releases on and re-run this job" + fi exit 1 fi echo "$TAG is published and immutable" From 94e742ace7c2aa0dd0f5c370b46c060941689bca Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Sun, 27 Sep 2026 15:16:22 +0200 Subject: [PATCH 04/13] docs(renovate): say Renovate is disabled; no description claims it raises anything now (A2) renovate.yml opens with the STATE paragraph of linuxmusterDEV templates/renovate.yml, word for word. renovate.json: the top-level description starts "Renovate is disabled, see renovate.yml", and every description that claims an action says "When enabled", worded as in templates/renovate.json. Text only: no rule, manager or pattern changed (the config validator of the pinned engine passes with --strict). --- .github/workflows/renovate.yml | 7 ++++--- renovate.json | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml index f74df16..71d7668 100644 --- a/.github/workflows/renovate.yml +++ b/.github/workflows/renovate.yml @@ -2,9 +2,10 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -# DISABLED (Kevin, 2026-09-25): this workflow is turned off in the repository settings until -# Renovate is re-enabled with a GitHub App; until then no Renovate PRs are opened and pins and -# locks are raised by hand. The rest of this header describes the workflow once re-enabled. +# STATE (Kevin, 2026-09-25): this workflow is disabled in every faircomp repo (gh workflow disable, +# shown as disabled_manually). Nothing below runs and no Renovate pull requests arrive; pinned +# versions move only in reviewed pull requests raised by hand, until Renovate returns as a +# GitHub App, which replaces this workflow. The rest of this header describes it when enabled. # # Self-hosted Renovate — so digest bumps work without depending on the org-level # Renovate/Mend GitHub App. Runs weekly and on demand. It opens PRs that bump the diff --git a/renovate.json b/renovate.json index f48a385..d743609 100644 --- a/renovate.json +++ b/renovate.json @@ -1,15 +1,15 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "description": "Supply chain (stage A): keep every pinned input current through reviewable PRs -- the data-plane image digest, the hash-pinned Python lockfiles, the SHA-pinned actions, the digest-pinned build image, the pinned CI tools and the pinned Renovate engine. Nothing is automerged.", + "description": "Renovate is disabled, see renovate.yml: it raises nothing now, and pins are raised by hand in reviewed PRs. When enabled again, this config (supply chain, stage A) keeps every pinned input current through reviewable PRs -- the data-plane image digest, the hash-pinned Python lockfiles, the SHA-pinned actions, the digest-pinned build image, the pinned CI tools and the pinned Renovate engine. Nothing is automerged.", "extends": ["config:recommended", "docker:pinDigests", "helpers:pinGitHubActionDigests"], "automerge": false, "semanticCommits": "enabled", "docker-compose": { "enabled": true }, "pip-compile": { - "description": "The hash-pinned lockfiles packaging/build-venv.sh installs with --require-hashes. Renovate re-runs the command in each header (uv pip compile ... --generate-hashes) inside controlplane/; scripts/check-lockfiles.sh (CI job `lockfile`) proves the result.", + "description": "The hash-pinned lockfiles packaging/build-venv.sh installs with --require-hashes. When enabled, Renovate re-runs the command in each header (uv pip compile ... --generate-hashes) inside controlplane/; scripts/check-lockfiles.sh (CI job `lockfile`) proves the result.", "managerFilePatterns": ["/^controlplane/(build-)?requirements\\.lock$/"], "lockFileMaintenance": { - "description": "The only way the Python lockfiles move: the dependencies in pyproject.toml carry no version (Renovate skips them as unspecified-version) and the transitive ones are indirect (disabled by default). On every run (the workflow runs weekly) Renovate deletes each lockfile and re-runs its header command, i.e. a fresh resolution with fresh hashes, as ONE reviewable PR. The header's --exclude-newer=P7D keeps releases younger than a week out (minimumReleaseAge cannot: lock maintenance has no package timestamps). The schedule lives in the workflow cron only; the default (before 4am on monday) would never match it.", + "description": "When enabled: the only way Renovate moves the Python lockfiles (the dependencies in pyproject.toml carry no version, Renovate skips them as unspecified-version, and the transitive ones are indirect, disabled by default). On every run (the workflow then runs weekly) Renovate deletes each lockfile and re-runs its header command, i.e. a fresh resolution with fresh hashes, as ONE reviewable PR. The header's --exclude-newer=P7D keeps releases younger than a week out (minimumReleaseAge cannot: lock maintenance has no package timestamps). The schedule lives in the workflow cron only; the default (before 4am on monday) would never match it.", "enabled": true, "schedule": ["at any time"] } @@ -17,7 +17,7 @@ "customManagers": [ { "customType": "regex", - "description": "Bump the digest-pinned data-plane image (DEFAULT_IMAGE) in the control-plane code and the deploy examples. The reference is digest-only (@sha256:...), so we tell Renovate which tag's digest to follow via currentValueTemplate (the rolling :latest tag published by build-image).", + "description": "When enabled: bump the digest-pinned data-plane image (DEFAULT_IMAGE) in the control-plane code and the deploy examples. The reference is digest-only (@sha256:...), so we tell Renovate which tag's digest to follow via currentValueTemplate (the rolling :latest tag published by build-image).", "managerFilePatterns": [ "/^controlplane/lmnradius/models\\.py$/", "/^deploy/instances/[^/]+\\.ya?ml$/" @@ -49,7 +49,7 @@ }, { "customType": "regex", - "description": "Bump the PINNED CI tools (ruff/mypy/reuse/pytest/types-PyYAML, uv for the lockfile check) that ci.yml installs inside a `pip install` run-step. They are pinned so a linter widening its default rules cannot turn the pipeline red on its own; Renovate keeps them current as reviewable PRs. The version part accepts any number of dot-separated components (types-PyYAML uses four, e.g. 6.0.12.20260906).", + "description": "When enabled: bump the PINNED CI tools (ruff/mypy/reuse/pytest/types-PyYAML, uv for the lockfile check) that ci.yml installs inside a `pip install` run-step. They are pinned so a linter widening its default rules cannot turn the pipeline red on its own; Renovate then keeps them current as reviewable PRs. The version part accepts any number of dot-separated components (types-PyYAML uses four, e.g. 6.0.12.20260906).", "managerFilePatterns": ["/^\\.github/workflows/ci\\.yml$/"], "matchStrings": [ "(?ruff|mypy|reuse|pytest|types-PyYAML|uv)==(?[0-9]+(?:\\.[0-9]+)+)" @@ -59,7 +59,7 @@ ], "packageRules": [ { - "description": "Data-plane image: pin/update by immutable digest only. A human MUST merge (never auto-apply a new image to a school's live RADIUS).", + "description": "When enabled: the data-plane image is pinned and updated by immutable digest only. A human MUST merge (never auto-apply a new image to a school's live RADIUS).", "matchDatasources": ["docker"], "pinDigests": true, "automerge": false @@ -71,24 +71,24 @@ "enabled": false }, { - "description": "Build image digests in one PR, so ci.yml, release.yml and the Makefile always build with the same image. A human reviews and merges it.", + "description": "When enabled: build image digests in one PR, so ci.yml, release.yml and the Makefile always build with the same image. A human reviews and merges it.", "matchPackageNames": ["ghcr.io/linuxmuster/lmndev-runner"], "matchUpdateTypes": ["digest"], "groupName": "lmndev-runner build image", "automerge": false }, { - "description": "PyPI releases (the pinned CI tools) only once they are a week old, the window in which a compromised upload is usually noticed and yanked. PyPI only: ghcr.io gives no release timestamps, so an age rule on Docker would hold those updates forever (the workflow's Thursday cron is their age brake).", + "description": "When enabled, PyPI releases (the pinned CI tools) only once they are a week old, the window in which a compromised upload is usually noticed and yanked. PyPI only: ghcr.io gives no release timestamps, so an age rule on Docker would hold those updates forever (the workflow's Thursday cron is their age brake).", "matchDatasources": ["pypi"], "minimumReleaseAge": "7 days" }, { - "description": "Python lockfiles: every bump is a supply-chain change of the shipped venv; a human merges it after CI (lockfile, fast tier on the new versions, package, install and upgrade smoke) is green.", + "description": "When enabled: every Python lockfile bump is a supply-chain change of the shipped venv; a human merges it after CI (lockfile, fast tier on the new versions, package, install and upgrade smoke) is green.", "matchManagers": ["pip-compile"], "automerge": false }, { - "description": "Actions stay pinned by commit SHA with a # vN comment; a human merges every bump.", + "description": "Actions stay pinned by commit SHA with a # vN comment; when enabled, a human merges every bump.", "matchManagers": ["github-actions"], "automerge": false }, @@ -117,7 +117,7 @@ "enabled": false }, { - "description": "Renovate engine: one PR that moves along until it is merged.", + "description": "When enabled: one PR for the Renovate engine that moves along until it is merged.", "matchPackageNames": ["ghcr.io/renovatebot/renovate"], "groupName": "renovate engine", "automerge": false From b127b23face85ff16c4dd21151e5c1ef3552ece1 Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Sun, 27 Sep 2026 15:16:45 +0200 Subject: [PATCH 05/13] chore(claude): no lab endpoints in the versioned settings.json; crabbox is not usable now (A5) .claude/settings.json kept the crabbox provider settings (Proxmox API address, token id of the removed crabbox user, node, template, storage, bridge) in this public repository. They belong in the gitignored .claude/settings.local.json only; the versioned file keeps the crabbox permissions. The /test skill and CLAUDE.md say where the settings live and that crabbox cannot lease boxes until Kevin sets it up again. The history still holds the old values. --- .claude/settings.json | 10 ---------- .claude/skills/test/SKILL.md | 12 +++++++++--- CLAUDE.md | 8 +++++--- packaging/make-deb.sh | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.claude/settings.json b/.claude/settings.json index 66bedef..3054a83 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -1,14 +1,4 @@ { - "env": { - "CRABBOX_PROVIDER": "proxmox", - "CRABBOX_PROXMOX_API_URL": "https://192.168.250.2:8006", - "CRABBOX_PROXMOX_TOKEN_ID": "crabbox@pve!ci", - "CRABBOX_PROXMOX_NODE": "babo", - "CRABBOX_PROXMOX_TEMPLATE_ID": "9400", - "CRABBOX_PROXMOX_STORAGE": "raid5", - "CRABBOX_PROXMOX_BRIDGE": "vmbr1", - "CRABBOX_PROXMOX_INSECURE_TLS": "1" - }, "permissions": { "allow": [ "Bash(crabbox run:*)", diff --git a/.claude/skills/test/SKILL.md b/.claude/skills/test/SKILL.md index 3e416b3..0ba6997 100644 --- a/.claude/skills/test/SKILL.md +++ b/.claude/skills/test/SKILL.md @@ -18,9 +18,15 @@ which the sandboxed dev box lacks. This suite is **authored here, run by the operator**: crabbox leases an ephemeral Proxmox VM, rsyncs the working tree, runs the suite, and tears down. -Provider env (proxmox) comes from `.claude/settings.json` (the **non-secret** provider -config). The `CRABBOX_PROXMOX_TOKEN_SECRET` lives **only** in the gitignored -`.claude/settings.local.json` — never commit it. Confirm with `crabbox doctor`. +The provider settings (`CRABBOX_PROVIDER`, `CRABBOX_PROXMOX_*`: API URL, token id and +secret, node, template, storage, bridge) live **only** in the gitignored +`.claude/settings.local.json` (`env` block) — never in the versioned `.claude/settings.json`, +which holds only the crabbox permissions: they are internal details of Kevin's lab and this +repository is public. Confirm with `crabbox doctor`. + +> **State (2026-09-27): crabbox cannot lease boxes right now** — its Proxmox user was +> removed. Until Kevin sets it up again, the heavy tier does not run; say so in every +> report instead of claiming the E2E. ## Single-box flow (warm once → reuse the slug → stop) diff --git a/CLAUDE.md b/CLAUDE.md index 284770f..88d7e3e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -246,9 +246,11 @@ real docker-compose winbind/EAP E2E (**Samba AD DC + joined FreeRADIUS + `eapol_test` supplicant**) that proves *teacher→Access-Accept (+correct VLAN) / student-on-teacher-SSID→Access-Reject / wrong-password→Reject / non-`wifi` user→Reject*, as well as multischool, update/rollback, and `.deb` install tests — needs real Linux -with **Docker**. **crabbox** leases an ephemeral Proxmox VM for this (provider in -`.claude/settings.json`, token only in the gitignored `.claude/settings.local.json`; -`crabbox doctor`). Rules/details: the `/test` skill (`.claude/skills/test/SKILL.md`). +with **Docker**. **crabbox** leases an ephemeral Proxmox VM for this (provider settings and +token only in the gitignored `.claude/settings.local.json`, never in the versioned +`.claude/settings.json`; `crabbox doctor`). **Not usable at the moment** (2026-09-27): its +Proxmox user was removed, so the heavy tier does not run until Kevin sets it up again. +Rules/details: the `/test` skill (`.claude/skills/test/SKILL.md`). - **One aggregate runner:** `bash scripts/tests/run.sh [gate|lint|unit|quick|locks|e2e|all]` (created in P0/P1). Every mode but `e2e` runs the lock gate first (network needed); if it diff --git a/packaging/make-deb.sh b/packaging/make-deb.sh index 82c9983..248f9b8 100755 --- a/packaging/make-deb.sh +++ b/packaging/make-deb.sh @@ -18,7 +18,7 @@ # * modes as git records them (0644/0755, directories 0755), whatever the umask of the # checkout or of this build; mtimes = the changelog date; tracked symlinks stay symlinks. # Deliberate exclusions from the published source: .github (workflows) and .claude -# (developer tooling with internal endpoints/token ids); dpkg-source drops .gitignore files. +# (developer tooling for Claude Code, not part of the package); dpkg-source drops .gitignore files. # # git only reads here, and nothing configured in the checkout runs: git's ownership guard stays # on (no safe.directory waiver -- a checkout owned by another user is refused, as git refuses From 1dc103aa197dd037ce150801c20b1dda3d0af893 Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Sun, 27 Sep 2026 15:24:39 +0200 Subject: [PATCH 06/13] ci(release): every job is named 'release: ', never like a required ci.yml check (A1) The main ruleset requires the ci.yml jobs by name; lockfile, file-tree, install-smoke and upgrade-smoke exist in release.yml too, so a release run on the same commit could report a green check of the same name. Every release.yml job now carries the display name 'release: ' with the comment of linuxmusterDEV templates/release.yml (7a5f5ed); job keys and needs are unchanged. The unreadable-state branch of the post-publish check is taken from that template as well (one-line annotation). test_packaging.py: the lockfile jobs are equal but for the display name, and no release job carries a ci.yml check's name. --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 23 ++++++++++++++++++----- controlplane/tests/test_packaging.py | 16 +++++++++++++++- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7711a7b..fc27edc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: # build-requirements.in (an extra or missing pin), a pin younger than seven days, a hash PyPI # does not publish, or a locked version without a wheel for the target (CPython 3.12, # glibc 2.39, x86_64). The fast tier and the build (packaging/build-venv.sh) run the same - # gate first; release.yml carries this job character for character. + # gate first; release.yml carries this job character for character, but for its display name. lockfile: runs-on: ubuntu-24.04 steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c09aa94..8592db4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,7 +48,11 @@ on: default: '' jobs: + # Every job carries a display name with the prefix 'release: '. The main ruleset requires the + # ci.yml jobs BY NAME; a release run on the same commit (workflow_dispatch on a PR branch) + # with a job of the same name could otherwise stand in for a red ci.yml check. gate: + name: 'release: gate' runs-on: ubuntu-latest outputs: image: ${{ steps.meta.outputs.image }} @@ -72,10 +76,12 @@ jobs: echo "image=$IMG" >> "$GITHUB_OUTPUT"; echo "version=$VERSION" >> "$GITHUB_OUTPUT" # The lock gate (scripts/check-lockfiles.sh) as a release gate of its own (release needs it), - # character for character the `lockfile` job of ci.yml: a tag cannot be published while a - # lock drifted from its inputs (cold verification of the debian umbau, finding 5). The build - # runs the same gate first (packaging/build-venv.sh); nothing is installed around it (R2). + # character for character the `lockfile` job of ci.yml (but for the display name, see above): + # a tag cannot be published while a lock drifted from its inputs (cold verification of the + # debian umbau, finding 5). The build runs the same gate first (packaging/build-venv.sh); + # nothing is installed around it (R2). lockfile: + name: 'release: lockfile' runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 @@ -87,6 +93,7 @@ jobs: run: bash scripts/check-lockfiles.sh build: + name: 'release: build' needs: gate runs-on: ubuntu-latest container: @@ -133,6 +140,7 @@ jobs: # freeze == lock gates of the build. This gate is permanent, and release.yml carries the # same job (the run blocks are character-identical). file-tree: + name: 'release: file-tree' needs: build runs-on: ubuntu-latest # GitHub-hosted: gh is installed here, not in the container permissions: @@ -237,6 +245,7 @@ jobs: PY install-smoke: + name: 'release: install-smoke' needs: build runs-on: ubuntu-24.04 steps: @@ -272,6 +281,7 @@ jobs: # puts realistic config/state in place, upgrades to the freshly built package and # checks that nothing was lost. It skips itself on the very first release. upgrade-smoke: + name: 'release: upgrade-smoke' needs: build runs-on: ubuntu-24.04 permissions: @@ -525,6 +535,7 @@ jobs: run: sudo journalctl -u linuxmuster-radius.service --no-pager | tail -60 || true release: + name: 'release: release' needs: [gate, lockfile, build, file-tree, install-smoke, upgrade-smoke] if: github.ref_type == 'tag' runs-on: ubuntu-latest @@ -656,8 +667,10 @@ jobs: echo "::error::$TAG is published but NOT immutable, its assets can still be replaced: delete release $rid (the tag stays), turn immutable releases on, re-run this job" else # Unreadable is not "false": the release may well be immutable (and then cannot be - # replaced anyway), so never tell anyone to delete it on a failed read. - echo "::error::$TAG is published, but whether it is immutable could not be read (${immutable:-no answer}). Do not delete it: check with gh api repos/$GH_REPO/releases/$rid --jq .immutable; only if that prints false, delete release $rid (the tag stays), turn immutable releases on and re-run this job" + # replaced anyway), so never tell anyone to delete it on a failed read. One line, or + # the annotation shows only the first line of a multi-line error answer. + shown=${immutable//$'\n'/ } + echo "::error::$TAG is published, but whether it is immutable could not be read (${shown:-no answer}). Do not delete it: check with gh api repos/$GH_REPO/releases/$rid --jq .immutable; only if that prints false, delete release $rid (the tag stays), turn immutable releases on and re-run this job" fi exit 1 fi diff --git a/controlplane/tests/test_packaging.py b/controlplane/tests/test_packaging.py index 334438f..b446e10 100644 --- a/controlplane/tests/test_packaging.py +++ b/controlplane/tests/test_packaging.py @@ -118,11 +118,25 @@ def test_fast_tier_runs_the_gate_first_and_lockfile_jobs_are_only_the_gate() -> steps = _jobs(wf)["lockfile"]["steps"] assert [s["run"].strip() for s in steps if "run" in s] == [GATE_STEP] assert not any("setup-python" in s.get("uses", "") for s in steps) - assert _jobs("ci.yml")["lockfile"] == _jobs("release.yml")["lockfile"] + ci_lockfile, release_lockfile = ( + dict(_jobs("ci.yml")["lockfile"]), + dict(_jobs("release.yml")["lockfile"]), + ) + assert release_lockfile.pop("name") == "release: lockfile" + assert ci_lockfile == release_lockfile # the release waits for it assert "lockfile" in _jobs("release.yml")["release"]["needs"] +def test_release_jobs_never_carry_the_name_of_a_required_ci_check() -> None: + # The main ruleset requires the ci.yml jobs by name; a release.yml run on the same commit + # (workflow_dispatch on a PR branch) must not report a check that could stand in for one. + ci_names = {spec.get("name", key) for key, spec in _jobs("ci.yml").items()} + for key, spec in _jobs("release.yml").items(): + assert spec.get("name") == f"release: {key}", f"release.yml/{key}: display name" + assert spec["name"] not in ci_names + + def test_make_deb_never_waives_the_git_ownership_guard_wholesale() -> None: script = (ROOT / "packaging" / "make-deb.sh").read_text(encoding="utf-8") assert not re.search(r"safe\.directory\s*=\s*['\"]?\*", script) From d13ba69ed4e99cc7378b706aa427756504cf8530 Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Sun, 27 Sep 2026 15:32:10 +0200 Subject: [PATCH 07/13] fix(build,tests): nothing of the caller's environment runs before the gate; skipped is not green (A3, A4) A3 -- the caller's environment. check-lockfiles.sh, build-venv.sh, make-deb.sh, lock_gates.sh and make_deb_checks.sh start with one and the same block, before any other command (even `set`): every shell function of the caller is removed through `builtin` (so exported functions named set, export, unset, compgen or mapfile cannot keep the others; one named `builtin` can, the stated limit), PATH is fixed, and exactly VIRTUAL_ENV, CONDA_PREFIX, PYTHON*, UV_*, PIP_*, GIT_*, PERL5OPT, PERL5LIB, PERLLIB, PERL5DB, MAKEFILES, MAKEFLAGS, GNUMAKEFLAGS, BASH_ENV, ENV and CDPATH are dropped. So the make runs of debian/rules never read the caller's MAKEFILES or MAKEFLAGS (a `-- SHELL=` in MAKEFLAGS ran code there), and dpkg/debhelper never read PERL5OPT. CLAUDE.md, ADR-016, threat-model and test-strategy name exactly these variables and the limits (what bash does before line 1, a function named builtin, the caller's own make, dpkg's config, proxy/CA). test_packaging.py keeps the five blocks identical and first. Tests: lock_gates.sh R1 poisons with exported functions set/export/cd/unset/compgen/mapfile, PERL5OPT/PERL5LIB, CDPATH, and for directly started scripts MAKEFILES/MAKEFLAGS/GNUMAKEFLAGS; it shows each is sharp where nothing removes it, and (LOCK_GATES_DEB) runs make-deb.sh directly under all of it. make_deb_checks.sh builds the dirty checkout with make, Perl and CDPATH poison. k1_wheel.py ships a dirname too. A4 -- run.sh. It removes the caller's functions and CDPATH, BASH_ENV, ENV first and calls /usr/bin/dirname (cold verification r4, F1: a venv's dirname ran before the gate). A skipped step is no longer green: exit 77 if anything was skipped, 1 on a failure, 0 only if every step ran and passed; LMNRADIUS_ALLOW_SKIP=1 accepts skips on purpose. The last line names every step that was not checked, and what a failed gate kept from running. Offline, the gate and the build say "PyPI gave no answer (offline?)" (lockfile_gate.py pypi exits 3 when PyPI does not answer) instead of blaming the uv lock or a hash (cold verification r3, B5/B6). --- .claude/skills/test/SKILL.md | 4 +- CLAUDE.md | 31 ++++++-- controlplane/tests/test_packaging.py | 66 +++++++++++++++- docs/decisions.md | 23 ++++-- docs/test-strategy.md | 37 +++++++-- docs/threat-model.md | 8 +- packaging/build-venv.sh | 33 +++++--- packaging/make-deb.sh | 26 ++++-- scripts/check-lockfiles.sh | 47 +++++++---- scripts/lockfile_gate.py | 16 +++- scripts/tests/k1_wheel.py | 2 +- scripts/tests/lock_gates.sh | 113 +++++++++++++++++++++++---- scripts/tests/make_deb_checks.sh | 46 +++++++++-- scripts/tests/run.sh | 70 ++++++++++++----- 14 files changed, 418 insertions(+), 104 deletions(-) diff --git a/.claude/skills/test/SKILL.md b/.claude/skills/test/SKILL.md index 0ba6997..e5d2419 100644 --- a/.claude/skills/test/SKILL.md +++ b/.claude/skills/test/SKILL.md @@ -43,7 +43,9 @@ repository is public. Confirm with `crabbox doctor`. `.crabbox/captures/*.tar.gz` (logs, timings, ready-made stop command). 5. **Stop** when done: `crabbox stop --id `. -`run.sh` prints `N passed, M failed, K skipped` and exits non-zero on any failure. +`run.sh` prints `N passed, M failed, K skipped` plus every step that was not checked, and +exits 0 only if every step ran and passed: 1 on a failure, 77 if a step was skipped (a missing +tool, e2e without `LMNRADIUS_ALLOW_REAL=1`). `LMNRADIUS_ALLOW_SKIP=1` accepts skips on purpose. `e2e`/`all` refuse to run without `LMNRADIUS_ALLOW_REAL=1` (a guard so heavy suites never fire by accident on the dev box). diff --git a/CLAUDE.md b/CLAUDE.md index 88d7e3e..0cfed82 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -80,12 +80,26 @@ conventions are `../../docs/paket-konventionen.md` there. The rules that bite he gate) install fixture locks that pin only the test wheel, never the checkout's. It verifies all three locks — grammar, every hash on PyPI, pin set == closure of the declared inputs (uv re-resolves `pyproject.toml`/`build-requirements.in`) — and installs the uv it needs - itself, from the verified uv lock into an isolated venv, called by absolute path. The - gates run `/usr/bin/python3 -I`, set a fixed PATH and drop `VIRTUAL_ENV`, `PYTHON*`, - `UV_*` and `PIP_*` (and pip/uv config files), so an activated venv or a `.venv` in the - checkout takes no part. Not neutralized, a stated limit: `BASH_ENV`, exported shell - functions and proxy/CA variables (`HTTPS_PROXY`, `SSL_CERT_FILE`, `REQUESTS_CA_BUNDLE`, …) - — whoever sets those already runs code as the caller, or decides whom the gate trusts as PyPI. + itself, from the verified uv lock into an isolated venv, called by absolute path. + **The caller's environment:** `scripts/check-lockfiles.sh`, `packaging/build-venv.sh`, + `packaging/make-deb.sh`, `scripts/tests/lock_gates.sh` and `scripts/tests/make_deb_checks.sh` + start with one and the same block (`test_packaging.py` keeps them equal), before any other + command: it removes every shell function of the caller, through `builtin` (so functions named + `set`, `export`, `unset`, `compgen` or `mapfile` cannot keep the others), sets PATH to + `/usr/sbin:/usr/bin:/sbin:/bin` and drops exactly `VIRTUAL_ENV`, `CONDA_PREFIX`, `PYTHON*`, + `UV_*`, `PIP_*`, `GIT_*`, `PERL5OPT`, `PERL5LIB`, `PERLLIB`, `PERL5DB`, `MAKEFILES`, + `MAKEFLAGS`, `GNUMAKEFLAGS`, `BASH_ENV`, `ENV` and `CDPATH`; the gates also read no pip/uv + config file and run `/usr/bin/python3 -I`. So neither an activated venv nor a `.venv` in the + checkout, a function, nor a Perl (dpkg, debhelper) or make setting of the caller takes part; + the make runs of `debian/rules` never see the caller's `MAKEFILES`/`MAKEFLAGS`. + `scripts/tests/run.sh` removes the functions and `CDPATH`, `BASH_ENV`, `ENV` first and calls + `/usr/bin/dirname` before its gate (after the gate, lint and unit use the caller's tools on + purpose). Not neutralized, a stated limit: what bash does before a script's first line + (`BASH_ENV`, `SHELLOPTS`/`BASHOPTS`), a function named `builtin`, the caller's own `make` of + `make deb` (it reads `MAKEFILES`/`MAKEFLAGS` itself), dpkg-buildpackage's configuration files + and `DEB_*`/`DH_*` settings, `LD_PRELOAD`, and proxy/CA variables (`HTTPS_PROXY`, + `SSL_CERT_FILE`, `REQUESTS_CA_BUNDLE`, …) — whoever sets those already runs code as the + caller, or decides whom the gate trusts as PyPI. Limit: pins are compared with the closure by name; another real release of a pinned package (older or newer, a week old, genuine hashes) that satisfies the declared requirements passes every gate — only the review of the lockfile diff catches it. @@ -257,7 +271,10 @@ Rules/details: the `/test` skill (`.claude/skills/test/SKILL.md`). fails, run.sh stops there and runs nothing else. `quick` (default) = gate + lint + unit + the lock regression test; `e2e`/`all` run the Docker suites and **refuse without `LMNRADIUS_ALLOW_REAL=1`**. Summary: - `N passed, M failed, K skipped` (exit ≠ 0 on failure); steps dep-gated. + `N passed, M failed, K skipped`, then everything that was not checked (skipped, or not run + after a failed gate); steps dep-gated. Exit 0 only if every step ran and passed, 1 on a + failure, **77 if a step was skipped** (a missing tool, e2e without `LMNRADIUS_ALLOW_REAL=1`); + `LMNRADIUS_ALLOW_SKIP=1` accepts skips on purpose (exit 0, the last line still names them). - **Box lifecycle:** `crabbox warmup` → `crabbox run --id -- 'bash scripts/tests/crabbox_bootstrap.sh'` → `crabbox run --id -- 'LMNRADIUS_ALLOW_REAL=1 bash scripts/tests/run.sh e2e'` → `crabbox stop --id `. diff --git a/controlplane/tests/test_packaging.py b/controlplane/tests/test_packaging.py index b446e10..fd0f7a7 100644 --- a/controlplane/tests/test_packaging.py +++ b/controlplane/tests/test_packaging.py @@ -6,7 +6,9 @@ resolver uv is pinned by hash in its own lockfile, not as a bare ci.yml `uv==` line (K1), and no workflow step installs anything from a lockfile before the lock gate ran in that job (R2). scripts/tests/lock_gates.sh replays those steps with a planted package; these tests keep the -order from being edited away.""" +order from being edited away. The scripts a caller starts clean their environment with one and +the same block before any other command (A3), and run.sh calls nothing from the caller's PATH +before its gate (A4); lock_gates.sh (R1) and make_deb_checks.sh show that this holds.""" from __future__ import annotations @@ -146,3 +148,65 @@ def test_make_deb_never_waives_the_git_ownership_guard_wholesale() -> None: if line.lstrip().startswith("#"): continue assert line.strip() == 'git config --global --add safe.directory "$GITHUB_WORKSPACE"' + + +# The scripts a caller or the build starts: they clean their environment with one block (A3). +ENV_SCRIPTS = ( + "scripts/check-lockfiles.sh", + "packaging/build-venv.sh", + "packaging/make-deb.sh", + "scripts/tests/lock_gates.sh", + "scripts/tests/make_deb_checks.sh", +) +FUNCTIONS_FIRST = "builtin mapfile -t _fns < <(builtin compgen -A function)" + + +def _code(path: str) -> list[str]: + """The lines of a shell script without comment lines and blank lines.""" + text = (ROOT / path).read_text(encoding="utf-8") + return [ln for ln in text.splitlines() if ln.strip() and not ln.lstrip().startswith("#")] + + +def test_entry_scripts_clean_the_callers_environment_first_with_one_block() -> None: + blocks = {} + for path in ENV_SCRIPTS: + code = _code(path) + # before anything else, even `set`: a function of the caller may be named set + assert code[0] == FUNCTIONS_FIRST, f"{path}: the first command must remove the functions" + end = code.index("done") + assert code[end + 1].startswith("set -"), f"{path}: `set` comes right after the block" + blocks[path] = code[: end + 1] + first = blocks[ENV_SCRIPTS[0]] + for path, block in blocks.items(): + assert block == first, f"{path}: its environment block differs from {ENV_SCRIPTS[0]}'s" + assert first[1] == 'builtin unset -f -- "${_fns[@]}"' + text = "\n".join(first) + for name in ( + "VIRTUAL_ENV", + "CONDA_PREFIX", + "PYTHON*", + "UV_*", + "PIP_*", + "GIT_*", + "PERL5OPT", + "PERL5LIB", + "PERLLIB", + "PERL5DB", + "MAKEFILES", + "MAKEFLAGS", + "GNUMAKEFLAGS", + "BASH_ENV", + "ENV", + "CDPATH", + ): + assert re.search(rf"(^|[\s|]){re.escape(name)}(\s|$|\))", text), name + + +def test_run_sh_calls_nothing_from_the_callers_path_before_its_gate() -> None: + code = _code("scripts/tests/run.sh") + assert code[0] == FUNCTIONS_FIRST + assert code[1] == 'builtin unset -f -- "${_fns[@]}"' + before_gate = code[: next(i for i, ln in enumerate(code) if ln.startswith("summary()"))] + assert any("/usr/bin/dirname" in ln for ln in before_gate) + for ln in before_gate: + assert not re.search(r"(? int: # PyPI would only fail every further pin after the same retries. try: known = published(pin) + # PyPI answered (e.g. 404: no such release), or gave no answer at all + # (URLError, TimeoutError and other OSErrors: offline, DNS). + except urllib.error.HTTPError as e: + errors.append(f"{path}: {pin}: cannot read PyPI: {e}") + return report(errors, "") + except (urllib.error.URLError, OSError) as e: + errors.append( + f"{path}: {pin}: cannot read PyPI, no answer (offline?): {e}" + ) + report(errors, "") + return UNREACHABLE except Exception as e: errors.append(f"{path}: {pin}: cannot read PyPI: {e}") return report(errors, "") diff --git a/scripts/tests/k1_wheel.py b/scripts/tests/k1_wheel.py index 01c8fa7..12c37e3 100755 --- a/scripts/tests/k1_wheel.py +++ b/scripts/tests/k1_wheel.py @@ -28,7 +28,7 @@ TOOLS = ( "diff comm sort awk grep cut cp python3 python pip uv sed tar git mktemp find env xargs " - "head tail wc tr cat rm mv chmod touch readlink bash" + "head tail wc tr cat rm mv chmod touch readlink bash dirname" ).split() diff --git a/scripts/tests/lock_gates.sh b/scripts/tests/lock_gates.sh index 59c99de..90b6212 100755 --- a/scripts/tests/lock_gates.sh +++ b/scripts/tests/lock_gates.sh @@ -23,8 +23,11 @@ # write the marker, and so does its .pth; # R1 the gates are not steered by these parts of the caller's environment: an activated # venv (bin/ first on PATH, VIRTUAL_ENV), a .venv in the checkout, PYTHONPATH/PYTHONHOME, -# UV_*/PIP_* variables and config files that redirect the index or the interpreter -- no -# marker, same verdicts; +# UV_*/PIP_* variables and config files that redirect the index or the interpreter, +# exported shell functions named like the builtins the scripts call (set, export, cd, +# unset, compgen, mapfile), MAKEFILES/MAKEFLAGS/GNUMAKEFLAGS, PERL5OPT/PERL5LIB and +# CDPATH (A3) -- no marker, same verdicts; each of these parts is shown to run code +# where nothing removes it; # R2 the lock-related steps of ci.yml and release.yml (extracted word for word by # scripts/tests/ci_step.py) stop at the gate with a planted package, before anything is # installed; the counter-probe without the gate step installs it and the marker appears. @@ -36,15 +39,25 @@ # refusal's reason. LOCK_GATES_DEB=1 also runs the whole `make deb` (dpkg-buildpackage) on each # tampered tree and requires it to fail without a .deb and without a marker; run that inside # the build image, as a user who may write the checkout, after `apt-get build-dep .` (the -# command is in the Makefile). The harness drops the same PATH/PYTHON*/UV_*/PIP_*/GIT_* parts of -# its environment as the gates. -set -uo pipefail - +# command is in the Makefile). The harness cleans its own environment with the same block as the +# gates. +# The caller's environment, before any other command (CLAUDE.md, "Python dependencies", names +# what is removed and what is left as the limit): first the shell functions, through `builtin`, +# so that a function named set, export, unset, compgen or mapfile cannot keep the others; then a +# fixed PATH and none of the variables that point Python, pip, uv, git, Perl (dpkg), make or bash +# at other code. +builtin mapfile -t _fns < <(builtin compgen -A function) +builtin unset -f -- "${_fns[@]}" +builtin unset _fns export PATH=/usr/sbin:/usr/bin:/sbin:/bin -unset VIRTUAL_ENV CONDA_PREFIX for v in $(compgen -e); do - case "$v" in PYTHON* | UV_* | PIP_* | GIT_*) unset "$v" ;; esac + case "$v" in + VIRTUAL_ENV | CONDA_PREFIX | PYTHON* | UV_* | PIP_* | GIT_* | PERL5OPT | PERL5LIB \ + | PERLLIB | PERL5DB | MAKEFILES | MAKEFLAGS | GNUMAKEFLAGS | BASH_ENV | ENV | CDPATH) + unset "$v" ;; + esac done +set -uo pipefail export PIP_CONFIG_FILE=/dev/null PIP_DISABLE_PIP_VERSION_CHECK=1 ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" @@ -352,8 +365,9 @@ bash "$dir/packaging/build-venv.sh" "$dir/v" > "$TMP/out" 2>&1 marker_from_bin "R6 counter-probe: build-venv.sh without the gate" # ------------------------------------------------ R1: these parts of the caller's environment -# (BASH_ENV, exported shell functions and proxy/CA variables are the documented limit, not -# tested here: whoever sets them already runs code as the caller) +# (what bash does before a script's first line -- BASH_ENV, SHELLOPTS -- a function named +# `builtin` and proxy/CA variables are the documented limit, not tested here: whoever sets them +# already runs code as the caller) # An activated venv P with the wheel installed: its bin/ (diff, sort, awk, grep, python3, uv, # pip, bash, ...) first on PATH, VIRTUAL_ENV=P, UV_PYTHON pointing into it; PYTHONPATH with a # sitecustomize that writes the marker; PYTHONHOME that breaks every non-isolated Python; @@ -378,6 +392,64 @@ POISON=(env "PATH=$P/bin:/usr/sbin:/usr/bin:/sbin:/bin" "VIRTUAL_ENV=$P" "UV_FIND_LINKS=$WHEELDIR" "UV_CONFIG_FILE=$TMP/r1-uv.toml" "PIP_INDEX_URL=http://127.0.0.1:9/simple" "PIP_FIND_LINKS=$WHEELDIR" "PIP_CONFIG_FILE=$TMP/r1-pip.conf" "GIT_CONFIG_PARAMETERS='core.fsmonitor'='$TMP/r1-fsmonitor'") +# A3: exported functions named like the builtins the scripts call before and while they clean +# their environment (each writes the marker, then does what the builtin does); Perl's own +# variables, which dpkg-parsechangelog, dpkg-buildpackage and debhelper read; CDPATH, which +# would send `cd scripts/..` of a script started by a relative path into $TMP/r1-cdpath. +mkdir -p "$TMP/r1-perl" "$TMP/r1-cdpath/scripts/tests" "$TMP/r1-cdpath/packaging" +printf 'open(my $m, ">>", "%s"); print $m "perl ran PERL5OPT: $0\\n"; close $m; 1;\n' "$MARK" \ + > "$TMP/r1-perl/ZzzPoison.pm" +for f in set export cd unset compgen mapfile; do + POISON+=("BASH_FUNC_$f%%=() { echo \"function $f ran\" >> '$MARK'; builtin $f \"\$@\"; }") +done +POISON+=("PERL5OPT=-MZzzPoison" "PERL5LIB=$TMP/r1-perl" "CDPATH=$TMP/r1-cdpath") +# make's own variables go only to the scripts started directly (POISON_MAKE): `make deb` is the +# caller's own make, which reads them before make-deb.sh starts (the stated limit); make-deb.sh +# must keep them from the make runs of debian/rules. MAKEFILES adds a makefile that writes the +# marker; MAKEFLAGS and GNUMAKEFLAGS set make's SHELL to a script that writes the marker. +printf '$(shell echo "MAKEFILES read by make in $(CURDIR)" >> %s)\n' "$MARK" > "$TMP/r1-poison.mk" +printf '#!/bin/sh\necho "make SHELL from MAKEFLAGS ran in $PWD" >> %s\nexec /bin/sh "$@"\n' "$MARK" \ + > "$TMP/r1-make-shell" +chmod +x "$TMP/r1-make-shell" +POISON_MAKE=("MAKEFILES=$TMP/r1-poison.mk" "MAKEFLAGS=-- SHELL=$TMP/r1-make-shell" + "GNUMAKEFLAGS=-- SHELL=$TMP/r1-make-shell") +# Each new part of the poison is sharp: where nothing removes it, it runs code. +sharp() { #