diff --git a/misc/qubes_usb.rules b/misc/qubes_usb.rules new file mode 100644 index 0000000..5b3c875 --- /dev/null +++ b/misc/qubes_usb.rules @@ -0,0 +1,10 @@ +# Expose all USB devices (except block) via xenstore + +# Handle only USB devices +SUBSYSTEM!="usb", GOTO="qubes_usb_end" + +ACTION=="add", IMPORT{program}="/usr/lib/qubes/usb_add_change" +ACTION=="change", IMPORT{program}="/usr/lib/qubes/usb_add_change" +ACTION=="remove", RUN+="/usr/lib/qubes/usb_remove" + +LABEL="qubes_usb_end" diff --git a/misc/usb_add_change b/misc/usb_add_change new file mode 100755 index 0000000..fa9c15f --- /dev/null +++ b/misc/usb_add_change @@ -0,0 +1,9 @@ +#!/bin/sh + +[ "x$DEVTYPE" = "xusb_device" ] || exit 0 + +NAME="${ID_VENDOR_ID}_${ID_MODEL_ID}" +DESC="${NAME} ${ID_SERIAL}" +XS_KEY="qubes-usb-devices/$NAME" + +xenstore-write "$XS_KEY/desc" "$DESC" diff --git a/misc/usb_remove b/misc/usb_remove new file mode 100755 index 0000000..ea66b7c --- /dev/null +++ b/misc/usb_remove @@ -0,0 +1,10 @@ +#!/bin/sh + +[ "x$DEVTYPE" = "xusb_device" ] || exit 0 + +NAME="${ID_VENDOR_ID}_${ID_MODEL_ID}" +DESC="${NAME} ${ID_SERIAL}" +XS_KEY="qubes-usb-devices/$NAME" + +xenstore-rm "$XS_KEY" +