Resolve the invoking user's home in removal cleanup scripts - #9571
Open
shaynhornik wants to merge 1 commit into
Open
Resolve the invoking user's home in removal cleanup scripts#9571shaynhornik wants to merge 1 commit into
shaynhornik wants to merge 1 commit into
Conversation
The omarchy-remove-{ai,gaming}-* scripts delete per-user data with
$HOME paths, but they carry requires-sudo and can arrive under sudo or
pkexec, where $HOME is root's — the package is removed while the
user's configs, caches, and libraries silently survive. Derive the
invoking user (OMARCHY_INSTALL_USER, SUDO_USER, then PKEXEC_UID, the
same derivation omarchy-apply-lock uses) and remove that user's data.
Fixes omacom#9569
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FTqr6ZjXfNthXT719ag7Qc
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.
Fixes #9569
Problem
The ten
omarchy-remove-{ai,gaming}-*scripts delete per-user data (~/.config/heroic,~/.steam,~/.ollama, …) through$HOME, but they are markedomarchy:requires-sudo=trueand can arrive undersudoorpkexec— the escalation pathdefault/agents/skills/omarchy/SKILL.mditself prescribes when no terminal is available. There$HOMEis root's:omarchy-pkg-dropsucceeds (its internalsudo pacmanis a no-op as root), the script prints its success message, and the user's real data — 2.0 GB of Proton runtimes in the reported case — silently survives.Fix
Each affected script derives the invoking user before touching any home path, with the exact derivation
omarchy-apply-lockalready uses (OMARCHY_INSTALL_USER→SUDO_USER→PKEXEC_UIDvia getent →$USER), then resolves that user's home withgetentand removes their data. Direct invocation is unchanged (target_home==$HOME).Covered:
ai-chatgpt,ai-grok-bot,ai-lm-studio(including its relocatable-home pointer guard),ai-ollama,ai-t3-code,gaming-heroic,gaming-lutris,gaming-minecraft,gaming-retroarch,gaming-steam.Deliberately not covered, same family but different concerns:
omarchy-remove-security-sshdjudges the wrong user'sauthorized_keysunder escalation (security decision — filing separately), andomarchy-remove-service-sunshineadditionally callssystemctl --useras root, which needs more than a home-path fix.Verification
bash -non all ten scripts../test/clipasses (116 ok).PKEXEC_UIDset withHOME=/root,SUDO_USERset withHOME=/root, and plain direct invocation — resolving to the invoking user's home in all three.🤖 Generated with Claude Code
https://claude.ai/code/session_01FTqr6ZjXfNthXT719ag7Qc