Skip to content

Resolve the invoking user's home in removal cleanup scripts - #9571

Open
shaynhornik wants to merge 1 commit into
omacom:quattrofrom
shaynhornik:fix/remove-scripts-target-home
Open

Resolve the invoking user's home in removal cleanup scripts#9571
shaynhornik wants to merge 1 commit into
omacom:quattrofrom
shaynhornik:fix/remove-scripts-target-home

Conversation

@shaynhornik

Copy link
Copy Markdown

Fixes #9569

Problem

The ten omarchy-remove-{ai,gaming}-* scripts delete per-user data (~/.config/heroic, ~/.steam, ~/.ollama, …) through $HOME, but they are marked omarchy:requires-sudo=true and can arrive under sudo or pkexec — the escalation path default/agents/skills/omarchy/SKILL.md itself prescribes when no terminal is available. There $HOME is root's: omarchy-pkg-drop succeeds (its internal sudo pacman is 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-lock already uses (OMARCHY_INSTALL_USERSUDO_USERPKEXEC_UID via getent → $USER), then resolves that user's home with getent and 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-sshd judges the wrong user's authorized_keys under escalation (security decision — filing separately), and omarchy-remove-service-sunshine additionally calls systemctl --user as root, which needs more than a home-path fix.

Verification

  • bash -n on all ten scripts.
  • ./test/cli passes (116 ok).
  • The derivation block was exercised under three simulated environments — PKEXEC_UID set with HOME=/root, SUDO_USER set with HOME=/root, and plain direct invocation — resolving to the invoking user's home in all three.
  • Not run: live removal of each package (no Omarchy install in this environment); the reporter's diagnosis in omarchy-remove-gaming-heroic leaves ~/.config/heroic behind ($HOME resolves to /root under pkexec) #9569 documents the pkexec case empirically.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FTqr6ZjXfNthXT719ag7Qc

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant