Retry USB approval notifications after delivery failure

This commit is contained in:
acrogenesis committed 2026-09-15 13:35:57 -06:00
1 parent 7309746ac8
commit 4ea410d6a1
2 files changed
+20 -2

No files matched your search

+13
View File
@@ -123,6 +123,7 @@ cat >"$stub_bin/omarchy-notification-send" <<'STUB'
printf 'notification' >>"$CALLS"
printf ' <%s>' "$@" >>"$CALLS"
printf '\n' >>"$CALLS"
exit "${NOTIFICATION_FAIL:-0}"
STUB
chmod +x "$stub_bin"/*
@@ -439,6 +440,18 @@ fi
[[ ! -e $request ]] || fail "a stale review request is discarded"
pass "USB review binds approval to the device snapshot"
notification_count=$(grep -c '^notification' "$calls")
if NOTIFICATION_FAIL=1 USBGUARD_IPC_SIGNAL=IPC.Connected \
"$ROOT/bin/omarchy-usb-authorization-event"; then
fail "a failed notification must report failure"
fi
[[ ! -e $request ]] || fail "a failed notification must not suppress retries"
USBGUARD_IPC_SIGNAL=IPC.Connected "$ROOT/bin/omarchy-usb-authorization-event"
[[ -f $request ]] || fail "reconnection retries a failed notification"
[[ $(grep -c '^notification' "$calls") == $((notification_count + 2)) ]] ||
fail "reconnection must attempt delivery after an earlier send failure"
pass "failed USB notifications can be retried on reconnection"
sysfs="$scratch/sys/bus/usb/devices"
mkdir -p "$sysfs/usb1" "$sysfs/1-2"
echo 0 >"$sysfs/usb1/authorized_default"