Bound the grant lock wait

The settings package's pre-transaction hook runs this command under
pacman's transaction. Its lock wait was unbounded, so a stalled grant
operation could hang pacman indefinitely before AbortOnFail ever saw a
result. Grant operations are short; wait at most 60 seconds.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Afonso OliveiraandClaude Fable 5.1 committed 2026-09-17 20:41:45 +01:00
1 parent c8407ee73f
commit 67a813d8d2
1 file changed
+3 -1
+3 -1
View File
@@ -86,7 +86,9 @@ with_root_lock() {
exec {fd}>"$LOCK_FILE" || return 1
/usr/bin/chown root:root "$LOCK_FILE" || return 1
/usr/bin/chmod 0600 "$LOCK_FILE" || return 1
/usr/bin/flock -x "$fd" || return 1
# Grant operations are short. A stalled holder must not hang a caller
# indefinitely, least of all pacman's pre-transaction hook.
/usr/bin/flock -x -w 60 "$fd" || return 1
"$@" || rc=$?
/usr/bin/flock -u "$fd" || rc=1
exec {fd}>&-