Linux – udev: how can I extend a default rule to modify the ownership of a symlink

linuxudev

I need to get some USB-serial devices into a particular user group to access them from an application. This is straightforward for the /dev/ttyUSB devices, where I can just use KERNEL="ttyUSB*", GROUP:="mygroup". However, for the symlinks like /dev/bus/usb/001/001, it is not obvious how to accomplish the same thing of setting their group to mygroup. I can do it by editing the default rules file /etc/udev/rules.d/50-udev.rules and adding a GROUP="mygroup" clause to the line for usb_device which creates the symlinks in /dev/bus/usb, however editing this file is clearly suboptimal from a packaging point of view.

So: how can I write a udev rule to modify the ownership of a symlink created by an earlier, default udev rule?

(I'm working on CentOS 5.5.)

Best Answer

Answered my own question: apparently it's all about using := instead of =.

SUBSYSTEM=="usb_device", MODE:="0664", GROUP:="mygroup"

This goes in a 10-usb-devices.rules file in /etc/udev/rules.d. The ":=" gets it to override the permissions of the nodes that the other rule creates -- I had initially incorrectly thought it was creating symlinks when in fact it was creating actual nodes in /dev/bus.