# Scanner not detected as user [SOLVED]

## swizec

Hi,

I've just gotten around to configuring my scanner after a reinstall and it works fine under root but under user it isn't detected at all (although my webcam gets detected twice, which is weird)

I thought at first it was the standard permissions problem as used to be the case in the past so I did all the fixes for that (with that usbscanner initscript) and they seem to be fine...

 *scanimage -L under root wrote:*   

> 
> 
> device `v4l:/dev/video1' is a Noname Z-star Vimicro zc0301p virtual device
> 
> device `v4l:/dev/video0' is a Noname Z-star Vimicro zc0301p virtual device
> ...

 

 *scanimage -L under user wrote:*   

> 
> 
> device `v4l:/dev/video1' is a Noname Z-star Vimicro zc0301p virtual device
> 
> device `v4l:/dev/video0' is a Noname Z-star Vimicro zc0301p virtual device
> ...

 

 *ls -l /proc/bus/usb/003/003 wrote:*   

> 
> 
> -rw-rw----  1 root scanner 57 May  1  2006 /proc/bus/usb/003/003
> 
> 

 

And the user does seem to be in the scanner group...

Somebody please help because I really need this to work.Last edited by swizec on Mon May 01, 2006 11:56 pm; edited 1 time in total

----------

## syouth

Seems to be??

```
$ cat /etc/group | grep yourusername
```

And if you have put your user into this group with current session, you have to log out and log back in.. That's the way it works.

----------

## swizec

Yep, it's in the scanner group.

edit:

did some more debugging and the scanner isn't detected when the permissions are set to 0666 nor when the user is specified as the owner...

----------

## bobspencer123

is your user a member of the "usb" also? If you use a usb scanner.

----------

## swizec

Yes it is

----------

## 01mf02

I have the same problem - some time ago it worked though. I think it could be due to a udev/hal/dbus update.

----------

## swizec

I think I have discovered what the problem is, no scanner device is created in /dev. But I don't know how to fix this problem...

edit:

solved the problem, the whole time I was looking at the permissions of /proc/bus/usb/... whereas I should be looking at /dev/bus/usb/...

----------

## 01mf02

