[sane-devel] [RFC] Hotplug proposal -- migrating to hotplug hooks (hotplug &
hotplug-ng compatible)
Julien BLACHE
jb@jblache.org
Tue, 15 Feb 2005 19:47:09 +0100
Hi,
With hotplug-ng dropping support for the way we're using it as of now,
there's a need to revamp the hotplug stuff we use.
First of all, recent versions of hotplug also support hooks, so the
proposed solution would be backward-compatible to a certain degree.
The idea basically is to build a simple database (simpler than the
usermap file) of the supported scanners, and, while doing so, adding
some features to the hotplug stuff.
Database layout:
----------------
The database would be installed under $sysconfdir/sane.d/hotplug.
The idea is to have one file per USB vendor ID; this file would
contain one line (plus comments) per known scanner product ID.
Now, we have the possibility to add some nice features, by adding
fields to this file, like:
# PID Ownership Perms [Optional: user-defined script]
0xPPPP root:scanner 0660 [/usr/local/bin/scanner-foo.sh]
This would solve complaint #1: as of now, it's not possible to have
different scanners owned by different users (where different means
different PID and/or VID, because we can't do much more...)
Hotplug script:
---------------
The hook gets the device number (DEVNUM) and bus number (BUSNUM) from
the environment.
It's now easy to get the DEVVID and DEVPID for the device, then look
for $sysconfdir/sane.d/hotplug/$DEVVID, and, if it exists, to grep for
^$DEVPID, then apply the corresponding ownership and permissions, and
run the user-specified script if it exists.
User script:
-----------
The user script would be called with DEVNUM, BUSNUM, DEVVID and DEVPID
in the environment.
I'm going to play with this next week, and this will probably make it
into the next revision of the Debian package, and to the CVS :)
This is, I believe, more secure and more flexible than the hotplug
hook posted earlier.
JB.
--
Julien BLACHE <http://www.jblache.org>
<jb@jblache.org> GPG KeyID 0xF5D65169