diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-10-06 14:00:40 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-10-06 14:00:40 +0200 |
commit | 6e9c41a892ed0e0da326e0278b3221ce3f5713b8 (patch) | |
tree | 2e301d871bbeeb44aa57ff9cc070fcf3be484487 /tools/hotplug/libusbscanner |
Initial import of sane-backends version 1.0.24-1.2
Diffstat (limited to 'tools/hotplug/libusbscanner')
-rwxr-xr-x | tools/hotplug/libusbscanner | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/hotplug/libusbscanner b/tools/hotplug/libusbscanner new file mode 100755 index 0000000..bf613a5 --- /dev/null +++ b/tools/hotplug/libusbscanner @@ -0,0 +1,35 @@ +#!/bin/sh + +# This file is part of sane-backends. +# +# This script changes the permissions and ownership of a USB device under +# /proc/bus/usb to grant access to this device to users in the scanner group. +# +# Ownership is set to root:scanner, permissions are set to 0660. +# +# Arguments : +# ----------- +# ACTION=[add|remove] +# DEVICE=/proc/bus/usb/BBB/DDD +# TYPE=usb + +# latest hotplug doesn't set DEVICE on 2.6.x kernels +if [ -z "$DEVICE" ] ; then + IF=`echo $DEVPATH | sed 's/\(bus\/usb\/devices\/\)\(.*\)-\(.*\)/\2/'` + DEV=$(cat /sys/${DEVPATH}/devnum) + DEVICE=`printf '/proc/bus/usb/%.03d/%.03d' $IF $DEV` +fi + +if [ "$ACTION" = "add" -a "$TYPE" = "usb" ]; then + chown root:scanner "$DEVICE" + chmod 0660 "$DEVICE" +fi + + +# That's an insecure but simple alternative +# Everyone has access to the scanner + +# if [ "$ACTION" = "add" -a "$TYPE" = "usb" ]; then +# chmod 0666 "$DEVICE" +# fi + |