Unix Technical Forum

sane as non-root?

This is a discussion on sane as non-root? within the Gentoo Linux Support forums, part of the Unix Operating Systems category; --> When I try to run xsane as non-root it does not find any scanners. The same for sane-find-scanner, it ...


Go Back   Unix Technical Forum > Unix Operating Systems > Gentoo Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-21-2008, 11:04 AM
Ken Scharf
 
Posts: n/a
Default sane as non-root?

When I try to run xsane as non-root it does not find any scanners.
The same for sane-find-scanner, it only works as root.
I was able to run xsane as root (but that is insane).
The gimp, also does not show sane in the aquire menu, even when
run by root (do I need to rebuild the gimp with sane support? How?)

How can I set up xsane to run by a user. I am in the scanner group.
What else is needed?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-21-2008, 11:04 AM
Albert
 
Posts: n/a
Default Re: sane as non-root?

Ken Scharf has offered us the following clue :

> When I try to run xsane as non-root it does not find any scanners.
> The same for sane-find-scanner, it only works as root.
> I was able to run xsane as root (but that is insane).
> The gimp, also does not show sane in the aquire menu, even when
> run by root (do I need to rebuild the gimp with sane support? How?)
>
> How can I set up xsane to run by a user. I am in the scanner group.
> What else is needed?


