LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Scanner to work as USER and not forced as ROOT Root (Suse 9.1) (https://www.linuxquestions.org/questions/linux-hardware-18/scanner-to-work-as-user-and-not-forced-as-root-root-suse-9-1-a-203363/)

1kyle 07-10-2004 08:51 AM

Scanner to work as USER and not forced as ROOT Root (Suse 9.1)
 
SUSE and a number of distributions have a problem assigning proper user rights to USB HOTPLUG devices such as scanners and I'm sure running as root when you don't have to is not a good idea --especially if other users can use the machine(s).

This problem is not restricted to SUSE but comes from the way the HOTPLUG USB stuff has been implemented in the 2.6 Kernel.

Finally found the answer so I can use XSANE / KOOKA as a user RATHER than ROOT.

The problem is in the permissions gained via HOTPLUG.


So look at your /etc/hotplug/usb directory and pick up file sane-hardcoded.usermap

You'll see some cryptic entries like this
desktopdev 0x0003 0x03f0 0x0101 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
desktopdev 0x0003 0x03f0 0x0102 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
desktopdev 0x0003 0x03f0 0x0105 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0

etc.

The first entry in each line is the name of the script to execute.
The next part identifies your scanner device.

Your scanner will have a number and depending on this number it will exeute the named script.

In this case they are all called desktopdev. As I only have 1 scanner I'm not going to find out which it is since all of the entries call the same script.

The old script is as follows (default with the system)

#!/bin/bash
# This adds a USB device to the "desktop usb" group.
# You just need to create an entry "desktopdev ..." in a usermap file
# and it will be picked up automatically.

if [ -x /sbin/resmgr -a ! -z "$DEVICE" ]; then
if [ "${ACTION}" = "add" ]; then
/sbin/resmgr ${ACTION} ${DEVICE} desktop usb && exit 0
else
/sbin/resmgr ${ACTION} ${DEVICE} desktop && exit 0
fi
fi


I've changed this to

#!/bin/bash
# This adds a USB device to the "desktop usb" group.
# You just need to create an entry "desktopdev ..." in a usermap file
# and it will be picked up automatically.
if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
chown root "${DEVICE}"
chgrp scanner "${DEVICE}" <======= your new group scanner
chmod 660 "${DEVICE}"
fi

Now I create a group called scanner and add the user to it. The name must be the same as in the chgrp line

file is in /etc/group

add the scanner group
........various entries etc etc
at:!:25:
public:x:32:
video:x:33:kyle
games:x:40:
xok:x:41:
trusted:x:42:
modem:x:43:
ftp:x:49:
postfix:!:51:
maildrop:!:59:
man:x:62:
sshd:!:65:
ntadmin:!:71:
scanner:x:93:kyle <================add this line (with your userid of course)
mobody:x:65533:nobody
nogroup:x:65534:nobody
users:x:100:

Add your userid to the scanner group.

Re-boot the machine -- not sure if it's necessary to re-boot but coming from Windows you always have to re-boot when changing system configurations --or so it seemed to me anyway.

He presto it works.


All times are GMT -5. The time now is 07:27 AM.