LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-20-2004, 02:12 AM   #16
vdemuth
Member
 
Registered: Oct 2003
Location: West Midlands, UK
Distribution: Slackware 14 (Server),OpenSuse 13.2 (Laptop & Desktop),, OpenSuse 13.2 on the wifes lappy
Posts: 781

Rep: Reputation: 98

Yes, have tried the post 9 and 10 solutions, but as elswhere in this thread, they are only temporary. I am certain this is something to do with the way hotplug handles setting permissions, but I am not yet good enough with linux to work it out. As I understand it, when I plug in/switch on my usb scanner, an entry appears in /proc/bus/usb/AAA/BBB (wher AAA/BBB is the bus/device respectively), and is initially owned by root. So how then, do I get root to pass ownership to the user who plugged in. i.e. run chown on the /proc/bus/AAA/BBB without root permissions in the first place, and all from within a script?
 
Old 07-20-2004, 07:36 AM   #17
craigienz
LQ Newbie
 
Registered: Aug 2003
Location: Wellington, New Zealand
Distribution: Slackware
Posts: 22

Original Poster
Rep: Reputation: 15
Unfortunately I won't be much help here. I am realitively new to Linux, and whilst I can do a few things on it, I am still a newby too. Hopefully someone out there can help out.
 
Old 07-22-2004, 03:15 AM   #18
vitko
LQ Newbie
 
Registered: Jul 2004
Posts: 3

Rep: Reputation: 0
kernel 2.6.7 USB scanner for user, a success story

Hi,

Today I'm using my Mustek BearPaw 1200 as a normal user, despite kernel 2.6.7!

Steps I've done (as root if not stated otherwise):

I plugged in the scanner, verified it is acessible: (via libusb on usbfs I guess, you need to have it mounted, but with 2.6.x kernel you have it probably working already)

$ sane-find-scanner
...
found USB scanner (vendor=0x05d8, product=0x4002, chip=GT-6801) at libusb:001:004
...

