Difference between revisions of "Making udev rule to set usb device permissions"
Line 18: | Line 18: | ||
Bummer. | Bummer. | ||
+ | |||
+ | ===udevadm query=== | ||
+ | OK, getting a little more serious about understanding udev, I am starting with this document: | ||
+ | http://reactivated.net/writing_udev_rules.html | ||
+ | |||
+ | And I also learn that the udevinfo command doesn't exist in Ubuntu, but there does exist a udevadm command and it works like this: | ||
+ | <pre> | ||
+ | root@weasel:/sys/dev/char# udevadm info -q all -n /dev/ldusb0 | ||
+ | P: /devices/pci0000:00/0000:00:02.0/usb2/2-8/2-8:1.0/usb/ldusb0 | ||
+ | N: ldusb0 | ||
+ | S: char/180:176 | ||
+ | E: UDEV_LOG=3 | ||
+ | E: DEVPATH=/devices/pci0000:00/0000:00:02.0/usb2/2-8/2-8:1.0/usb/ldusb0 | ||
+ | E: SUBSYSTEM=usb | ||
+ | E: DEVNAME=/dev/ldusb0 | ||
+ | E: MAJOR=180 | ||
+ | E: MINOR=176 | ||
+ | E: DEVLINKS=/dev/char/180:176 | ||
+ | </pre> |
Revision as of 00:25, 22 December 2010
I have a USB temperature probe that defaults to 600 permission and ownership by root. I'd like everyone (especially my non-root script) to be able to read this device, so I set it to 644 permission. But something keeps switching the permission back. I assume this something is udev. To make my permission setting stick, I told udev to honor it by creating this file:
root@weasel:/etc/udev/rules.d# pwd;ls /etc/udev/rules.d 45-libmtp7.rules 70-persistent-net.rules README 70-persistent-cd.rules 99-vernier.rules root@weasel:/etc/udev/rules.d# cat 99-vernier.rules # Vernier EasyTemp/Go!Temp ATTR{idVendor}=="08f7", ATTR{idProduct}=="0002", MODE="644"
I guessed at the syntax by peeking at the other rules files in this directory.
My previous attempt at a fix for this was to add a "chmod" to /etc/rc.local, but udev is smarter than that, since it changes the permission of my usb device at times other than reboot. We'll see if this udev rule is sufficient. If not, I'll have to start reading more about udev.
I disabled the /etc/rc.local script and rebooted... immediately after booting, the permissions on /dev/ldusb0 were 600 again.
Bummer.
udevadm query
OK, getting a little more serious about understanding udev, I am starting with this document: http://reactivated.net/writing_udev_rules.html
And I also learn that the udevinfo command doesn't exist in Ubuntu, but there does exist a udevadm command and it works like this:
root@weasel:/sys/dev/char# udevadm info -q all -n /dev/ldusb0 P: /devices/pci0000:00/0000:00:02.0/usb2/2-8/2-8:1.0/usb/ldusb0 N: ldusb0 S: char/180:176 E: UDEV_LOG=3 E: DEVPATH=/devices/pci0000:00/0000:00:02.0/usb2/2-8/2-8:1.0/usb/ldusb0 E: SUBSYSTEM=usb E: DEVNAME=/dev/ldusb0 E: MAJOR=180 E: MINOR=176 E: DEVLINKS=/dev/char/180:176