Pass MY_PI_PASSWORD_HASH through to the image build #149

Merged
aluminum-ice merged 1 commit from pi-password-hash into main 2026-11-01 23:32:05 +00:00
Owner

What this PR does

Makes a custom pi password hash given at build time actually reach the image. The documented way, the MY_PI_PASSWORD_HASH environment variable, never got past sudo env ... packer build and the ansible-local command, so every build used the documented default.

  • Makefile:
    • Read unexpanded: reads MY_PI_PASSWORD_HASH with $(value ...) into KESTREL_PI_HASH, so make doesn't take $6, $salt... for its own variables. It works from the command line or the environment.
    • Passed without being echoed: exports the value to the image recipe as an environment variable, so make's echo of the recipe shows $KESTREL_PI_HASH, never the hash.
    • Checked first: when set, the value must be one crypt string ($id$ followed by ./0-9A-Za-z$=, no newline), or the build stops with "MY_PI_PASSWORD_HASH is not a crypt hash" before Packer starts.
    • Handed to Packer as -var "my_pi_password_hash=$KESTREL_PI_HASH".
  • builder/config.json: declares my_hostname, my_version and my_pi_password_hash under variables, lists the hash in sensitive-variables (Packer masks it in its output), and adds MY_PI_PASSWORD_HASH='...' to the ansible-local command beside MY_VERSION/MY_HOSTNAME. The value checked by the Makefile can't contain a quote.
  • builder/config.yml: the system.account.pi lookup is unchanged. Two early tasks are added:
    • an assert that the login is a crypt hash;
    • a log line, "login: custom hash" or "login: the documented default" (never the value).
  • Docs: README ("Login"), the first-boot guide's "Building your own image" and CLAUDE.md give the working command with the single quotes the hash needs: sudo make image MY_PI_PASSWORD_HASH='$6$...'.

