SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Slackware 14 (Server),OpenSuse 13.2 (Laptop & Desktop),, OpenSuse 13.2 on the wifes lappy
Posts: 781
Rep:
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?
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.
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
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.
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 ----
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
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?
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.
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
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.
Distribution: Slackware 11.0; Kubuntu 6.06; OpenBSD 4.0; OS X 10.4.10
Posts: 345
Rep:
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.