summaryrefslogtreecommitdiff
path: root/tools/hotplug
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-10-06 14:00:40 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-10-06 14:00:40 +0200
commit6e9c41a892ed0e0da326e0278b3221ce3f5713b8 (patch)
tree2e301d871bbeeb44aa57ff9cc070fcf3be484487 /tools/hotplug
Initial import of sane-backends version 1.0.24-1.2
Diffstat (limited to 'tools/hotplug')
-rw-r--r--tools/hotplug/README35
-rwxr-xr-xtools/hotplug/libusbscanner35
2 files changed, 70 insertions, 0 deletions
diff --git a/tools/hotplug/README b/tools/hotplug/README
new file mode 100644
index 0000000..1170639
--- /dev/null
+++ b/tools/hotplug/README
@@ -0,0 +1,35 @@
+README for the USB hotplug scripts for sane-backends :
+------------------------------------------------------
+
+If you intend to use a USB scanner with libusb and older versions of Linux, you
+should install the hotplug package, and then take the following steps. For
+current Linux kernels, "udev" is state of the art, see the "udev" directory
+instead.
+
+ o Copy the libsane.usermap and libusbscanner files from this directory to
+ /etc/hotplug/usb/
+ o If you use Linux 2.6.3 or older, add scanner to /etc/hotplug/blacklist so
+ that the scanner.o kernel driver won't be loaded by hotplug. With later
+ kernel versions there is no scanner module and therefore it's not necessary
+ to use the blacklist.
+ o Check if /etc/hotplug/usb/libsane.usermap already knows about your scanner.
+ If your scanner is not in this list,add a line similar to the other ones
+ using the vendor ID and the product ID of your scanner. Please contact the
+ sane-devel mailing list in this case so the ids of your scanner can be added.
+ o Make sure that the "scanner" group exists on your system and that every user
+ who should be allowed to acces the scanner is a member of that group.
+ Alternatively, you can enable access for every user of your system in
+ libusbscanner.
+
+The vendor ID and product ID of your scanner can be obtained by running
+sane-find-scanner (you might need to run it as root).
+
+Please note that the scanner.o (or scanner.ko in Linux 2.6) kernel module is
+now deprecated and marked as obsolete in Linux 2.6. It is recommended to switch
+to libusb.
+
+If the hotplug support doesn't work for you once you have taken the steps
+described above, check that your kernel has been built with hotplug support.
+Otherwise, you'll need to rebuild your kernel.
+
+ -- Julien BLACHE <jb@jblache.org>, Sat, 28 Feb 2004 10:01:02 +0000
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
+