Retry USB approval notifications after delivery failure
This commit is contained in:
1 parent
7309746ac8
commit
4ea410d6a1
2 files changed
+20
-2
No files matched your search
@@ -68,11 +68,16 @@ jq -n \
|
|||||||
chmod 600 "$temporary"
|
chmod 600 "$temporary"
|
||||||
mv -f "$temporary" "$request"
|
mv -f "$temporary" "$request"
|
||||||
|
|
||||||
omarchy-notification-send \
|
if ! omarchy-notification-send \
|
||||||
--app-name omarchy-action \
|
--app-name omarchy-action \
|
||||||
--urgency critical \
|
--urgency critical \
|
||||||
--glyph \
|
--glyph \
|
||||||
"USB accessory blocked" \
|
"USB accessory blocked" \
|
||||||
"Click to review it. Keep it blocked unless you recognize the device." \
|
"Click to review it. Keep it blocked unless you recognize the device." \
|
||||||
--exec omarchy-launch-floating-terminal-with-presentation \
|
--exec omarchy-launch-floating-terminal-with-presentation \
|
||||||
omarchy-usb-authorization-review "$token"
|
omarchy-usb-authorization-review "$token"; then
|
||||||
|
# Only a delivered notification may suppress subsequent attempts. Keep the
|
||||||
|
# lock until failure cleanup so another event cannot skip an unsent request.
|
||||||
|
rm -f "$request"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -123,6 +123,7 @@ cat >"$stub_bin/omarchy-notification-send" <<'STUB'
|
|||||||
printf 'notification' >>"$CALLS"
|
printf 'notification' >>"$CALLS"
|
||||||
printf ' <%s>' "$@" >>"$CALLS"
|
printf ' <%s>' "$@" >>"$CALLS"
|
||||||
printf '\n' >>"$CALLS"
|
printf '\n' >>"$CALLS"
|
||||||
|
exit "${NOTIFICATION_FAIL:-0}"
|
||||||
STUB
|
STUB
|
||||||
chmod +x "$stub_bin"/*
|
chmod +x "$stub_bin"/*
|
||||||
|
|
||||||
@@ -439,6 +440,18 @@ fi
|
|||||||
[[ ! -e $request ]] || fail "a stale review request is discarded"
|
[[ ! -e $request ]] || fail "a stale review request is discarded"
|
||||||
pass "USB review binds approval to the device snapshot"
|
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"
|
sysfs="$scratch/sys/bus/usb/devices"
|
||||||
mkdir -p "$sysfs/usb1" "$sysfs/1-2"
|
mkdir -p "$sysfs/usb1" "$sysfs/1-2"
|
||||||
echo 0 >"$sysfs/usb1/authorized_default"
|
echo 0 >"$sysfs/usb1/authorized_default"
|
||||||
|
|||||||
Reference in new issue
Block a user