$ scanimage -L
device `gt68xx:libusb:001:004' is a Mustek BearPaw 1200 CU flatbed scanner

Then I poited my browser to http://www.meier-geinitz.de/sane/gt68xx-backend/ to download firmware for my scanner, it is file 'ps1fw.usb', xsane is happy to find it in /usr/share/sane/gt68xx/ps1fw.usb, so I copied it there.

Now scanning works for root, not for normal user. We need hotplug package. I'm using Debian (Sid), so

apt-get install hotplug

it installs latest hotplug package.

Then I enabled hotplug debugging, because of a lot of frustration day before (but it is another story, now it works as it should):

edited /etc/hotplug.d/default/default.hotplug, uncommented line

# DEBUG=yes export DEBUG

so now I have

DEBUG=yes
export DEBUG

On another console I run

tail -f /var/log/messages

to see what is going on.

Plugged out the scanner, plugged in, voila, a lot of messages

...
Jul 22 09:52:15 ws14-l scsi.agent[15577]: SCSI remove event not supported
Jul 22 10:04:08 ws14-l kernel: usb 1-2: new full speed USB device using address 6
Jul 22 10:04:08 ws14-l default.hotplug[15759]: arguments (usb) env (OLDPWD=/ DEVPATH=/devices/pci0000:00/0000:00:07.2/usb1/1-2 PATH=/bin:/sbin:/usr/sbin:/usr/bin ACTION=add PWD=/etc/hotplug HOME=/ SHLVL=2 DEBUG=yes SEQNUM=412 _=/usr/bin/env)
Jul 22 10:04:08 ws14-l default.hotplug[15759]: invoke /etc/hotplug/usb.agent ()
Jul 22 10:04:08 ws14-l default.hotplug[15771]: arguments (usb) env (OLDPWD=/ DEVPATH=/devices/pci0000:00/0000:00:07.2/usb1/1-2/1-2:1.0 PATH=/bin:/sbin:/usr/sbin:/usr/bin ACTION=add PWD=/etc/hotplug HOME=/ SHLVL=2 DEVICE=/proc/bus/usb/001/006 PRODUCT=5d8/4002/100 TYPE=255/255/255 DEBUG=yes SEQNUM=413 _=/usr/bin/env)
Jul 22 10:04:08 ws14-l default.hotplug[15771]: invoke /etc/hotplug/usb.agent ()
Jul 22 10:04:09 ws14-l usb.agent[15771]: Setup libusbscanner for USB product 5d8/4002/100
Jul 22 10:04:09 ws14-l usb.agent[15771]: libusbscanner: loaded successfully
Jul 22 10:04:09 ws14-l usb.agent[15771]: Module setup libusbscanner for USB product 5d8/4002/100

Now lets have a look at our scanner device

$ la /proc/bus/usb/001/
...
-rw-rw---- 1 root scanner 43 2004-07-22 10:04 006

YES, it is there, perms look good, nice group, so

adduser myuser scanner

Login as myuser, run xsane, it works, scans, makes pictures, I'm happy.

Vitko
 
Old 07-30-2004, 12:30 PM   #19
mr666white
Member
 
Registered: Jun 2004
Location: Leeds, England
Distribution: Gentoo, IPCop
Posts: 54

Rep: Reputation: 15
Right, I've found something mandrake does right (shock horror!) here's the script it uses for the job.

***Edit*** I should reall say where this came from / whare to put it:
/etc/hotplug/usb

#!/bin/bash
# Filename: /etc/hotplug/usb/usbscanner
# This file was installed by the sane-backends package.
#
# 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 usb group
# and the first user that logged in.
#
# Ownership is set to $USER.usb, where $USER is the first user that logged
# in (through pam_console). If there is no user logged in, the ownership
# will get set to root.usb. Permissions are set to 0660.
#
# Arguments :
# -----------
# ACTION=[add|remove]
# DEVICE=/proc/bus/usb/BBB/DDD
# TYPE=usb

if [ "$ACTION" = "add" -a "$TYPE" = "usb" ] && [ -f "${DEVICE}" ]; then
if [ -f /var/run/console.lock ]; then
USER=`cat /var/run/console.lock`
else
USER=root
fi
# sanity check
if [ -z $USER ]; then
USER=root
fi
chown $USER:usb "$DEVICE"
chmod 0660 "$DEVICE"
fi

I have this working now with my mandrake laptop, soon to become FC2 and my FC2 server

Last edited by mr666white; 08-07-2004 at 06:41 AM.
 
Old 08-03-2004, 03:15 PM   #20
esteeven
Senior Member
 
Registered: Oct 2001
Location: Bristol UK
Distribution: Arch Slackware Ubuntu
Posts: 1,082

Rep: Reputation: 52
well. I had the same problem with my Canon Lide --- it worked as root but not as user. I added myuser to scanner but nothing. Then I saw Vitko's reference to Debian ----- so did apt-get install hotplug and ----da daaaaaah ----- it works. Thanks a million ----- I really felt as though I was about to embark upon a struggle. Good luck to everyone else ----
 
Old 08-09-2004, 05:39 AM   #21
vitko
LQ Newbie
 
Registered: Jul 2004
Posts: 3

Rep: Reputation: 0
mr666white: yes, that is the way how hotplug package works :-)

esteeven: what model of Lide do you have? I had bad experience with Cannon Lide 80, it doesn't seem to be supported by sane yet :-(
 
Old 08-09-2004, 08:19 AM   #22
mr666white
Member
 
Registered: Jun 2004
Location: Leeds, England
Distribution: Gentoo, IPCop
Posts: 54

Rep: Reputation: 15
more to the point, we smile at open source code and use the mandrake config that *works* on the many fc2 boxen that somehow fail to access hardware. Oneday I'll get my clie syncing with something other than mandrake....Oneday
 
Old 09-04-2004, 04:23 PM   #23
shilo
Senior Member
 
Registered: Nov 2002
Location: Stockton, CA
Distribution: Slackware 11 - kernel 2.6.19.1 - Dropline Gnome 2.16.2
Posts: 1,132

Rep: Reputation: 50
I have been following along with this thread adn have recently been trying to get things working the "right" way. Here is what I've come up with so far. There is probably some repetition here, but I want to make it clear what is going on. The scanner, as of the 2.6.X kernel, is handled in user space. That means there is no /dev entry. This also means that udev does not have anything to do with it, since udev handles devices in the /dev directory. The correct method for handling prermissions is the use of a hotplug script. Luckily, one is provided. It just needs a little fixing

There should be a file named /etc/hotplug/usb/libusbscanner on your system already. If you haven't messed around with it, it should look like this:

Code:
#!/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

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
So we can see a couple of things. First, if we leave this script alone, USB devices will be given an owner of root, a group of scanner, and permissions of 660. That's good enough permissions that anyone in the scanner group will be able to use the scanner.

Problem #1

Looking in /etc/group there is no scanner group. So, all you have to do is add a scanner group with the users you want to be able to use the scanner as members of the group. Now, if you don't want to add a scanner group, the script provides an alternate method. Comment out the chown line, or comment out that entire section of script and uncommetn out the bottom portion. We are looking good so far.

Now, I go ahead and reboot and, wow, nothing's changed. Quick thinking, I unplug the scanner and plug it back in. Amazingly, it now works. So, just as lucho had noted, the script is not dbeing called at boot time, but is called during hotplug events.

So has anyone come up with a "correct" hotplugging solution other than installing non-Slackware software? It seems that the only thing that is missing right now is forcing the /etc/hotplug/usb/libusbscanner script to run at boot time, since it works great for hotplug events. Any thoughts?
 
Old 09-18-2004, 01:01 PM   #24
tcomputerchip
Member
 
Registered: Sep 2004
Location: LA,California
Distribution: FC4, FC5smp, REL4, REL5
Posts: 58

Rep: Reputation: 15
Simply Put, changing the permissions and adding a "scanner" group works. MAKE sure you add your local user to that group. Most systems have a GUI where you can do this. Im not sure how to add a user to the group through command line.

If you are trying to scan inside GIMP and you are looking for the scanner device try:
"File->Aquire->:xsaneevice Dialog..."

To test your scanner attached (as said above). Type "xsane" in the Terminal or "Run" location.

Also, if you get the scanner to work outside of GIMP, try saving the settings in the sane folder when you are in xsane. This seemed to work fine for me.

Last edited by tcomputerchip; 09-18-2004 at 01:02 PM.
 
Old 09-18-2004, 06:22 PM   #25
jimbob1234
LQ Newbie
 
Registered: Nov 2003
Distribution: Slackware Current
Posts: 21

Rep: Reputation: 15
Thanks

Thanks craigienz!

I used your above method to make my PTP digital camera accessible as a user.
 
Old 09-19-2004, 04:14 AM   #26
craigienz
LQ Newbie
 
Registered: Aug 2003
Location: Wellington, New Zealand
Distribution: Slackware
Posts: 22

Original Poster
Rep: Reputation: 15
Hey jimbob1234,

Thanks for the thanks. I am glad that I helped someone at least. Good luck with your computer.
 
Old 12-17-2004, 03:50 AM   #27
grostoto
LQ Newbie
 
Registered: Dec 2004
Distribution: slack
Posts: 5

Rep: Reputation: 0
Hello everyone,

Maybe i ban help lucho (which hotplug is OK but not coldplug).
I use Slack 10 and kernel 2.6.9 (and epson 1660 photo usb scanner)
I searched among hotplug scripts what it was OK at hotplug and not at boot time (so called coldplug:
In fact, it seems that /proc/bus/usb/XXX/XXX is not here before hotplug script starts!
So even if everything is OK according to DEBUG mode in hotplugs scripts,
the action chown & chmod does not do anything at boot time.
A solution i found is to make a few sleep in /etc/hotplug/usb/libusbscanner script:
Here is the snippet:
#!/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
# added 5 second sleep in order that $DEVICE be created

setpermissions()
{
sleep 5
chown root:scanner "$DEVICE"
chmod 0660 "$DEVICE"
}

if [ "$ACTION" = "add" -a "$TYPE" = "usb" ]; then
setpermissions &
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

In fact (on my system) it really takes 3 sec for /proc/bus/usb to be created, 5 sec will, i think, be enough for everyone use.
Note that it does not make boot up during 5 sec more since setpermissions is forked (&) from script.
I know this is probably not the best way, (since it will work 'only' for the usb scanner) but i found rather simple and
clear.

If you want something better, you might add sleep in /etc/hotplus/usb.rc after modprobing ehci-hcd / ohci-hcd / uhci-hcd instead => therefore it will work for any usb device. (add sleep in the beginning of usb_boot_events
function and call it with a '&' for instance)

The best way, i think, is to fix those modules (xhci-hcd ) that returns before they make /proc/bus/usb/XXX/XXX
available (maybe a bug, since /proc is real time fs?), and thus we shouldn't have to add any sleep in hotplug scripts.


Hope it helps
grostoto
 
Old 12-21-2004, 02:23 PM   #28
hussar
Member
 
Registered: Oct 2003
Location: Heidelberg, Germany
Distribution: Slackware 11.0; Kubuntu 6.06; OpenBSD 4.0; OS X 10.4.10
Posts: 345

Rep: Reputation: 30
I read through this thread and got my scanner recognized without being root by changing the permissions on /proc/bus/usb/003/003 to 0666. Problem is, now when I try to scan something as root or as a user, I get the error message "Failed to start scanner: Device busy"

Anyone have any ideas what I can do here to get this to work?
 
Old 12-21-2004, 02:28 PM   #29
tcomputerchip
Member
 
Registered: Sep 2004
Location: LA,California
Distribution: FC4, FC5smp, REL4, REL5
Posts: 58

Rep: Reputation: 15
Try shutting off the computer, disconnecting the scanner, then connecting it in another USB slot and starting your OS. You may need to reset your permissions again. But thats what seemed to work for me.
 
Old 12-21-2004, 02:35 PM   #30
tcomputerchip
Member
 
Registered: Sep 2004
Location: LA,California
Distribution: FC4, FC5smp, REL4, REL5
Posts: 58

Rep: Reputation: 15
Also, sometimes you maybe logged in as root and your user account at the sametime. This may result in a busy signal. Sometimes my iPod does this.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Scanner Access Rick069 Linux - Hardware 5 10-04-2005 04:43 PM
How do I access my scanner? maestro52 Fedora 4 01-23-2005 11:26 PM
Scanner as root 900i Mandriva 3 12-04-2004 01:40 PM
Scanner to work as USER and not forced as ROOT Root (Suse 9.1) 1kyle Linux - Hardware 0 07-10-2004 08:51 AM
scanner access tsitras Linux - Hardware 3 04-29-2004 08:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration