[SOLVED] Using udev to allow access to USB HID device??

Issues related to hardware problems

[SOLVED] Using udev to allow access to USB HID device??

Postby baldy672 » 2011/06/02 18:45:01

I have a customer using my open source solution for a custom HID device. It identifies as a HID device but it's not a mouse or anything recognizable so the OS will just leave it alone. The code uses libusb to walk through the /proc/bus/usb tree to locate the device. When it finds it, it opens up the device and then speaks the HID-specific commands to it. If you're logged in as root it works great.

Customers started asking if it could be run when logged in as non-root users. You can't because the device is owned by root and set to 600 access instead of the 666 you'd want for general 'anyone' access. I fixed that on Debian by using a udev rule: SUBSYSTEMS=="usb", SYSFS{idVendor}=="041f", MODE:="0666"

Any device from that USB vendor ID gets correctly set to R/W and the solution works fine for non-admin access. A customer running CentOS 4.6 with udev 039 tried the fix and it didn't work. Lots of things changed in the world between this version and my current Debian stuff. What I've tried so far is this: BUS="usb", SYSFS{idVendor}="1234", NAME="foo%n", MODE:="0666" (using the real VID and name, of course)

I can see that the device is located, the rule is executed and the new device '/dev/foo0' does correctly end up with the access 666 that I want. The problem is that libusb is going to walk the /proc/bus/usb tree for something like /proc/bus/usb/002/022 and expect to find the 666 access. I've seen it work on Debian and customers on other OSs (don't know exactly which ones) say it also works. I have CentOS 4.6 as described and I see it doesn't.

Any solutions to this without upgrading? We can suggest that the user upgrade the OS but if there's a fix for it, I'd love to offer the fix. I was hoping to use the 'RUN=' key option that current udevs have, but that doesn't seem to exist.

Thanks,

Howard
baldy672
 
Posts: 5
Joined: 2011/06/02 18:19:47

Re: Using udev to allow access to USB HID device??

Postby baldy672 » 2011/06/02 23:42:18

If it helps, I later installed a clean 5.6 install on the same machine and the rules worked perfectly, allowing the application solution to run in non-root mode.

was the udev system substantiallybfixed in the upgrade from Centos 4 to Centos 5?
baldy672
 
Posts: 5
Joined: 2011/06/02 18:19:47

[SOLVED] Using udev to allow access to USB HID device??

Postby pschaff » 2011/06/06 15:07:16

Welcome to the CentOS fora. Reading FAQ & Readme First is recommended for new users.

baldy672 wrote:
... customer running CentOS 4.6 with udev 039 tried the fix and it didn't work. ...

That release is severely obsolete and unsupported. The current 4.x release is 4.9 which incorporates several updates to udev as well as many other security and bug-fix patches.

If it helps, I later installed a clean 5.6 install on the same machine and the rules worked perfectly, allowing the application solution to run in non-root mode.

was the udev system substantiallybfixed in the upgrade from Centos 4 to Centos 5?

Yes. CentOS 4.9 updates has udev-039-10.30.el4 while the current CentOS 5.6 version is udev-095-14.24.el5.
pschaff
Retired Moderator
 
Posts: 18277
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America

Re: Using udev to allow access to USB HID device??

Postby baldy672 » 2011/06/07 10:36:09

Thanks for the confirmation, Phil. I know about both 4.9 and 5.6. The customer has an installed base of 4.6 machines and doesn't want to update them, so I have to come up with a workaround for the problem. I do have a couple of ideas to try.

Cam the newer udev be easily applied to 4.6 without screaming 'upgrade'? maybe they'll go for that - they don't want to go to 4.9.

thanks,

Howard
baldy672
 
Posts: 5
Joined: 2011/06/02 18:19:47

Re: Using udev to allow access to USB HID device??

Postby pschaff » 2011/06/07 11:06:50

If they (foolishly IMHO) don't want to update to 4.9, or install 5.6, then patching in a later udev would be out of the question, and unlikely to work in any case. You seem to have been handed an over-constrained problem that may not have a viable solution within those parameters.

Perhaps they would consider installing 5.6 and virtualizing the old insecure OS via Xen, KVM, VirtualBox, VMware, etc. That would also provide better security, backups/restores via snapshots of the VMs, and possibly cost savings. No idea how your custom HID might fit into that scenario.
pschaff
Retired Moderator
 
Posts: 18277
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America

Re: Using udev to allow access to USB HID device??

Postby baldy672 » 2011/06/07 21:35:44

Phil, I don't know the full reason why they can't or won't upgrade. There's an installed base issue and perhaps they don't want to take on upgrading a fair number of machines. Customers can sometimes just decide that whoever comes last to the party has to accommodate everyone else - and there are other data acquisition applications that have to run on the same machines. Perhaps thos apps won't run with an upgrade.

Your word that this can't be fixed without going to either 4.9 or 5.6 is good enough for me. I'll talk with them and we'll figure something out.

Thanks again,

Howard
baldy672
 
Posts: 5
Joined: 2011/06/02 18:19:47

Re: Using udev to allow access to USB HID device??

Postby pschaff » 2011/06/08 17:58:16

In your discussions you may want to consider a couple of additional points.

1. There is no evidence that updating to 4.9 will help, unless you have tested that.
2. CentOS 4 is near EOL, with CentOS-4 updates until Feb 29, 2012.
pschaff
Retired Moderator
 
Posts: 18277
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America

Re: Using udev to allow access to USB HID device??

Postby baldy672 » 2011/07/03 23:14:04

Phil-

The final end user in the chain is going to do what they want, regardless of whether the OS is obsolete or not. I will make it a point of making sure they know there's less than a year before the OS is fully abandoned.

In the meantime, I am tasked with making sure that my code runs on what they have. I started down a road of trying to access the USB devices without libusb and by going directly to the device through the /dev/hiddevN path. The udev rules are able to set the access on the device node it creates. Of course, once you open the first can of worms you find several more inside - hardly worth all the effort. i gave up on that and looked at the hotplug mechanism instead.

The fix turned out to be pretty easy. I'm posting it here to complete the thread (I like seeing threads that include the final fix).

That version of hotplug used the 'usb.usermap' file to connect specific devices by VID and PID to a script. I added a number of device-specific lines to that file, each of which refers to the 'mydevice' script, and then wrote a quick 'mydevice' script to put in the /etc/hotplug/usb directory.

It works just swell. That was a much easier fix than the convoluted workaround I started trying and yes, it's all a throwaway when the user finally upgrades to a modern version of Linux. But users are always right, aren't they?? :-)

Howard
baldy672
 
Posts: 5
Joined: 2011/06/02 18:19:47

Re: [SOLVED] Using udev to allow access to USB HID device??

Postby pschaff » 2011/07/04 16:51:44

baldy672 wrote:
....
The fix turned out to be pretty easy. I'm posting it here to complete the thread (I like seeing threads that include the final fix)...

Me too! Thanks for reporting back. Marking this thread [SOLVED] for posterity on your behalf.
pschaff
Retired Moderator
 
Posts: 18277
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America


Return to CentOS 4 - Hardware Support

Who is online

Users browsing this forum: No registered users and 0 guests