I tried to chown username:scanner /dev/bus/usb/002/005 (that's the device that the scanner points to), but I still can't detect the scanner as user.

----------

## 01mf02

Nobody ever had this problem?

----------

## Matteo Azzali

I have this issue and I didn't sorted out how to fix:

/proc/bus/usb seems fine with permissions,

/dev/bus/usb is all root-only and even changing manually the permissions scanimage -L won't find the scanner....

[SOLVED?]

Creating a file /etc/udev/rules.d/15-usb.rules  ( 15 isn't fixed, just make sure is below 50),with the line:

SUBSYSTEM=="usb_device", PROGRAM="/bin/sh -c 'K=%k; K=$${K#usbdev}; printf bus/usb/%%03i/%%03i $${K%%%%.*} $${K#*.}'", NAME="%c", GROUP="usb", MODE="0664"

Seems to have fixed, I'm not sure this is a safe procedure but at least works and give permissions to usb group users...

Now I have another doubt: how do I tell to sane that /dev/video0 isn't a scanner, and should ignore it?

EDIT: solved this also: I commented out every line of /etc/sane.d/v4l.conf ....

----------

## micb

 *Matteo Azzali wrote:*   

> [SOLVED?] 

 

Had the same problem here, tried your solution and it worked.

Many thanks!

----------

## letchideslandes

A nicely solution for me is to write a special rule :

BUS=="usb", SYSFS{product}=="CanoScan", OWNER="cyril", GROUP="scanner"

works just for me, and just for my CanonScan, but secure, while waiting a complète solution

----------

## Matteo Azzali

Ok, a better way to get scanner to be usable as user, as ROOT you may use script or do manually:

(both way you remove first the old 15-usb.rules file....)

use script:

scanner.sh:

```

#!/bin/bash

BIDENTIFY=`scanimage -L |grep -o -E "[0-9][0-9][0-9]:[0-9][0-9][0-9]"`

SCAT=${BIDENTIFY/://}

FINAL=`udevinfo -a -p $(udevinfo -q path -n /dev/bus/usb/$SCAT) | grep -A 12 -E "KERNEL==" | grep -E "SYSFS{product}"`

if [ "x$FINAL" != "x" ] ; then

echo $FINAL

echo "BUS=\"usb\", "$FINAL", GROUP=\"scanner\", MODE=\"664\"" > /etc/udev/rules.d/92-scanner.rules

else

echo "Error, no scanner found, something gone bad....turn on scanner"

echo "and make sure it's connected...."

fi

```

Run this as root (sh scanner.sh) and if it gives no error do udevstart as root and then Scanimage -L as user in the scanner group.

92-scanner.rules file has been created in udev rules directory.

 Alternative: do manually

#Scanimage -L

it displays for example:

device `snapscan:libusb:001:006' is a EPSON EPSON Scanner flatbed scanner

we care about 001:006 , all the rest isn't useful.

then we do (modify /001/006 with the results of previous command):

#udevinfo -a -p $(udevinfo -q path -n /dev/bus/usb/001/006)

result will belike:

```

looking at device '/class/usb_device/usbdev1.6':

    KERNEL=="usbdev1.6"

    SUBSYSTEM=="usb_device"

    SYSFS{dev}=="189:5"

  looking at device '/devices/pci0000:00/0000:00:02.2/usb1/1-5':

    ID=="1-5"

    BUS=="usb"

    DRIVER=="usb"

    SYSFS{configuration}==""

    SYSFS{product}=="EPSON Scanner"

    SYSFS{manufacturer}=="EPSON"

    SYSFS{maxchild}=="0"

    SYSFS{version}==" 2.00"

    SYSFS{devnum}=="6"

    SYSFS{speed}=="480"

    SYSFS{bMaxPacketSize0}=="64"

    SYSFS{bNumConfigurations}=="1"

    SYSFS{bDeviceProtocol}=="ff"

    SYSFS{bDeviceSubClass}=="ff"

    SYSFS{bDeviceClass}=="ff"

    SYSFS{bcdDevice}=="0107"

    SYSFS{idProduct}=="011f"

    SYSFS{idVendor}=="04b8"

    SYSFS{bMaxPower}=="100mA"

    SYSFS{bmAttributes}=="c0"

    SYSFS{bConfigurationValue}=="1"

    SYSFS{bNumInterfaces}==" 1"

............ (there's more but this is the useful part.)

```

now we can add a file, ex: /etc/udev/rules.d/91-scanner.rules, containing:

BUS="usb", SYSFS{product}=="EPSON Scanner", GROUP="scanner", MODE="664"

(Modify "EPSON Scanner" with the result of prevuois command).

That's all.

----------

## htranou

 *Matteo Azzali wrote:*   

> now we can add a file, ex: /etc/udev/rules.d/91-scanner.rules, containing:
> 
> BUS="usb", SYSFS{product}=="EPSON Scanner", GROUP="scanner", MODE="664"
> 
> (Modify "EPSON Scanner" with the result of prevuois command).
> ...

 

Hello,

I tried adding your rule, but it seems to totally ignore the MODE statement here. The rule is good, since if I change the GROUP part, it effectively changes the group of the device. But I can put anything in MODE, it will stay as crw-r--r-- .

I can manually change the permissions, but when hotplugging, nothing.

Thanks for any help

----------

## Matteo Azzali

 *htranou wrote:*   

> 
> 
> Hello,
> 
> I tried adding your rule, but it seems to totally ignore the MODE statement here. The rule is good, since if I change the GROUP part, it effectively changes the group of the device. But I can put anything in MODE, it will stay as crw-r--r-- .
> ...

 

Did you tried to change the rule number (start of filename) to go from the other part of 50-udev.rules ?

(lower than 50 if you have higher, higher if you have lower....).

Check by doing "scanimage -L" from an user in scanner group to see if it's detected...

----------

## htranou

I use 10-something, so it should have precedence over the 50 one

scanimage -L doesn't work as user, only as root. Of course, after changing the perm by hand it works.

I guess I'll use the RUN command in udev to change the permissions with a script. Though, it really feels more like a hack. I would prefer using udev to do that.

----------

## Matteo Azzali

 *htranou wrote:*   

> I use 10-something, so it should have precedence over the 50 one
> 
> scanimage -L doesn't work as user, only as root. Of course, after changing the perm by hand it works.
> 
> I guess I'll use the RUN command in udev to change the permissions with a script. Though, it really feels more like a hack. I would prefer using udev to do that.

 

Got ya! Did you tried also to use 91-something.rules as I suggested above?? Udev should set rules accordingly to the LAST rule for that device it finds,

so if you used it only inside 10-something.rules the permissions are set by 50-udev.rules that already contains permissions for that device.

10-something doesn't means it have precedence or priority, means only it will be processed first (and then 50-something overwrites it's permissions).

----------

## htranou

Ah! Thank you, it works now. Misunderstood how udev works.

Though I have another problem now, but it's only because of my scanner. I'm sure yesterday, it gave me a  SYSFS{product}==" Snapscan1212u_2" and today, it gives me SYSFS{product}=="SNAPSCAN". And I rebooted yesterday, before trying. Well, I hope it won't find a third name another day (Manufacturer changed a bit too, so it's the same if I use it or product).

Thanks again for the help.

----------

## dncohen

I'm trying to follow along but can't make this work.  Scanimage -L works for me as root, but not as a user in the scanner group.

```

# scanimage -L

device `hpaio:/usb/Photosmart_C3100_series?serial=CN71FCD11Z04KV' is a Hewlett-Packard Photosmart_C3100_series all-in-one

```

Note that I don't get the handy :001:006 to help me identify the device.  Through trial and error I think I've found it at 001/007:

```

# udevinfo -a -p $(udevinfo -q path -n /dev/bus/usb/001/007)

Udevinfo starts with the device specified by the devpath and then

walks up the chain of parent devices. It prints for every device

found, all possible attributes in the udev rules key format.

A rule to match, can be composed by the attributes of the device

and the attributes from one single parent device.

  looking at device '/class/usb_device/usbdev1.7':

    KERNEL=="usbdev1.7"

    SUBSYSTEM=="usb_device"

    DRIVER==""

    ATTR{dev}=="189:6"

  looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-1':

    KERNELS=="1-1"

    SUBSYSTEMS=="usb"

    DRIVERS=="usb"

    ATTRS{serial}=="CN71FCD11Z04KV"

    ATTRS{product}=="Photosmart C3100 series"

    ATTRS{manufacturer}=="HP"

    ATTRS{quirks}=="0x0"

    ATTRS{maxchild}=="0"

etc.....

```

Here, I don't get SYSFS{product}, but I get ATTRS{product}.  This is all gobbledygook to me anyway.  I tried to create /etc/udev/rules.d/91-scanner.rules with 

```

BUS="usb", ATTRS{product}=="Photosmart C3100 series", GROUP="scanner", MODE="664" 

```

But this changed nothing.

Here's what I see as a user:

```

dave@george ~> groups

tty wheel cron console audio cdrom video games apache usb users scanner

dave@george ~> sane-find-scanner -q

found USB scanner (vendor=0x03f0, product=0x5611) at libusb:001:002

dave@george ~> scanimage -L

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).

```

Any help is appreciated!

----------

## PaulBredbury

There's a big difference between = and ==

You're trying to assign the BUS, which is wrong.

Use == immediately after BUS.

----------

## dncohen

Damn, I'm good.  Of course I would have gotten nowhere without this thread.

I copied a line from 70-libsane.rules and modified it slighly.  Here's what I needed,

```

ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="5611", MODE="664", GROUP="scanner"

```

----------

## erikderzweite

I had same problem - xsane/kooka worked only as root. Abovementioned solutions didn't help. It turned out that I needed to change permissions to /var/lib/lock/sane/. Afterwards it has started to work.

----------

## The Mountain Man

 *erikderzweite wrote:*   

> I had same problem - xsane/kooka worked only as root. Abovementioned solutions didn't help. It turned out that I needed to change permissions to /var/lib/lock/sane/. Afterwards it has started to work.

 

Would you mind explaining this solution a little more?  What changes did you make exactly?

Edit: Never mind.  Creating a rule in udev works for me.

----------

