[Nut-upsdev] newhidups subdriver_matcher incorrectly matches USB hub

Peter Selinger selinger at mathstat.dal.ca
Wed Aug 16 01:27:39 UTC 2006


Schmier, Jacob wrote:
> 
> > > :/tmp# /tmp/newhidups -DDD /dev/usb/hid/hiddev0
> 
> > (Note that you do not need to specify the /dev node for newhidups.)
> 
> According to the usage info, the /dev node is only optional when
> using -a.  Although running the following works just fine:
> :/tmp# /tmp/newhidups -u nut /etc/passwd
> 
> Having to provide SOMETHING in the device option even though newhidups
> is going to scan the usb bus for a device anyway seems a bit ridiculous
> to me, but that is another issue ;)

The reason for this is that all the NUT drivers use the same common
command line interface, and only newhidups ignores this value! Since
you should normally use upsdrvctl to start the driver, it is in fact
necessary that all drivers share the same command line format. 
 
> > One way to avoid this is to run the driver as an unprivileged user,
> > and set up udev/hotplug to only give NUT read/write access to the UPS.
> 
> > IIRC, most distributions use mode 0644 on /proc/bus/usb/* nodes by
> > default, so creating a 'nut' user and running 'chown nut ...' in the
> > hotplug script would do the trick. See scripts/hotplug or
> > scripts/hotplug-ng (udev) for more information.
> 
> > --
> > - Charles Lepple
> 
> Thanks for the suggestion.  It definitely does the trick.  However,
> this is really just a work around to the underlying problem.  The hub
> is still matched, it just cannot be claimed due to permissions.  The
> hub really shouldn't be matched at all.
> 
> I could just as easily change belkin_claim in drivers/belkin-hid.c so
> that it never reports a match since I don't use a Belkin UPS.

You are right that it is not a good idea to just match any Belkin
device. The reason was that I had never seen, to this day, any other
Belkin device. Of course having a Belkin hub is particularly bad in
this circumstance. 

Unfortunately, I don't have a list of which of their devices are
UPS's. I don't even know if all of their USB UPS's use the same device
number. So it seemed reasonable at the time to match all of them. 

However, I have now changed this in SVN so that only device 0980 is
matched as a UPS. This may mean that some similar devices might not
seem "supported" in the future, until some user tells us about the
device. I have not yet made the corresponding change for MGE, again
because they have many devices and I don't have a list of them (what
are they? I know about ffff and 0001). 

By the way, in your particular situation, there was an existing
solution, and it is documented on the newhidups(8) man page: you could
have simply specified "-x vendorid=0463" on the command line, to
select the particular device to connect to. (This can also be put into
ups.conf). If you need to be more specific, there is also "-x
productid" and "-x serial". 

-- Peter





More information about the Nut-upsdev mailing list