Ask for the sudo password once per omarchy update (#13323)
* Ask for the sudo password once per omarchy update Every sudo call in omarchy update prompted, because the no-update wrapper covered the whole run on top of per-phase revokes, and stay-awake revoked the timestamp on its own entry and exit. A single update could ask four times before the snapshot finished (#13319). Authorize once, right after confirmation, starting from a revoked timestamp so the prompt always belongs to this update. A background keepalive refreshes it until the update is done. Prune, snapshot, stay-awake, keyring, system packages, migrations, orphan removal, service restarts, the post-update hook, and mise all share that authorization. AUR builds run third-party PKGBUILD code, so they move to the end and run cold: the keepalive stops, the timestamp is revoked, and yay and any bare sudo use the no-update wrapper. The timestamp is revoked again after AUR and on every exit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep the single authorization for passwordless sudo and ttyless inhibition Authorize by running a command instead of sudo -v. Under the default verifypw=all, -v prompts even when passwordless sudo is enabled, which would have added a prompt those users never had. Inside an update without a terminal, stay-awake now reuses the update's authorization with a non-interactive sudo instead of asking again through polkit. It falls back to polkit only if that authorization is gone. The test sudo refuses a cold non-interactive call, as the real one does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b336b1b0d
commit
e1614f2bdb
9 files changed
+163
-51
No files matched your search
@@ -37,6 +37,7 @@ mkdir -p "$stub_bin" "$test_home" "$mapped_root/bin" "$mapped_root/default/omarc
|
||||
|
||||
cat >"$stub_bin/pkexec" <<'SH'
|
||||
#!/bin/bash
|
||||
[[ -z ${SUDO_EVENT_LOG:-} ]] || printf 'pkexec\n' >>"$SUDO_EVENT_LOG"
|
||||
exec "$@"
|
||||
SH
|
||||
|
||||
@@ -44,8 +45,12 @@ cat >"$stub_bin/sudo" <<'SH'
|
||||
#!/bin/bash
|
||||
case ${1:-} in
|
||||
-h) echo 'usage: sudo [-bHkNnPS] command'; exit 0 ;;
|
||||
-k|-K|-v) exit 0 ;;
|
||||
-k|-K|-v)
|
||||
[[ -z ${SUDO_EVENT_LOG:-} ]] || printf 'sudo %s\n' "$1" >>"$SUDO_EVENT_LOG"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
[[ -z ${SUDO_EVENT_LOG:-} ]] || printf 'sudo %s\n' "$*" >>"$SUDO_EVENT_LOG"
|
||||
background=0
|
||||
while (( $# )); do
|
||||
case "$1" in
|
||||
@@ -173,9 +178,31 @@ read -r version valid_pid valid_start valid_owner valid_token <"$state_dir/inhib
|
||||
fail "inhibitor state is private, caller-owned, and singly linked"
|
||||
run_helper stop
|
||||
wait_dead "$valid_pid" || fail "valid inhibitor identity is stopped"
|
||||
|
||||
[[ ! -e $state_dir ]] || fail "valid state is cleaned after stop"
|
||||
pass "valid XDG runtime uses private atomic inhibitor state"
|
||||
|
||||
# omarchy update owns its one authorization; the helper must not revoke it.
|
||||
# Run on its own, the helper still starts and ends cold.
|
||||
sudo_events="$test_tmp/sudo-events"
|
||||
: >"$sudo_events"
|
||||
OMARCHY_UPDATE_SUDO_SESSION=1 SUDO_EVENT_LOG="$sudo_events" run_helper start
|
||||
OMARCHY_UPDATE_SUDO_SESSION=1 SUDO_EVENT_LOG="$sudo_events" run_helper stop
|
||||
! grep -qx 'sudo -k' "$sudo_events" || fail "helper revoked the update's authorization" "$(<"$sudo_events")"
|
||||
SUDO_EVENT_LOG="$sudo_events" run_helper start
|
||||
SUDO_EVENT_LOG="$sudo_events" run_helper stop
|
||||
grep -qx 'sudo -k' "$sudo_events" || fail "standalone helper no longer revokes sudo"
|
||||
pass "helper leaves the update's authorization alone and revokes when standalone"
|
||||
|
||||
# Without a terminal, an update's inhibitor reuses the update's authorization
|
||||
# non-interactively instead of asking again through polkit.
|
||||
: >"$sudo_events"
|
||||
OMARCHY_UPDATE_SUDO_SESSION=1 SUDO_EVENT_LOG="$sudo_events" run_helper start </dev/null
|
||||
OMARCHY_UPDATE_SUDO_SESSION=1 SUDO_EVENT_LOG="$sudo_events" run_helper stop </dev/null
|
||||
grep -q -- '^sudo -n -N -b -- ' "$sudo_events" || fail "update inhibitor without a terminal did not reuse sudo" "$(<"$sudo_events")"
|
||||
! grep -qx pkexec "$sudo_events" || fail "update inhibitor without a terminal asked polkit" "$(<"$sudo_events")"
|
||||
pass "update inhibitor without a terminal reuses the update's authorization instead of polkit"
|
||||
|
||||
permissive_runtime="$test_tmp/permissive-runtime"
|
||||
mkdir -m 755 "$permissive_runtime"
|
||||
if HOME="$test_home" XDG_RUNTIME_DIR="$permissive_runtime" PATH="$stub_bin:$ROOT/bin:/usr/bin:/bin" \
|
||||
|
||||
Reference in new issue
Block a user