# [SOLVED] xsane only works as root

## cfloeter

I admit this is an old one, the forums are full with it.   :Rolling Eyes:   I've read through many of them, consulted FAQs, HOWTOs and webpages, but still no success.... scanimage -L (and thus xsane or kooka) will only find my scanner as root, not as user.

My user is in the usb and scanner groups, and permissions in /proc/bus/usb/xxx/yyy are set correctly:

 *Quote:*   

> cf@sakura ~ $ groups
> 
> wheel uucp audio cdrom games cdrw usb users portage qemu scanner
> 
> 

 

 *Quote:*   

> cf@sakura ~ $ sane-find-scanner -q
> 
> found USB scanner (vendor=0x04a9 [Canon], product=0x2220 [CanoScan], chip=LM9832/3) at libusb:004:002
> 
> 

 

 *Quote:*   

> cf@sakura ~ $ ls -l /proc/bus/usb/004
> 
> total 0
> 
> -rw-rw-r--  1 root usb     43  6. Jan 12:58 001
> ...

 

But still, as user, scanimage -L gives me:

 *Quote:*   

> cf@sakura ~ $ 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
> ...

 

Whereas as root, it gives:

 *Quote:*   

> sakura cf # scanimage -L
> 
> device `plustek:libusb:004:002' is a Canon LiDE25 USB flatbed scanner
> 
> 

 

My specs: kernel 2.6.15-rc7 vanilla, libusb 0.1.10a, udev 079. 'usb' and 'scanner' are set in my USE flags.

So WTF is going on?? Why is it still not recognizing my scanner as user?  :Crying or Very sad: Last edited by cfloeter on Tue Jan 10, 2006 11:16 am; edited 1 time in total

----------

## Drunkula

Though I have a SCSI scanner I had the same problem.  I found the answer here.

https://forums.gentoo.org/viewtopic-t-367857-highlight-scsi+scanner.html

However, take note, though the solution directly addresses SCSI you'll have to modify a command or two to work on a USB scanner.

----------

## cfloeter

Is the creation of /dev/scanner necessary to solve the problem? Having a USB scanner using libusb, I don't know where I should link it to...

----------

## Drunkula

 *cfloeter wrote:*   

> Is the creation of /dev/scanner necessary to solve the problem? Having a USB scanner using libusb, I don't know where I should link it to...

 

I don't believe so - however the correct permissions get assigned to it (/dev/scanner).  When I did that xsane found my scanner as a regular user.  I haven't yet taken the time to learn the ins & outs of using udev.  :Wink: 

----------

## cfloeter

Well, the sane-plustek manpage tells something about /dev/usbscanner, so I manually created it and linked it to /proc/bus/usb/xxx/yyy, just to see what would happen. But scanimage still don't find my scanner. I'm at my wits' end.

Ok, I can use my scanner as root. Probably many users do the same. However, I'm feeling like Gentoo has left me alone for the first time. Are other Canon LiDE owners experiencing the same problem, or did everyone manage to set it up and work as it should??

Btw..... "Scanner Access Now Easy" ???    :Shocked: 

Yeah, sure. 

I'll laugh when I have time.    :Wink: 

----------

## Drunkula

I don't believe you should have linked it to something in /proc/usb....  Instead you should be linking to something like /dev/usb/scanner0.  I  don't know what a USB scanner would appear as in /dev.  Just a guess but I think even some USB scanners use the SCSI Generic module (modprobe sg) so it should show up as /dev/sg[0-9].  Try modprobing sg (assuming it's built as a module) and check in /var/log/messages to see if it mentions the device name.  

Have you checked http://www.linux-usb.org/USB-guide/book1.html ?

----------

## cfloeter

With the help of the newsgroups, I was able to resolve the problem.

The plustek driver needs a lock directory named /var/lib/lock/sane, and the permissions of /var/lib/lock had to be set to 775. After that, my scanner was correctly found as user.  If the ebuild had done this in the first place, it would have saved me a lot of hassle...   :Razz: 

Anyway, thanks for your answers Drunkula, I appreciate it.

FYI, the scanner is found with libusb - a special device node in /dev isn't needed.

C.

----------

## My_World

From the SANE F.A.Q page:

 *Quote:*   

> 
> 
> 9.2. How can I use a USB scanner with Linux 2.6?
> 
> With Linux 2.4.* you could either use the kernel scanner module or libusb to access USB scanners. In Linux 2.6.4 the kernel scanner module was removed. Therefore with this and later kernels libusb must be used. While SANE automatically uses libusb when the library and its header file were present during the build of sane-backends, setting permissions will require some attention.
> ...

 

Hmm, so it seems like the USB scanner thingy is not so easy as they would like us to think...

Anyway, I have the same problem as above mentioned, only his solution did not work for me, so lemme see if I can figure out how to configure this SANE hotplug to work...

 :Sad: 

----------

## cfloeter

 *My_World wrote:*   

> Hmm, so it seems like the USB scanner thingy is not so easy as they would like us to think...
> 
> Anyway, I have the same problem as above mentioned, only his solution did not work for me, so lemme see if I can figure out how to configure this SANE hotplug to work...
> 
> 

 

-Start with http://gentoo-wiki.com/HOWTO_Install_a_USB_scanner

-Make sure your user is in the usb and scanner groups

-Make sure your USE flags contain usb and scanner as well (if they didn't, set them and re-emerge xsane, sane-backends, sane-frontends (and probably libusb and udev as well)

-If your scanner doesn't seem to be supported by the stable versions of sane-backends, emerge the latest unstable version

-When using the plustek driver, make sure the permissions of the lock directory are correctly set:

 *Quote:*   

> # mkdir /var/lib/lock
> 
> # chmod 775 /var/lib/lock
> 
> # mkdir /var/lib/lock/sane
> ...

 

----------

## -=GGW=- $ol!d $n4>|e

I'm having same problem, none of these solutions fixed it for me

----------

## razer

 *-=GGW=- $ol!d $n4>|e wrote:*   

> I'm having same problem, none of these solutions fixed it for me

 

Same thing here, that's unbelievable

What answer can we give when Windows users tell you "Linux is too complex and not user friendly"

I'm using Linux since 10 years, and I can't use my scanner as normal user, even with 3 hours of searching...

/EDIT :

Fix the problem after a search on bugzilla : https://bugs.gentoo.org/show_bug.cgi?id=131756

Seems to be an libusb related bug

 *Quote:*   

> Changing perms on /dev/bus/usb/appropriate/file allows non-root access again.
> 
> Don't have a pretty, general solution.
> 
> 

 

----------

## PaulBredbury

Well, for a Canon Lide 30, I have in  /etc/udev/rules.d/91-local.rules

```
BUS=="usb", SYSFS{product}=="CanoScan", GROUP="scanner", MODE="0660"
```

"91" means that this rule takes precedence over other udev rules in lower-numbered filenames.

----------

## razer

 *PaulBredbury wrote:*   

> Well, for a Canon Lide 30, I have in  /etc/udev/rules.d/91-local.rules
> 
> ```
> BUS=="usb", SYSFS{product}=="CanoScan", GROUP="scanner", MODE="0660"
> ```
> ...

 

Tried it doesn't work for me, udev sucks   :Sad: 

----------

## midget

This is nuts   :Shocked:  I must've tried people's suggestions from a squillion forum threads by now and I still can't solve it. DOH!

----------

## Headrush

 *PaulBredbury wrote:*   

> Well, for a Canon Lide 30, I have in  /etc/udev/rules.d/91-local.rules
> 
> ```
> BUS=="usb", SYSFS{product}=="CanoScan", GROUP="scanner", MODE="0660"
> ```
> ...

 

I thought the first rule to match was used so "91" would NOT take precedence.

----------

## alex

How can this thread be set to SOLVED, while there isn't a working solution and there are still so many users out there having the same problem?   :Sad: 

----------

## snorri_dj

The udev rule also worked for me. I put my local udev rules in /etc/udev/rules.d/10-locale.rules.

I also modified the udev rule a bit so a symlink is made

```
BUS="usb", SYSFS{product}="CanoScan", GROUP="scanner", MODE="0660", SYMLINK="scanner"
```

That will symlink /dev/scanner to /dev/bus/usb/<bus#>/<dev#> that corresponds to my CanoScan scanner. You could also identify it with idProduct numbers or idVendor numbers (obtain from lsusb) if you liked. Also, dev/scanner has root:scanner permissions, so as long as your user is in the scanner group, xsane will fire up no problem.[/code]

----------

## PaulBredbury

 *Headrush wrote:*   

> I thought the first rule to match was used

 

True with NAME, but not true with MODE and GROUP I think. man udev explains about NAME.

 *Quote:*   

> BUS=..., SYSFS{product}=...

 

That's wrong, in recent versions of udev - comparisons must be made with == rather than =.

----------

## Erdie

My Medion USB Scanner worked fine but now, after upgrading udev to 104, i have the same problem. Only root has access although i have written a udev rule which worked before.

I i do

chmod a+rw /proc/bus/usb/xxx/xxx"

on the device which is shown by sane-find-scanner it works until the scanner is unplugged.

 :Evil or Very Mad: 

-Erdie

----------

## PaulBredbury

 *Erdie wrote:*   

> udev rule which worked before.

 

Well, show it then. I bet it had "=" instead of "==".

----------

## Erdie

I  don´t think so, udev creates a device called /dev/scanner as it is supposed to but the permission on /proc/usb/... like described above prevent a normal user from using the device even the user is in the scanner group and the scanner device has read permission to this group. My udev rules are:

```

