Skip to content

Scope user-session process signals to the invoking user - #14900

Open
radimsem wants to merge 3 commits into
omacom:quattrofrom
radimsem:fix/pkill-uid-scope
Open

radimsem wants to merge 3 commits into
omacom:quattrofrom
radimsem:fix/pkill-uid-scope

Conversation

@radimsem

@radimsem radimsem commented Oct 10, 2026 •

Copy link
Copy Markdown

pkill and pgrep scan every user's process table, while signals only reach the caller's own processes. The session commands in bin/ assume the scan and the signal cover the same set. They do not as soon as a second local account exists.

What that looks like on a machine with two accounts. Account B runs a process named kitty, account A runs the command:

$ pkill -x kitty
pkill: killing pid 72 failed: Operation not permitted

B's process stays alive, and A never had a kitty to reload in the first place. The unscoped form either throws EPERM errors at a user who can do nothing about them (font-set, display-text-size), or its guard reports "running" for a process the user can never signal (restart-helix decides to reload, the kill fails silently). The webcam overlay cleanup, the slurp dismissal, the screensaver teardown and the Battle.net prefix stop reach across accounts the same way.

The change

Adds -u "$UID" to the pgrep/pkill calls in 13 scripts that target processes belonging to the login session running the command: terminal reload signals, screensaver teardown, slurp dismissal, webcam overlay cleanup, omarchy restart-app, the Battle.net prefix stop, the Claude desktop quit. Where a pgrep guard sits in front of a scoped pkill, the guard is scoped too, so the check and the signal look at the same set.

This is the rule #14431 already picked for recording detection: omarchy-capture-screenrecording-process uses pgrep -u "$UID" plus a /proc/<pid>/exe identity check. This PR extends it to the rest of the session commands. omarchy-restart-xcompose got the same scoping upstream in #14433, so this branch no longer touches it. The third commit scopes the 1Password guard in omarchy-system-lock, as suggested in review.

Nothing a legitimate flow can notice. These processes are owned by the session that runs the command, and cross-uid matches never received a signal from these commands before this change either. The tailscaled system daemon check and -P parent-scoped child kills are untouched.

Proof

The same two accounts, with the flag in place:

$ pkill -u "$(id -u)" -x kitty   # A has no kitty
(exit 1, silent)
$ pkill -u "$(id -u)" -x kitty   # A's own kitty
(exit 0, A's process dies)
  • test/cli passes on this branch, including the Hunk retint tests.
  • test/shell ends with exactly the failure set of quattro at 4c1b4cb run in the same Arch container (64 files fail on both for lack of a desktop session). Three test files that pin the old command strings (command-operand-boundaries, system-lock, remove-ai) are updated in the second commit to expect the -u "$UID" argument, and they keep their literal-operand and ordering checks.
  • bash -n on every changed script.
  • The two-account runs above were taken verbatim from a container with two fresh users, removed afterwards.

Manual passes worth doing after merge: omarchy font-set with kitty and ghostty open, a theme switch on a Hunk or btop theme, omarchy screenrecord --with-webcam start and stop, screensaver exit, omarchy remove-gaming-battlenet with a game running.

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issue remains.

Summary

The PR limits session process checks and signals to the invoking user.

  • Font changes refresh only terminals in the current session.
  • Theme and editor refreshes reach only the current user's apps.
  • Capture controls stop only this session's picker and webcam overlay.
  • Locking and exiting the screensaver affect only this user's processes.
  • Restarting an app stops only that app in the current session.
  • Battle.net cleanup stops only processes owned by the current user.
  • Claude removal quits only the desktop app owned by this user.

Reviews (3) · Last reviewed commit: "Scope the 1Password lock guard to the in..." · Reviewed by Greptile

Comment thread bin/omarchy-restart-app Resolved
@jandrusk

Copy link
Copy Markdown

Nice hardening — scoping session pkill/pgrep with -u "$UID" is the right multi-user fix.

Two notes before merge:

  1. Overlap: Confirm secure session acquisition before reporting a lock #14911 also rewrites bin/omarchy-system-lock and test/shell.d/system-lock-test.sh. Whichever lands second needs a rebase; the changes are complementary (your UID scoping on the screensaver kill vs their lock-IPC confirmation) but the test file will conflict.
  2. NIT: in omarchy-system-lock, pgrep -x "1password" is still unscoped while the nearby pkills are UID-scoped. Same pattern as the rest of this PR would be:
if pgrep -u "$UID" -x "1password" >/dev/null && omarchy-cmd-present 1password; then

@radimsem
radimsem force-pushed the fix/pkill-uid-scope branch from 1cab324 to 0cd6bd5 Compare October 12, 2026 19:45
@radimsem

Copy link
Copy Markdown
Author

Rebased onto quattro and scoped the 1Password guard in its own commit, as suggested. omarchy-restart-xcompose is no longer in the diff because #14433 already scoped it.

Three open PRs change the same lines, so whichever of them lands after this one needs a small follow-up:

If any of them merges first, I'll rebase this PR and update the affected test here.

@omarchybot

Copy link
Copy Markdown
Collaborator

This pull request has not been reviewed yet. Classifying an item takes two models agreeing: Claude Opus 5.5 read it as a bug fix, but the second opinion (Codex Medium) could not run because its daily review budget is spent. With no agreement there is no class label, and nothing was run on a worker. It will be picked up again once the second opinion is available.

Two things turned up while reading, neither run on a worker:

  • The branch no longer merges into quattro. Two files conflict: bin/omarchy-install-gaming-battlenet, where Omarchy in 50 languages #15326 wrapped the gum confirm prompt above your pkill in omarchy-i18n, and bin/omarchy-restart-btop, which Retint terminals first and finish other apps behind a theme switch #15189 rewrote to pkill -SIGUSR2 -x btop followed by (( $? <= 1 )). Both resolve by adding -u "$UID" to the new lines.
  • Several call sites on quattro have the same unscoped scan and are not in the diff. bin/omarchy-launch-screensaver:6 exits early when pgrep -f '[o]rg.omarchy.screensaver' matches any account's screensaver, so another user's screensaver keeps this one from starting. bin/omarchy-restart-terminal and bin/omarchy-restart-opencode guard with an unscoped pgrep and signal with killall, which also signals every account. The guard at bin/omarchy-capture-region:154 (--select-window) and the notification checks at bin/omarchy-font-set:76 and :80 are unscoped too.

Waiting on the second opinion; after that, the review, a reproduction on a worker and the suite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants