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.

27 lines
745 B

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