News | About | Get Frugalware | Packages | Documentation | Discussion Forums | Bug Tracker | Wiki | Community | Development

USB scanner works only as root

From FrugalWiki

Jump to: navigation, search

If your USB scanner works only as root, there are an easy way to change this.

First of all try to add your user the the group "scanner".

Find out in which groups you are.

$ id
uid=1006(bmh1980) gid=100(users) groups=100(users)

I'm only memeber of users. So it's no problem to add my the scanner.

Now I add myself (as root) to scanner

$ su -c "usermod -G scanner bmh1980"

After relogin:

$ id
uid=1006(bmh1980) gid=100(users) groups=17(scanner),100(users)

If the first output of id looks like this

$ id
uid=1006(bmh1980) gid=100(users) groups=6(disk),11(floppy),100(users)

you must change the usermod command:

$ su -c "usermod -G disk,floppy,scanner bmh1980"

If this doesn't work, you must change some lines in the hotplug script.

Open the file /etc/hotplug/usb/libusbscanner as root with an editor.

This is my /etc/hotplug/usb/libusbscanner:

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

# latest hotplug doesn't set DEVICE on 2.6.x kernels
if [ -z "$DEVICE" ] ; then
  IF=`echo $DEVPATH | sed 's/\(bus\/usb\/devices\/\)\(.*\)-\(.*\)/\2/'`
  DEV=$(cat /sys/${DEVPATH}/devnum)
  DEVICE=`printf '/proc/bus/usb/%.03d/%.03d' $IF $DEV`
fi

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

Change the last two section to:

# 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

Now you should be able to use your scanner as root. :)

Personal tools
Namespaces
Variants
Actions