[sane-devel] Re: [ANNOUNCE] hotplug-ng 001 release

Alexander E. Patrakov patrakov@ums.usu.ru
Tue, 15 Feb 2005 15:25:39 +0500


--Boundary-00=_j4cECzMuwe5hPBX
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Tuesday 15 February 2005 12:34, Greg KH wrote:
> On Sat, Feb 12, 2005 at 09:27:29PM +0500, Alexander E. Patrakov wrote:
> > Greg KH wrote:
> > > I'd like to announce, yet-another-hotplug based userspace project:
> > > hotplug-ng.  This collection of code replaces the existing linux-hotplug
> > > package with very tiny, compiled executable programs, instead of the
> > > existing bash scripts.
> >
> > The ability to set up userspace handlers for certain devices via
> > *.usermap files (see SANE and gphoto2 for basic "chown and chmod a file
> > in /proc/bus/usb" examples) was lost.
>
> Yes.  That stuff is a mess and I'm glad to get rid of it :)
>
> > Is this functionality planned to be restored in hotplug-ng?
>
> Nope.
>
> > Or is it the responsibility of SANE and gphoto2 maintainers to adapt
> > to this change e.g. by providing additional files for
> > /etc/hotplug.d/usb instead?
>
> Yes, it's easier for programs to add their own hooks into
> /etc/hotplug.d/ directory than for them to modify the usermap files,
> correct?

Indeed. How about including the hook for SANE (attached, place it 
in /etc/hotplug.d/usb/libusbscanner.hotplug) into the next release of 
hotplug-ng as an example? Or, even better, in the next SANE version?

It differs a lot from the current version of the script. Instead of 
duplicating knowledge in several places including the usermap file, this 
script relies on the output from sane-find-scanner.

Sorry for not providing gphoto2 hook. I don't have a digital camera.

-- 
Alexander E. Patrakov

--Boundary-00=_j4cECzMuwe5hPBX
Content-Type: application/x-shellscript;
  name="libusbscanner.hotplug"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
	filename="libusbscanner.hotplug"

#!/bin/sh
# 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.

# The following environment variable is used:
# DEVICE=/proc/bus/usb/BUSNUM/DEVNUM

if [ "$ACTION" = "add" ]
then
	BUSANDDEV=${DEVICE#/proc/bus/usb/}
	BUSNUM=${BUSANDDEV%/*}
	DEVNUM=${BUSANDDEV#*/}
	if sane-find-scanner -q "libusb:$BUSNUM:$DEVNUM" | grep -q "^found"
	then
		chown root:scanner "$DEVICE"
		chmod 0660 "$DEVICE"
		# That's an insecure but simple alternative
		# chmod 0666 "$DEVICE"
	fi
fi

--Boundary-00=_j4cECzMuwe5hPBX--