← Back to team overview

sslug-teknik team mailing list archive

Re: udev pg libusb problem

 

On Sat, 21 Aug 2004 09:46:57 +0200, Anders Gnistrup wrote:

> 
> Er det nogen der har en god løsning til hotpluggeble enheder under libusb
> som kommer og går som de har lyst til?
> 
Se man hotplug.

Et eksempel er /etc/hotplug/usb/libusbscanner fra sane-backends:

#!/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=`echo $DEVPATH | sed 's/\(bus\/usb\/devices\/\)\(.*\)-\(.*\)/\3/'`
  DEV=`expr $DEV + 1`
  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

-- 
Hilsen/Regards
Michael Rasmussen

Get my public GnuPG keys:
mir <at> datanom <dot> net
http://search.keyserver.net:11371/pks/lookup?op=get&search=0xE501F51C
mir <at> miras <dot> org
http://search.keyserver.net:11371/pks/lookup?op=get&search=0xE3E80917
--------------------------------------------------------------
Q:	How does a hacker fix a function which
	doesn't work for all of the elements in its domain?
A:	He changes the domain.




References