Skip to content

Probe sudo non-interactively so unattended updates cannot hang - #9875

Open
konsorsiumai wants to merge 1 commit into
omacom:quattrofrom
konsorsiumai:fix/update-stay-awake-sudo-probe
Open

Probe sudo non-interactively so unattended updates cannot hang#9875
konsorsiumai wants to merge 1 commit into
omacom:quattrofrom
konsorsiumai:fix/update-stay-awake-sudo-probe

Conversation

@konsorsiumai

Copy link
Copy Markdown

Problem

omarchy update run non-interactively (scripts, cron, AI agents — a workflow the manual explicitly supports) hangs for exactly 5 minutes and then aborts with "Something went wrong during the update!". By that point the pre-update snapshot has already been created, so the user is left with a confusing failure and no update.

Root cause

Three pieces conspire:

  1. omarchy-update re-executes itself under script -qefc ... /tmp/omarchy-update.log for logging, so every step runs with a PTY on stdin.
  2. omarchy-update-stay-awake start() picks its privilege runner with [[ -t 0 ]] — which is therefore always true under the logging PTY — and runs sudo -v.
  3. sudo -v cannot complete without typed input: on current Arch sudo it prompts even when NOPASSWD: ALL is granted, waits passwd_timeout (default 300 s), then fails. set -e plus the ERR trap abort the whole update.

Journal evidence from a real machine: three failed update attempts at 00:27–00:28, and one that hung from 01:01:58 to exactly 01:07:01 (≈ passwd_timeout) before aborting right after the snapshot step.

Reproducer on an affected system (returns nothing until killed, 300 s unattended):

timeout 12 script -qefc 'omarchy-update-stay-awake start' /dev/null

Fix

Replace the tty guess with a capability probe:

if sudo -n true 2>/dev/null; then
  inhibit_runner=(sudo)
else
  inhibit_runner=(pkexec)
fi
  • Non-interactive by construction — it can never wait on input.
  • Interactive users with valid tickets or NOPASSWD keep the sudo path.
  • Everyone else gets the pkexec dialog: the branch that already existed for non-tty callers but could never trigger during an update, because the logging PTY always defeated the [[ -t 0 ]] check.

Tests

test/shell.d/update-lock-test.sh updated: the sudo stub handles the -n true probe, and the terminal-section assertion now verifies the non-interactive probe instead of sudo -v. All 7 assertions pass.

Related (not in this PR)

omarchy-sudo-keepalive (sourced by omarchy-pkg-install / omarchy-pkg-aur-install) opens with a bare sudo -v and can hang menu-driven package installs the same way while passwordless sudo is enabled. Happy to file or fix that separately.

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.

1 participant