🐛 fix(pacman): remove the render dir on every refresh exit
- 🐛 a failed render, a refused sudo prompt, or a signal left the scratch directory behind; repeated attempts piled them up - 🔒 the cleanup runs before the sudo revocation, which stays the last step of the exit path Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SdXqTwm63rRMwotZ1xqLC8
This commit is contained in:
1 parent
50a26be6a7
commit
6be88d14a5
2 files changed
+30
-1
No files matched your search
@@ -31,8 +31,16 @@ if [[ $channel != "stable" && $channel != "rc" && $channel != "edge" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Render the channel templates plus this machine's regional additions as the
|
# Render the channel templates plus this machine's regional additions as the
|
||||||
# caller, so root only copies finished files.
|
# caller, so root only copies finished files. The scratch directory goes on
|
||||||
|
# every exit, including a failed render, a refused sudo prompt, or a signal;
|
||||||
|
# revoking the sudo timestamp stays the last thing the exit path does.
|
||||||
rendered=$(mktemp -d)
|
rendered=$(mktemp -d)
|
||||||
|
cleanup_refresh() {
|
||||||
|
local status=$?
|
||||||
|
rm -rf "$rendered"
|
||||||
|
omarchy_security_exit_with_revoked_sudo "$status"
|
||||||
|
}
|
||||||
|
trap cleanup_refresh EXIT
|
||||||
"$OMARCHY_PATH/bin/omarchy-apply-pacman" --render "$channel" "$rendered"
|
"$OMARCHY_PATH/bin/omarchy-apply-pacman" --render "$channel" "$rendered"
|
||||||
|
|
||||||
sudo cp -f /etc/pacman.conf /etc/pacman.conf.bak
|
sudo cp -f /etc/pacman.conf /etc/pacman.conf.bak
|
||||||
|
|||||||
@@ -40,3 +40,24 @@ if grep -Eq '^(sudo -N cp |step:pacman )' "$SUDO_TEST_LOG"; then
|
|||||||
fail "invalid channel reached privileged work" "$(<"$SUDO_TEST_LOG")"
|
fail "invalid channel reached privileged work" "$(<"$SUDO_TEST_LOG")"
|
||||||
fi
|
fi
|
||||||
pass "failed refresh does not proceed to privileged copies or a package update"
|
pass "failed refresh does not proceed to privileged copies or a package update"
|
||||||
|
|
||||||
|
# A failed render still removes its scratch directory and exits cold.
|
||||||
|
reset_boundary
|
||||||
|
mv "$SUDO_TEST_ROOT/bin/omarchy-apply-pacman" "$boundary_tmp/omarchy-apply-pacman"
|
||||||
|
cat >"$SUDO_TEST_ROOT/bin/omarchy-apply-pacman" <<'STUB'
|
||||||
|
#!/bin/bash
|
||||||
|
: >"$3/pacman.conf"
|
||||||
|
exit 1
|
||||||
|
STUB
|
||||||
|
chmod +x "$SUDO_TEST_ROOT/bin/omarchy-apply-pacman"
|
||||||
|
mkdir -p "$boundary_tmp/scratch"
|
||||||
|
if TMPDIR="$boundary_tmp/scratch" "$SUDO_TEST_ROOT/bin/omarchy-refresh-pacman" rc >"$boundary_tmp/output" 2>&1; then
|
||||||
|
fail "refresh succeeds after a failed render"
|
||||||
|
fi
|
||||||
|
mv "$boundary_tmp/omarchy-apply-pacman" "$SUDO_TEST_ROOT/bin/omarchy-apply-pacman"
|
||||||
|
[[ -z $(ls -A "$boundary_tmp/scratch") ]] || fail "failed render leaves its scratch directory" "$(ls -AR "$boundary_tmp/scratch")"
|
||||||
|
if grep -Eq '^(sudo -N cp |step:pacman )' "$SUDO_TEST_LOG"; then
|
||||||
|
fail "failed render reached privileged work" "$(<"$SUDO_TEST_LOG")"
|
||||||
|
fi
|
||||||
|
assert_boundary_cold "failed render"
|
||||||
|
pass "failed render removes its scratch directory and exits cold"
|
||||||
Reference in new issue
Block a user