You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
836 B

  1. #!/bin/sh
  2. [ "$ACTION" != "remove" ] || exit 0
  3. SANE_GROUP=scanner
  4. grep -q -E "^$SANE_GROUP:" /etc/group || exit 0
  5. grant() {
  6. echo "hotplug(usb/20-saned): Granting $1 to '$2' for group '$SANE_GROUP'" >/dev/kmsg
  7. chgrp "$SANE_GROUP" "$2"
  8. chmod "$1" "$2"
  9. }
  10. usblp_bind="/sys/bus/usb/drivers/usblp/bind"
  11. if [ "$DEVTYPE" = "usb_device" ]; then
  12. # Filter SANE known devices
  13. vendor_product="${PRODUCT%/*}"
  14. vendorid="$(printf '%04x' "0x0${vendor_product%/*}")"
  15. productid="$(printf '%04x' "0x0${vendor_product#*/}")"
  16. grep -s -x -F -q "$productid" "/usr/share/sane/$vendorid"-*.usbid || exit 0
  17. grant g+rw "/dev/$DEVNAME"
  18. elif [ "$DEVTYPE" = "usb_interface" ] && [ "$DRIVER" = 'usblp' ]; then
  19. # Needed by script /usr/bin/saned to rebind USB devices back to usblp after use
  20. if [ -e "$usblp_bind" ]; then
  21. grant g+w "$usblp_bind"
  22. fi
  23. fi