[clue-tech] Hotplug scripts and usermaps
Matt Gushee
mgushee at havenrock.com
Fri Mar 18 16:45:18 MST 2005
I seem to have a USB hotplugging problem.
The other day I bought a new Palm Pilot (3 or 4 years behind the times,
as usual ;-), and I am trying to hot-sync it over a USB connection (I
don't have a cradle, just a USB cable running directly from the Palm to
the PC). On the PC side, I'm using pilot-link with the JPilot GUI, and I
have kernel 2.6.10.
The basic issue I'm running into is permissions on the USB connection.
If I run JPilot as root, there's no problem, but of course I don't want
to do that. Or I can log in as root and set the permissions. But the
trouble with that is that the device representing USB connection is
temporary. In fact, it only comes into existence when I press the
hot-sync button on the Palm Pilot. So when I want hot-sync as a regular
user I have to be logged in as root on some console; I run JPilot, press
the hot-sync button, switch to my root console, set the permissions on
the device, then switch back to JPilot and do what I need to do ... it's
completely bogus.
Apparently the right way to do this is with hotplug, and I have
attempted to set this up but it's not working. Apparently a usermap and
a device-specific script are required, so I copied and modified the ones
that are installed for libsane, which enable the hotplug manager to
correctly detect my USB scanner. So in /etc/hotplug/usb I have:
pilot.usermap
-------------
# usb module match_flags idVendor idProduct bcdDevice_lo \
bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol \
bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info
visor 0x0003 0x0830 0x0060 0x0000 0x0000 0x00 0x00 0x00
0x00 0x00 0x00 0x00000000
pilot
-----
#!/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:staff "$DEVICE"
chmod 0660 "$DEVICE"
chown root:staff /dev/usb/tts/1
chmod 0660 /dev/usb/tts/1
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
This could be completely wrong: the only thing I'm sure of the the
vendor and product IDs that I put in the usermap. I've checked the
linux-hotplug project on SourceForge, manual pages, and other places,
and there's very little documentation on how to do this stuff. At any
rate, the permissions don't get set automatically.
I've also checked for log messages. There is a /var/log/hotplug
directory, but it's empty. The only thing I've found that could be
relevant is this message, which appears many times in /var/log/errors:
Mar 18 16:18:57 $MY_HOSTNAME hal.hotplug[5011]: DEVPATH is not set
Anybody have a clue how I can fix this?
--
Matt Gushee
Englewood, CO, USA
More information about the clue-tech
mailing list