Skip to content
Advertisement

Linux udev rule does not appear to work

I am writing an application that MUST run on Fedora Core 4. The application needs to access a USB device WITHOUT root privileges. Using libusb-1.0.8 I have successfully written the application except for one problem. If I do not have root privileges, libusb_open fails with -3 “Permission Denied”.

I’ve read that I can alter the permissions of the device with a udev rule. And so I added 10-local.rules to /etc/udev/rules.d with the following line:

BUS=="usb", SYSFS{idVendor}=="040a", SYSFS{idProduct}=="4e00", MODE="0666"

I copied the above information from the output of udevinfo.

Even with the above rule, the device permissions always end up “0644” and I cannot open the USB device from a user application. Even after rebooting.

Does anyone have any suggestions as to what I may be doing wrong? Does Fedora Core 4 support what I am trying to do? Thanks

Advertisement

Answer

Modifiying permissions for USB devices seems to be handled at least 3 different ways depending on the version of Linux (HAL, udev, hotplug, etc.). After several unsuccessful attempts I finally came across a site with accurate information.

For Linux 2.6.11 at least, the answer is hotplug. The solution is to create a custom usermap file in /etc/hotplug/usb. Use the built-in usermap (/etc/hotplug/usb.usermap) as an example. The usermap file specifies a script to execute when a matching device is connected. The script should also be located in /etc/hotplug/usb.

For example, I created /etc/hotplug/usb/myusbdvc.usermap with the VID and PID of my device and a script to execute named chmodmyusbdvc.

I also created /etc/hotplug/usb/chmodmyusbdvc with the follow contents:

#!/bin/bash
if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
  echo "changing ${DEVICE}" >> /tmp/debug-hotplug
  chmod 666 "${DEVICE}"
fi
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement