Comment 3 for bug 270185

Ian! D. Allen (idallen) wrote :

This is a work-around for the scanner permissions bug.

$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 8.04.1
Release: 8.04
Codename: hardy

$ uname -a
Linux home 2.6.24-23-generic #1 SMP Thu Nov 27 18:44:42 UTC 2008 i686 GNU/Linux

$ sane-find-scanner
...
found USB scanner (vendor=0x04a5, product=0x2060) at libusb:002:003

$ lsusb
...
Bus 002 Device 003: ID 04a5:2060 Acer Peripherals Inc. (now BenQ Corp.) Prisa 620U+/640U

$ grep 2060 /etc/sane.d/*conf
/etc/sane.d/snapscan.conf:usb 0x04a5 0x2060

$ SANE_DEBUG_SNAPSCAN=128 scanimage -L
[sanei_debug] Setting debug level of snapscan to 128.
[snapscan] sane_snapscan_init
[snapscan] sane_snapscan_init: Snapscan backend version 1.4.53
[snapscan] add_usb_device(libusb:002:003)
[snapscan] add_usb_device: Detected (kind of) an USB device
[snapscan] snapscani_usb_open(libusb:002:003)
[snapscan] add_usb_device: error opening device libusb:002:003: Access to resource has been denied
[snapscan] sane_snapscan_get_devices (0xbff8e418, 0)

No scanners were identified. If you were expecting something different,
check that the scanner is plugged in, turned on and detected by the
sane-find-scanner tool (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).
[snapscan] sane_snapscan_exit

--------------

This works as root:

root# scanimage -L
device `snapscan:libusb:002:003' is a Acer FlatbedScanner13 flatbed scanner

So it's a permission problem with the device. What will fix it?
"chgrp scanner /dev/usb* ; chmod 777 /dev/usb*" doesn't do it:

crwxrwxrwx 1 root scanner 254, 13 Jan 14 08:41 /dev/usbdev2.3_ep83
crwxrwxrwx 1 root scanner 254, 12 Jan 14 08:41 /dev/usbdev2.3_ep02
crwxrwxrwx 1 root scanner 254, 11 Jan 14 08:41 /dev/usbdev2.3_ep81
crwxrwxrwx 1 root scanner 254, 10 Jan 14 08:41 /dev/usbdev2.3_ep00

More investigation:

lrwxrwxrwx 1 root root 14 Jan 14 08:41 /dev/.udev/db/\\x2fdevices\\x2fpci0000:00\\x2f0000:00:02.1\\x2fusb2\\x2f2-1\\x2f2-1:1.0\\x2fusb_endpoint\\x2fusbdev2.3_ep83 -> usbdev2.3_ep83
lrwxrwxrwx 1 root root 14 Jan 14 08:41 /dev/.udev/db/\\x2fdevices\\x2fpci0000:00\\x2f0000:00:02.1\\x2fusb2\\x2f2-1\\x2f2-1:1.0\\x2fusb_endpoint\\x2fusbdev2.3_ep02 -> usbdev2.3_ep02
lrwxrwxrwx 1 root root 14 Jan 14 08:41 /dev/.udev/db/\\x2fdevices\\x2fpci0000:00\\x2f0000:00:02.1\\x2fusb2\\x2f2-1\\x2f2-1:1.0\\x2fusb_endpoint\\x2fusbdev2.3_ep81 -> usbdev2.3_ep81
lrwxrwxrwx 1 root root 14 Jan 14 08:41 /dev/.udev/db/\\x2fdevices\\x2fpci0000:00\\x2f0000:00:02.1\\x2fusb2\\x2f2-1\\x2fusb_endpoint\\x2fusbdev2.3_ep00 -> usbdev2.3_ep00
lrwxrwxrwx 1 root root 15 Jan 14 08:41 /dev/.udev/db/\\x2fdevices\\x2fpci0000:00\\x2f0000:00:02.1\\x2fusb2\\x2f2-1 -> bus/usb/002/003

Looking at the last line above, and checking permissions:

$ ls -l /dev/bus/usb/002/003
crw-rw-r-- 1 root root 189, 130 Jan 14 09:26 /dev/bus/usb/002/003

Fixing permissions:

root# chgrp scanner /dev/bus/usb/002/003

And now it works fine as non-root (as long as I'm in group scanner):

$ SANE_DEBUG_SNAPSCAN=128 scanimage -L
[sanei_debug] Setting debug level of snapscan to 128.
[snapscan] sane_snapscan_init
[snapscan] sane_snapscan_init: Snapscan backend version 1.4.53
[snapscan] add_usb_device(libusb:002:003)
[snapscan] add_usb_device: Detected (kind of) an USB device
[snapscan] snapscani_usb_open(libusb:002:003)
[snapscan] add_usb_device: Checking if 0x04a5 is a supported USB vendor ID
[snapscan] snapscani_check_device()
[snapscan] mini_inquiry
[snapscan] snapscan_cmd
[snapscan] snapscani_usb_cmd(0,0xbf97cbba,6,0xbf97cbc4,0xbf97cbc0 (36))
[snapscan] atomic_usb_cmd(0,0xbf97cbba,6,0xbf97cbc4,0xbf97cbc0 (36))
[snapscan] usb_cmd(0,0xbf97cbba,6,0xbf97cbc4,0xbf97cbc0 (36))
[snapscan] usb_cmd: cmdlen=6, datalen=0
[snapscan] usb_write: writing: 0x12 0x00 0x00 0x00 0x24 0x00
[snapscan] Written 6 bytes
[snapscan] usb_read: reading: 0xf9 0x00 0x00 0x00 0x00 0x00 0x00 0x00
[snapscan] Read 8 bytes
[snapscan] usb_read: reading: 0x06 0x00 0x02 0x02 0x49 0x00 0x00 0x00 0x43 0x6f ...
[snapscan] Read 36 bytes
[snapscan] usb_read: reading: 0xfb 0x00 0x00 0x00 0x00 0x00 0x00 0x00
[snapscan] Read 8 bytes
[snapscan] snapscani_check_device: Is vendor "Color" model "FlatbedScanner13" a supported scanner?
[snapscan] snapscani_get_model_id(FlatbedScanner13, 0, 2)
[snapscan] snapscani_get_model_id: looking up scanner for ID 0x04a5,0x2060.
[snapscan] snapscani_check_device: Autodetected driver: Acer620
[snapscan] snapscani_usb_close(0)
[snapscan] 1st read 3 write 1
[snapscan] snapscani_usb_cmd(0,0xbf97cba2,6,0x0,0x0 (0))
[snapscan] atomic_usb_cmd(0,0xbf97cba2,6,0x0,0x0 (0))
[snapscan] usb_cmd(0,0xbf97cba2,6,0x0,0x0 (0))
[snapscan] usb_cmd: cmdlen=6, datalen=0
[snapscan] usb_write: writing: 0x00 0x00 0x00 0x00 0x00 0x00
[snapscan] Written 6 bytes
[snapscan] usb_read: reading: 0xfb 0x00 0x00 0x00 0x00 0x00 0x00 0x00
[snapscan] Read 8 bytes
[snapscan] 2nd read 4 write 2
[snapscan] snapscani_init_device_structure()
[snapscan] sane_snapscan_get_devices (0xbf97de08, 0)
device `snapscan:libusb:002:003' is a Acer FlatbedScanner13 flatbed scanner
[snapscan] sane_snapscan_exit