When I connect my USB scanner, hotplug launches the script libusbscanner
which changes the rights for users. This script is in /etc/hotplug/usb.
Look at the end. You have to uncomment the wanted lines.
There are two possibilities, depending on your usage (my PC is single home
user, I don't care that much).

Gimp works OK and launches the scanner. I've a HP OfficeJetV40 with hpoj and
a Canon Canoscan Lide 20.

#!/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 [ -z "$DEVICE" ] ; then
IF=$(echo $DEVPATH | sed 's:\(bus/usb/devices/\)\(.*\)-\(.*\):\2:')
DEV=$(echo $DEVPATH | sed 's:\(bus/usb/devices/\)\(.*\)-\(.*\):\3:')
DEV=$(expr $DEV + 1)
DEVICE=$(printf '/proc/bus/usb/%.03d/%.03d' $IF $DEV)
fi


#Secure version
#
#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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-21-2008, 11:04 AM
Ken Scharf
 
Posts: n/a
Default Re: sane as non-root?

Albert wrote:
> Ken Scharf has offered us the following clue :
>
>
>>When I try to run xsane as non-root it does not find any scanners.
>>The same for sane-find-scanner, it only works as root.
>>I was able to run xsane as root (but that is insane).
>>The gimp, also does not show sane in the aquire menu, even when
>>run by root (do I need to rebuild the gimp with sane support? How?)
>>
>>How can I set up xsane to run by a user. I am in the scanner group.
>>What else is needed?

>
>
> When I connect my USB scanner, hotplug launches the script libusbscanner
> which changes the rights for users. This script is in /etc/hotplug/usb.
> Look at the end. You have to uncomment the wanted lines.
> There are two possibilities, depending on your usage (my PC is single home
> user, I don't care that much).
>
> Gimp works OK and launches the scanner. I've a HP OfficeJetV40 with hpoj and
> a Canon Canoscan Lide 20.
>
> #!/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 [ -z "$DEVICE" ] ; then
> IF=$(echo $DEVPATH | sed 's:\(bus/usb/devices/\)\(.*\)-\(.*\):\2:')
> DEV=$(echo $DEVPATH | sed 's:\(bus/usb/devices/\)\(.*\)-\(.*\):\3:')
> DEV=$(expr $DEV + 1)
> DEVICE=$(printf '/proc/bus/usb/%.03d/%.03d' $IF $DEV)
> fi
>
>
> #Secure version
> #
> #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
>
>

I was able to gain access to xsane as a user by
"chgrp scanner /dev/sg0"
but I'd have to put this in a script as you did because
udev recreates these devices at will.
I could also modify the rescan-scsi-bus.sh script to
do the same.

I still don't see sane as an option in gimp for aquire
in the file menu tab. What use flags did you use
to build the gimp?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-21-2008, 11:04 AM
J.O. Aho
 
Posts: n/a
Default Re: sane as non-root?

Ken Scharf wrote:

> I was able to gain access to xsane as a user by
> "chgrp scanner /dev/sg0"
> but I'd have to put this in a script as you did because
> udev recreates these devices at will.
> I could also modify the rescan-scsi-bus.sh script to
> do the same.


What about edit your udev rules and set the sg0 to be owned by the group scanner

You have in your

BUS=="scsi", KERNEL="sg[0-9]*", ACTION=="add", DRIVER=="sr", GROUP="cdrom"

maybe you could change that to

BUS=="scsi", KERNEL="sg[0]*", ACTION=="add", DRIVER=="sr", GROUP="scanner"
BUS=="scsi", KERNEL="sg[1-9]*", ACTION=="add", DRIVER=="sr", GROUP="cdrom"

This will take effect at next bootup (not sure how to make udev to reload rules)


> I still don't see sane as an option in gimp for aquire
> in the file menu tab. What use flags did you use
> to build the gimp?


You need to emerge sane-frontends and have USE="gimp" to get the feature for
gimp, but it seems to not work that well, so don't count things will work.


//Aho
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-21-2008, 11:04 AM
J.O. Aho
 
Posts: n/a
Default Re: sane as non-root?

J.O. Aho wrote:
> Ken Scharf wrote:


>> I still don't see sane as an option in gimp for aquire
>> in the file menu tab. What use flags did you use
>> to build the gimp?

>
> You need to emerge sane-frontends and have USE="gimp" to get the feature
> for gimp, but it seems to not work that well, so don't count things will
> work.


Noticed while I looked at the ebuilds, you need to emerge xsane with the
USE="gimp" too to get this to work.


example:
USE="gimp" emerge sane-frontends xsane



//Aho
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-21-2008, 11:05 AM
Ken Scharf
 
Posts: n/a
Default Re: sane as non-root?

J.O. Aho wrote:
> J.O. Aho wrote:
>
>> Ken Scharf wrote:

>
>
>>> I still don't see sane as an option in gimp for aquire
>>> in the file menu tab. What use flags did you use
>>> to build the gimp?

>>
>>
>> You need to emerge sane-frontends and have USE="gimp" to get the
>> feature for gimp, but it seems to not work that well, so don't count
>> things will work.

>
>
> Noticed while I looked at the ebuilds, you need to emerge xsane with the
> USE="gimp" too to get this to work.
>
>
> example:
> USE="gimp" emerge sane-frontends xsane
>
>
>
> //Aho

Thanks, I will add the flag and rebuild sane. However, I think
all I might need to do is to edit the gimp plugin config file,
need to google to find the directions for that.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-21-2008, 11:05 AM
Ken Scharf
 
Posts: n/a
Default Re: sane as non-root?

J.O. Aho wrote:
> Ken Scharf wrote:
>
>> I was able to gain access to xsane as a user by
>> "chgrp scanner /dev/sg0"
>> but I'd have to put this in a script as you did because
>> udev recreates these devices at will.
>> I could also modify the rescan-scsi-bus.sh script to
>> do the same.

>
>
> What about edit your udev rules and set the sg0 to be owned by the group
> scanner
>

the only rules file I have in /etc/udev is 50-udev.rules
and it doesn't have any KERNEL="sg " entries at all.
Yet I do have an /dev/sg0 when the system is booted with
the scanner powered up.

> You have in your
>
> BUS=="scsi", KERNEL="sg[0-9]*", ACTION=="add", DRIVER=="sr",
> GROUP="cdrom"
>
> maybe you could change that to
>
> BUS=="scsi", KERNEL="sg[0]*", ACTION=="add", DRIVER=="sr",
> GROUP="scanner"
> BUS=="scsi", KERNEL="sg[1-9]*", ACTION=="add", DRIVER=="sr",
> GROUP="cdrom"
>
> This will take effect at next bootup (not sure how to make udev to
> reload rules)
>
>
>> I still don't see sane as an option in gimp for aquire
>> in the file menu tab. What use flags did you use
>> to build the gimp?

>
>
> You need to emerge sane-frontends and have USE="gimp" to get the feature
> for gimp, but it seems to not work that well, so don't count things will
> work.
>
>
> //Aho

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-21-2008, 11:05 AM
J.O. Aho
 
Posts: n/a
Default Re: sane as non-root?

Ken Scharf wrote:
> J.O. Aho wrote:


>> Noticed while I looked at the ebuilds, you need to emerge xsane with the
>> USE="gimp" too to get this to work.
>> example:
>> USE="gimp" emerge sane-frontends xsane

> Thanks, I will add the flag and rebuild sane. However, I think
> all I might need to do is to edit the gimp plugin config file,
> need to google to find the directions for that.


No, it's not that simple, what you need is include gimp support into the
scanning tools, as long as they don't have the support, gimp can't talk with
them and therefore can't use the scanner at all, this forces you to recompile
sane-frontends and xsane with gimp support (by default this isn't included).


//Aho
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-21-2008, 11:05 AM
J.O. Aho
 
Posts: n/a
Default Re: sane as non-root?

Ken Scharf wrote:
> J.O. Aho wrote:
>> Ken Scharf wrote:
>>
>>> I was able to gain access to xsane as a user by
>>> "chgrp scanner /dev/sg0"
>>> but I'd have to put this in a script as you did because
>>> udev recreates these devices at will.
>>> I could also modify the rescan-scsi-bus.sh script to
>>> do the same.

>>
>> What about edit your udev rules and set the sg0 to be owned by the group
>> scanner
>>

> the only rules file I have in /etc/udev is 50-udev.rules
> and it doesn't have any KERNEL="sg " entries at all.
> Yet I do have an /dev/sg0 when the system is booted with
> the scanner powered up.


That sounds strange, that they don't setup any rules for sg, feels like you
may have an ould or experimental udev, you should at least have
sys-fs/udev-079-r1.


//Aho
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-21-2008, 11:05 AM
Ken Scharf
 
Posts: n/a
Default Re: sane as non-root?

J.O. Aho wrote:
> Ken Scharf wrote:
>
>> J.O. Aho wrote:
>>
>>> Ken Scharf wrote:
>>>
>>>> I was able to gain access to xsane as a user by
>>>> "chgrp scanner /dev/sg0"
>>>> but I'd have to put this in a script as you did because
>>>> udev recreates these devices at will.
>>>> I could also modify the rescan-scsi-bus.sh script to
>>>> do the same.
>>>
>>>
>>> What about edit your udev rules and set the sg0 to be owned by the group
>>> scanner
>>>

>> the only rules file I have in /etc/udev is 50-udev.rules
>> and it doesn't have any KERNEL="sg " entries at all.
>> Yet I do have an /dev/sg0 when the system is booted with
>> the scanner powered up.

>
>
> That sounds strange, that they don't setup any rules for sg, feels like
> you may have an ould or experimental udev, you should at least have
> sys-fs/udev-079-r1.
>
>
> //Aho

I havn't done a emerge sync recently, but I just checked to see
what I have...

# emerge -pv udev
These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild R ] sys-fs/udev-070-r1 (-selinux) -static 0 kB
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:24 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com