#digicam

BUS=="scsi", KERNEL=="sd?1", SYSFS{vendor}=="FUJIFILM", NAME="f700"

#Trekstore 40 Gig

BUS=="scsi", KERNEL=="sd?1", SYSFS{vendor}=="SAMSUNG ", NAME="trekstor40"

#Gmini 402

BUS=="scsi", KERNEL=="sd?1", SYSFS{model}=="Gmini402", NAME="gmini402"

#Trekstore Musikstick

BUS=="scsi", KERNEL=="sd?1", SYSFS{model}=="150 MusicStick  ", NAME="mp3stick"

#Medion Scanner

BUS=="usb", SYSFS{idVendor}=="05d8", NAME="%k", SYMLINK="scanner", GROUP="scanner", MODE="0660

```

I already adjusted the "=" to "==" without success. With "=" before nothing worked - even the device for the digicam and so on ..

-Erdie

----------

## PaulBredbury

 *Erdie wrote:*   

> MODE="0660

 

The final quote is missing there.

Could be fixed with:

/etc/udev/rules.d/91-local.rules (make sure it's 91, so this rule overrides the standard udev rules for GROUP & MODE)

```
BUS=="usb", SYSFS{idVendor}=="05d8", ACTION=="add", NAME="%k", SYMLINK+="scanner", GROUP="scanner", MODE="0660", RUN+="/bin/chmod blah blah"
```

I've included NAME in this rule, although we don't care whether it's overruled by the standard udev rules, because it's the SYMLINK that is important.

----------

## Erdie

... the missing final quote was an cut & past error. The quote exists.

 *Quote:*   

> 
> 
> ```
> BUS=="usb", SYSFS{idVendor}=="05d8", ACTION=="add", NAME="%k", SYMLINK+="scanner", GROUP="scanner", MODE="0660", RUN+="/bin/chmod blah blah"
> ```
> ...

 

Sorry for my stupid question: 1) How can i use "RUN+="/bin/chmod foobar" if i don´t know how the usb device is called? It could be sometimes /proc/bus/usb/foo/bar and the next time /proc/usb/usb/xxx/yyy and so on ..

2) What does the "+=" after "SYMLINK" mean?

BTW: My rule is called 10-local.rules, if i move it to 91, no device is working anymore (digicam etc.) so i changed it back to 10 ... again. I don´t know why it is so ..

thanks

Erdie

----------

## PaulBredbury

Read man udev. Ensure that the file is /etc/udev/rules.d/91-local.rules and not some random variation.

 *Erdie wrote:*   

> How can i use "RUN+="/bin/chmod foobar" if i don´t know how the usb device is called?

 

Good question. Thankfully, it's not required (also not required is /dev/scanner). Just get these right:

The filename. Setting GROUP and MODE in 10-local.rules is useless if they are overridden by a later rule. This is why the filename installed by media-gfx/sane-backends is 99-libsane.rules

The rule. Example:

```
BUS=="usb", SYSFS{product}=="CanoScan", GROUP="scanner", MODE="0660"
```

----------

## Erdie

 *PaulBredbury wrote:*   

> Read man udev. Ensure that the file is /etc/udev/rules.d/91-local.rules and not some random variation. 

 

Of course, I moved it to 91-local.rules but as I mentioned above, no rule worked anymore afterthat. I did not analyse the problem and moved it back to 10-local.rules. So I have to fix this issue at first.

thanks

Erdie

----------

## Erdie

If i move 10-local-rules to 91-local-rules, the scanner only works after doing:

```

chmod a+rw /proc/bus/usb/xxx/yyy

```

where xxx and yyy are the values given by "sane-find-scanner"

Futhermore all other devices do not work anymore ..  :Question: 

Any suggestions?

-Erdie

----------

