mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 17:54:03 +01:00
The split referenced $_NL_PAYLOAD_DIR from both install functions but
defined it nowhere, so `setup_night_lockdown.sh setup` would have died
with an unbound variable partway through installing the lockdown. My
earlier scratch verification set the variable by hand, which is exactly
what hid the bug: the emitted artifacts hashed correctly while the real
entry path could not have reached them.
It is now defined in each lib that uses it, eight lines above the use,
via `: "${_NL_PAYLOAD_DIR:=...}"` so an explicit override still wins. A
definition placed in the entry script was silently stripped by an
autoformat pass three times during this work, and a half-run lockdown
installer is not an acceptable failure mode.
Also drops two zero-byte payload files left behind by the .sh -> .sh.in
rename.
Re-verified without presetting anything: install_enter_script and
install_unlock_script emit mode-0755 files hashing 4baaf405... and
eafce28d..., byte-identical to the live /usr/local/bin copies. help and
an unknown command match their baselines; status differs only by the
05:00 countdown ticking 13h to 12h between runs.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
53 lines
4.8 KiB
JSON
53 lines
4.8 KiB
JSON
{
|
|
"intent": "Bring setup_night_lockdown.sh (918 lines) under the 250-line cap, without changing a byte of the two scripts it deploys to /usr/local/bin — one of which is executed by night-lockdown-unlock.timer, which is enabled and fires at 05:00.",
|
|
"scope": [
|
|
"setup_night_lockdown.sh: 918 -> 127 lines",
|
|
"New libs: nl_enter.sh, nl_unlock.sh, nl_units.sh (100), nl_config.sh (125), nl_commands.sh (82)",
|
|
"New payloads: lib/payloads/night-lockdown-enter.sh.in (279), night-lockdown-unlock.sh.in (212)",
|
|
"Non-goal: running `setup`. It masks the TTY login surface and tears down the GUI; the only recovery is SSH."
|
|
],
|
|
"changes": [
|
|
"Moved the real top-level functions into five libs with extract_shell_functions.py. The apparent functions at lines 218/233/244/251/266 and 506/522/551 of the original are NOT top-level: they live inside the two big quoted heredocs and belong to the generated scripts. Each heredoc was therefore treated as one atomic unit.",
|
|
"The two heredoc bodies became verbatim payload FILES rather than inline text. Both heredocs were quoted (<<'ENTER_EOF' / <<'UNLOCK_EOF'), so their bodies were already literal with no expansion — moving them to files is exactly equivalent, and it is what brings the libs under the cap.",
|
|
"The payloads carry a .sh.in extension. They are deployment artifacts byte-pinned to the installed copy, not hand-edited shell source, so they sit outside the cap's scope the same way third_party/ does — decided by the user after being shown the alternative of splitting the 279-line enter payload.",
|
|
"DEFECT FOUND AND FIXED -- $_NL_PAYLOAD_DIR was referenced by both install functions and defined nowhere, so `setup_night_lockdown.sh setup` would have died with 'unbound variable' partway through installing the lockdown. Reproduced directly. It is now defined in the same file as its use, eight lines above it: a definition placed in the entry script was silently stripped by an autoformat pass three separate times during this work, and this installer is not something that can be allowed to half-run."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "sha256sum of the emitted artifacts vs the LIVE deployed files",
|
|
"result": "pass",
|
|
"evidence": "THE decisive check. Running the split install_enter_script/install_unlock_script against redirected destinations emits 4baaf405ccee8824... and eafce28d826bb160..., which are byte-for-byte the current /usr/local/bin/night-lockdown-enter.sh and night-lockdown-unlock.sh. The payload files hash identically to the heredoc bodies extracted from the pre-split file, so the chain original-body == payload == emitted == deployed is closed. Modes are 0755 as before."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/check_file_length.sh --all",
|
|
"result": "pass",
|
|
"evidence": "Over-cap list went from 3 files to 2. Confirmed with the payloads git-tracked (git add -N), since the gate only sees tracked files — an untracked payload would have given a false pass."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/verify_shell_split.sh HEAD <old> <old> <5 libs>",
|
|
"result": "pass",
|
|
"evidence": "Eleven additions and no -/+ pair on any name: every moved function is byte-identical."
|
|
},
|
|
{
|
|
"command": "diff of `status` and `--help` against pre-split baselines",
|
|
"result": "pass",
|
|
"evidence": "--help byte-identical. `status` differed by one character — the countdown to the 05:00 timer ticked from '13h' to '12h' between the two runs. Live clock state, not a code change; every other line matches."
|
|
},
|
|
{
|
|
"command": "bash -n on both payloads; shellcheck + shfmt on entry and libs",
|
|
"result": "pass",
|
|
"evidence": "Both payloads parse as standalone scripts. shellcheck rc=0 with no suppressions; shfmt -w is a no-op; the hyphenated-key canary is clean."
|
|
}
|
|
],
|
|
"risks": [
|
|
"The deployed copies are NOT touched by this commit and remain byte-identical to what the split now produces, so the 05:00 unlock timer is unaffected whether or not `setup` is ever re-run.",
|
|
"`setup` itself is never executed under test — it masks getty/autovt and tears down the GUI, with SSH as the only recovery. Its correctness rests on the emitted-artifact hash equality above plus the unchanged-function proof, not on a live run.",
|
|
"The .sh.in convention is new. A future payload that is genuinely hand-edited source would inherit an exemption it should not have; the extension is the signal that a file is a verbatim deployment artifact."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; setup_night_lockdown.sh returns to one 918-line file and lib/nl_*.sh plus lib/payloads/ disappear.",
|
|
"Nothing to undo on the live system — no deployed file was written.",
|
|
"After rollback, re-run the emitted-artifact hash check against /usr/local/bin to confirm the reverted heredocs still produce 4baaf405... and eafce28d..."
|
|
]
|
|
}
|