linux-boot: harden boot-inner.sh and configure-worktree.sh #2305
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2305
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/linux-boot-inner-configure-safety"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: LINUX-BOOT-INNER-AND-CONFIGURE-WORKTREE-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193109369)
What and why
scripts/linux-boot/boot-inner.sh:BOOT_AGENT,BOOT_N,BOOT_SECS,GTA6RT) upfront (single path segment checks forBOOT_AGENT/BOOT_N, non-negative integer checks forBOOT_SECS/WAIT_ITERS/LEONIDA_BOOT_MIN_FREE_MB) with exit code2before creating or truncating files, andmkdir -pwork/root directories before opening logs or locks.flockwithcommand -v flock, select the cgroup v20::entry cleanly from/proc/self/cgroup, coerce non-digit cgroup values such as"max"to0viaread_uint()before shell arithmetic, and register a signal-safecleanup()trap (EXIT,INT,TERM) to reap the background sampler subshell immediately.LEONIDA_BOOT_ROOT,LEONIDA_BOOT_WORK,BOOT_SH,NVIDIA_SMI,LEONIDA_MEMINFO_PATH,LEONIDA_SELF_CGROUP_PATH,LEONIDA_CGROUP_ROOT,LEONIDA_WAIT_SLEEP_SECS,LEONIDA_SAMPLE_SLEEP_SECS, andLEONIDA_WAIT_ITERSoverrides for testing.scripts/linux-boot/configure-worktree.sh:-h/--help(exit0), validate argument count, worktree directory existence,runtime/CMakeLists.txt,runtime/cmake/clang-cl-xwin.cmake,CMAKEexecutable availability, and optionalSDL3_SRCdirectory upfront with exit code2.cmake_argsarray so paths andSDL3_SRCcontaining spaces remain intact single argv tokens instead of undergoing unquoted word splitting.tests/test_linux_boot_inner_and_configure.py(verifying LF line endings,bash -nsyntax, validation exits, cgroup"max"sampling, exit124mapping, and spaced worktree/SDL3_SRCpaths).Tested
python -I tests/test_linux_boot_inner_and_configure.py -v(via Git Bash): 4 passed, 0 failed (detachedupstream/mainbaseline with only the new test file fails with 8 subtest/test failures).python -I tests/test_ci_registration.py: 16 passed.python -I tests/test_text_write_line_endings.py: 3 passed.python -I scripts/check_no_game_data.py,python -I -m compileall -q tests/test_linux_boot_inner_and_configure.py, andgit diff --cached --check: passed.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.#2305 | head 9a2ac71066ee1cfc23b39c6b4b4b121ed2ab72d0 (merged cleanly with main 3ca0707dd) |
python -I tests/test_linux_boot_inner_and_configure.py| red on main:FAILED (failures=1)on-k test_configure_worktree_help_validation_and_spaced_paths(1 != 0, andboot-inner.shonmainenters its hardcoded40 x 15swait loop instead of rejecting invalid env vars with exit2) | green on PR+main:4 tests OK(-k test_boot_inner_handles_cgroup_max_and_timeout_exit_124:1 test OK) | Windows 11, Python 3.12.10 (Git Bash) | AI-assisted: yesAudited
scripts/linux-boot/boot-inner.shandconfigure-worktree.sh(upfrontBOOT_AGENT/BOOT_Npath-segment and integer env validation,maxcgroup handling viaread_uint, sampler cleanup trap, and--help/ spaced-path CMake argument array handling), and verified bothPR + main(3ca0707dd) and a combinedmain + #2305 + #2298merge (0conflicts;4 OK+4 OK). Also passedtests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK),tests/test_runner_calls_all_tests.py(3 OK), andscripts/check_no_game_data.py.Red/green: tests/test_linux_boot_inner_and_configure.py fails 8 assertions on main (boot-inner.sh/configure-worktree.sh do not validate env vars, cgroup max or timeout 124) and passes with the PR (cloud run on main 7daa4a4).
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 7daa4a4a5 in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)