Checklist

  • Lint passes — make lint (ansible --syntax-check, yamllint, shellcheck --severity=error, and the real-data check). The Lint workflow runs this on the PR.
  • Tests pass — make test (the kestrel_pi pytest suite and the real-data check's tests). The Test workflow runs this on the PR.
  • Nothing real: no secrets, no personal information, no real data. This is a public repository. The diff contains no real account passwords or hashes, Wi-Fi passphrases, private keys, API tokens, .env files, real names, personal emails, device serials, and no real captured or device data: SSIDs, MAC addresses, GPS coordinates, capture files, diagnostics bundles, logs, or screenshots of a real device — placeholders only. The real-data check catches MACs, emails, keys and capture files; real SSIDs, coordinates and screenshots are on you.
  • Consent gates intact. Capture and network plugins still ship disabled, enabling them still takes the authorized-use acknowledgment (never pre-ticked or given by code), and the capture whitelist is still enforced.
  • Docs updated in the same PR, if this changes something an operator sees or configures: the README package table, the relevant page under docs/, and the on-device operator guide (GUIDE_MD in kestrel_pi/userguide.py) where it applies.
  • Commit messages are short and imperative.

Release impact

  • App-layer-safe — changes only files the in-place update engine carries: the kestrel_pi package, plugins/*.py, systemd units, the journald drop-in, a lib script already in the engine's LIB_SCRIPTS, or the CLI.
  • Reflash-class — touches a build input the engine does not carry onto a running device: apt or pip packages, boot options / config.txt / cmdline, kernel modules, the base image or partition size, builder/config.json, builder/config.yml, the Makefile, the Release workflow (.forgejo/workflows/main.yml), a shipped config default (config.toml / default.conf), or a brand-new lib script.

Notes for review

  • Release kind: the box above is ticked because this touches build inputs, so the Release workflow's auto will call 1.0.13 reflash. Nothing an image contains changes, though: the official build sets no hash and still gets the documented default, and the new playbook tasks only check and log. Every hunk is build-host plumbing. So 1.0.13 should be released with update_kind=app-layer.
  • How the hash reaches the playbook: through the Makefile, then Packer's -var, then the ansible command's environment. sudo doesn't matter now, because the value goes as an argument, not as inherited environment.
  • Checked without a full build:
    • packer validate -syntax-only passes, and full packer validate passes with a sample hash.
    • make -n image MY_PI_PASSWORD_HASH='$6$...' shows $KESTREL_PI_HASH in the echoed Packer line, not the hash.
    • The recipe's check, run with the real lines: it passes an empty value, a $6$ hash, a $y$ hash and a rounds= hash, from the command line and the environment. It stops a quote-and-command value, plain text, and values with a newline.
    • The playbook's two tasks, run with local ansible: they log the default with no hash, "custom hash" with one, and fail on a non-hash.
  • Still to prove: an image built with a hash, by checking the pi: line of /etc/shadow in the mounted image after the next local build.
  • Locally: the suite passes except the two tests that depend on this host (the daemon SIGHUP test and the GPS serial-device test); CI runs both.

🤖 Generated with Claude Code

## What this PR does Makes a custom `pi` password hash given at build time actually reach the image. The documented way, the `MY_PI_PASSWORD_HASH` environment variable, never got past `sudo env ... packer build` and the ansible-local command, so every build used the documented default. - **`Makefile`:** - **Read unexpanded:** reads `MY_PI_PASSWORD_HASH` with `$(value ...)` into `KESTREL_PI_HASH`, so make doesn't take `$6`, `$salt`... for its own variables. It works from the command line or the environment. - **Passed without being echoed:** exports the value to the image recipe as an environment variable, so make's echo of the recipe shows `$KESTREL_PI_HASH`, never the hash. - **Checked first:** when set, the value must be one crypt string (`$id$` followed by `./0-9A-Za-z$=`, no newline), or the build stops with "MY_PI_PASSWORD_HASH is not a crypt hash" before Packer starts. - **Handed to Packer** as `-var "my_pi_password_hash=$KESTREL_PI_HASH"`. - **`builder/config.json`:** declares `my_hostname`, `my_version` and `my_pi_password_hash` under `variables`, lists the hash in `sensitive-variables` (Packer masks it in its output), and adds `MY_PI_PASSWORD_HASH='...'` to the ansible-local command beside `MY_VERSION`/`MY_HOSTNAME`. The value checked by the Makefile can't contain a quote. - **`builder/config.yml`:** the `system.account.pi` lookup is unchanged. Two early tasks are added: - an assert that the login is a crypt hash; - a log line, "login: custom hash" or "login: the documented default" (never the value). - **Docs:** README ("Login"), the first-boot guide's "Building your own image" and CLAUDE.md give the working command with the single quotes the hash needs: `sudo make image MY_PI_PASSWORD_HASH='$6$...'`. ## Checklist - [x] **Lint passes** — `make lint` (ansible `--syntax-check`, `yamllint`, `shellcheck --severity=error`, and the real-data check). The **Lint** workflow runs this on the PR. - [x] **Tests pass** — `make test` (the `kestrel_pi` pytest suite and the real-data check's tests). The **Test** workflow runs this on the PR. - [x] **Nothing real: no secrets, no personal information, no real data.** This is a public repository. The diff contains no real account passwords or hashes, Wi-Fi passphrases, private keys, API tokens, `.env` files, real names, personal emails, device serials, and no real captured or device data: SSIDs, MAC addresses, GPS coordinates, capture files, diagnostics bundles, logs, or screenshots of a real device — placeholders only. The real-data check catches MACs, emails, keys and capture files; real SSIDs, coordinates and screenshots are on you. - [x] **Consent gates intact.** Capture and network plugins still ship disabled, enabling them still takes the authorized-use acknowledgment (never pre-ticked or given by code), and the capture whitelist is still enforced. - [x] **Docs updated in the same PR**, if this changes something an operator sees or configures: the README package table, the relevant page under `docs/`, and the on-device operator guide (`GUIDE_MD` in `kestrel_pi/userguide.py`) where it applies. - [x] Commit messages are short and imperative. ## Release impact - [ ] **App-layer-safe** — changes only files the in-place update engine carries: the `kestrel_pi` package, `plugins/*.py`, systemd units, the journald drop-in, a lib script already in the engine's `LIB_SCRIPTS`, or the CLI. - [x] **Reflash-class** — touches a build input the engine does not carry onto a running device: apt or pip packages, boot options / `config.txt` / `cmdline`, kernel modules, the base image or partition size, `builder/config.json`, `builder/config.yml`, the `Makefile`, the Release workflow (`.forgejo/workflows/main.yml`), a shipped config default (`config.toml` / `default.conf`), or a brand-new lib script. ## Notes for review - **Release kind:** the box above is ticked because this touches build inputs, so the Release workflow's `auto` will call 1.0.13 reflash. Nothing an image contains changes, though: the official build sets no hash and still gets the documented default, and the new playbook tasks only check and log. Every hunk is build-host plumbing. So 1.0.13 should be released with `update_kind=app-layer`. - **How the hash reaches the playbook:** through the Makefile, then Packer's `-var`, then the ansible command's environment. `sudo` doesn't matter now, because the value goes as an argument, not as inherited environment. - **Checked without a full build:** - `packer validate -syntax-only` passes, and full `packer validate` passes with a sample hash. - `make -n image MY_PI_PASSWORD_HASH='$6$...'` shows `$KESTREL_PI_HASH` in the echoed Packer line, not the hash. - The recipe's check, run with the real lines: it passes an empty value, a `$6$` hash, a `$y$` hash and a `rounds=` hash, from the command line and the environment. It stops a quote-and-command value, plain text, and values with a newline. - The playbook's two tasks, run with local ansible: they log the default with no hash, "custom hash" with one, and fail on a non-hash. - **Still to prove:** an image built with a hash, by checking the `pi:` line of `/etc/shadow` in the mounted image after the next local build. - **Locally:** the suite passes except the two tests that depend on this host (the daemon SIGHUP test and the GPS serial-device test); CI runs both. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Pass MY_PI_PASSWORD_HASH through to the image build
All checks were successful
Test / test (pull_request) Successful in 33s
Lint / lint (pull_request) Successful in 34s
Test / test (push) Successful in 33s
Lint / lint (push) Successful in 34s
7adac9c0ed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aluminum-ice deleted branch pi-password-hash 2026-11-01 23:32:05 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aluminum-ice/kestrel!149
No description provided.