tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Set USB device ownership based on vedorid/productid



> Does NetBSD provide any framework that allows USB device
> ownership/permissions to be autmatically set on USB
> VendorId/DeviceId?

As far as I know it doesn't; a quick look at 8.0's manpages didn't show
me anything.  (9.1 is not easy for me to check right now; today I'm on
the wrong job for that.)

Back in the day, I added a pseudo-device that gave userland the ability
to watch the autoconf device tree.  I did this for 4.0.1 and,
apparently, never ported it to either of the other versions I run, so I
obviously didn't use it much.  But it looks as though it could be used
as part of such a thing, and, as I say, the 8.0 manpages didn't show me
anything obviously related on a cursory check, though I hardly did a
thorough search.

> E.g., if a USB device with VendorId/ProductId 06da/0002 appears and
> becomes ugen0, do chown nut:nut /dev/ugen0.*; chmod 0660 /dev/ugen0.*

My code couldn't do that directly.  What it could do is let userland
discover when ugen<N> appears or disappears.  It would then require
additional code to fetch ugen<N>'s vendor and product IDs, check them
against some kind of configuration and, when appropriate, do the chown
and chmod.  It does occur to me that anything of the sort is likely to
be highly racy (racing ugen0 disappearing and re-appearing versus
userland issuing the chmod/chown); depending on your intended use case,
of course, this may or may not matter in practice.

Anyone who cares to is welcome to use my code as the basis for
something of the sort in a more modern system.  It's commits ba0f281
(most of it) and fec28fd (one bugfix) in my 4.0.1 src git tree
(git://git.rodents-montreal.org/Mouse/netbsd-fork/4.0.1/src).  I can
also mail out copies and/or put them up for anonymous FTP.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index