fix(#550): mkdir before chown -R in prepare_directories and reset_dashboard#574
Merged
Conversation
…hboard Both functions chown -R'd a data-dir tree to APP_UID and THEN ran an unprivileged mkdir -p inside it — EACCES for any operator uid != 1000, and in reset-dashboard the set -e abort landed after the data wipe, stranding the install with no dashboard containers. Reorder to match ensure_directories: every mkdir first, chown -R last. Pin the order with a shadow-sudo/mkdir regression test in tests/stack/run.sh. Closes #550 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #550
Summary
prepare_directoriesandreset_dashboardransudo chown -Ron a data-dir tree and then an unprivilegedmkdir -p "$P2POOL_DIR/stats"inside it. For any operator uid ≠ 1000 (APP_UID/APP_GIDare hardcoded), the mkdir gets EACCES andset -eaborts — inreset-dashboardthe abort lands after the data wipe and before the containers come back up, stranding the install.Both functions now match
ensure_directories: everymkdir -pfirst,chown -Rlast. Pure reordering — no new helpers.prepare_directories(pithead):mkdir -p "$P2POOL_DIR/stats"moved above the twochown -Rlines.reset_dashboard(pithead):mkdir -p "$p2pool_dir/stats"moved above thechown -R.Other
chown -Rsites checkedGrepped
pitheadfor everychown -R; besides the two fixed:stack_restore(~line 1342):chown -R 100:101 "$TOR_DATA_DIR"— followed only by conditionalensure_ownercalls on other trees; no unprivileged write intoTOR_DATA_DIRafter the chown. Clean.ensure_owner(~line 2787): the reference-correct helper (ensure_directoriescalls it after all mkdirs). Clean.provision_onion_client_auth(~line 2952):$run chown -Ris the last op on$hs_dir, and every preceding write already uses the same$run(sudo) elevation. Clean.CONTROL_DIR/CADDY_LOG_DIR/CLEARNET_STATE_DIRinprepare_control_dirsare sibling trees underdata/, not inside any chowned dir. Clean.Tests (tier 1,
tests/stack/run.sh)New ordering-pin regression block (
== regression: mkdir runs before chown -R of the same tree (#550) ==), using the existing function-shadowing pattern (same technique as the #291fw_then_composeblock): shadowmkdir/sudoto emitmkdir-stats/chown-p2poolsentinels and assert the mkdir sentinel precedes the chown sentinel in bothprepare_directoriesandreset_dashboard.make lint: passtests/stack/run.shon this branch: 1271 passed, 0 failedRevert-proof: with the pithead reordering reverted (tests kept), both new assertions fail:
🤖 Generated with Claude Code