Page 1 of 1

udev wrong group

Posted: Fri Dec 27, 2013 8:06 pm
by Lieta
Hi.
I've set up this udev rule:

Code: Select all

cat /etc/udev/rules.d/100-usbadapter.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="0001", SYMLINK+="ttyUSBzwave", GROUP="dialout", MODE="0660"
I'd like it to create a link with group set to "dialout", but instead it's a root:

Code: Select all

pi@raspberrypi ~ $ ls -l /dev/ttyUSB*
crw-rw---T 1 root dialout 188, 0 Jan  1  1970 /dev/ttyUSB0
lrwxrwxrwx 1 root root        15 Jan  1  1970 /dev/ttyUSBzwave -> bus/usb/001/004

Re: udev wrong group

Posted: Fri Dec 27, 2013 9:40 pm
by DougieLawson
/dev/ttyUSB0 is a character device so it's owned by root and in group dialout
/dev/USBzwave is a symbolic link to bus/usb/001/004 so will always be owned by root.root (that's how all symlinks work)

What's the ownership and permission bits for the target of the symlink bus/usb/001/004?

Can a user who's in group dialout open and read/write your /dev/USBzwave device?

Re: udev wrong group

Posted: Sun Dec 29, 2013 7:10 am
by Lieta
DougieLawson wrote:What's the ownership and permission bits for the target of the symlink bus/usb/001/004?

Code: Select all

pi@raspberrypi ~ $ ls -l /dev/bus/usb/001/004
crw-rw---T 1 root dialout 189, 3 Jan  1  1970 /dev/bus/usb/001/004
DougieLawson wrote:Can a user who's in group dialout open and read/write your /dev/USBzwave device?
No. That's the problem.

Re: udev wrong group

Posted: Sun Dec 29, 2013 10:46 am
by DougieLawson
Can you change your application to try to open /dev/bus/usb/001/004? (This is just a temporary experiment, not a permanent fix because the device abstraction layer is there to give movable things fixed names.)

Re: udev wrong group

Posted: Sun Dec 29, 2013 11:38 am
by Lieta
DougieLawson wrote:Can you change your application to try to open /dev/bus/usb/001/004? (This is just a temporary experiment, not a permanent fix because the device abstraction layer is there to give movable things fixed names.)
Doesn't work. It prints: "ERROR: interface FAILED to connect to Port /dev/bus/usb/001/004 (retrying)"

Re: udev wrong group

Posted: Sun Dec 29, 2013 1:29 pm
by DougieLawson
So it's not a user permissions thing. It's a device driver / non-functional device problem.

Re: udev wrong group

Posted: Sun Dec 29, 2013 6:20 pm
by nroff-man
Hi

This is what I use for a cp2102 device, adjust for your own adapter and
post your solution if it works for you.

Code: Select all

KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", GROUP="dialout", MODE="0660", RUN+="/bin/ln -sf %k /dev/cygnal"
good luck.

Re: udev wrong group

Posted: Wed Jan 01, 2014 8:42 pm
by Lieta
DougieLawson wrote:So it's not a user permissions thing. It's a device driver / non-functional device problem.
But it works with "/dev/ttyUSB0".

Re: udev wrong group

Posted: Wed Jan 01, 2014 8:43 pm
by Lieta
nroff-man wrote:Hi

This is what I use for a cp2102 device, adjust for your own adapter and
post your solution if it works for you.

Code: Select all

KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", GROUP="dialout", MODE="0660", RUN+="/bin/ln -sf %k /dev/cygnal"
good luck.
Doesn't work. Owner and group is still "root":

Code: Select all

pi@raspberrypi ~ $ ls -l /dev/ttyUSB*
crw-rw---T 1 root dialout 188, 0 Jan  1  1970 /dev/ttyUSB0
lrwxrwxrwx 1 root root         7 Jan  1  1970 /dev/ttyUSBzwave -> ttyUSB0

Re: udev wrong group

Posted: Wed Jan 01, 2014 9:05 pm
by rpdom
The owner and group of a symbolic link will often be root. It doesn't matter. It has read/write/execute permissions for everyone. It's only purpose is to be a link/shortcut to the real file and it is the permissions on the that file that matter.

Re: udev wrong group

Posted: Thu Jan 02, 2014 8:24 am
by Lieta
rpdom wrote:The owner and group of a symbolic link will often be root. It doesn't matter. It has read/write/execute permissions for everyone. It's only purpose is to be a link/shortcut to the real file and it is the permissions on the that file that matter.
Ok, I'll try, but then it doesn't make sense to specify GROUP="dialout" in the rule.

Re: udev wrong group

Posted: Thu Jan 02, 2014 5:47 pm
by Lieta
udev rule proposed by nroff-man works. Rule

Code: Select all

KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="0001", GROUP="dialout", MODE="0660", RUN+="/bin/ln -sf %k /dev/ttyUSBzwave"
creates

Code: Select all

lrwxrwxrwx 1 root root         7 Jan  1  1970 /dev/ttyUSBzwave -> ttyUSB0
and "/dev/ttyUSBzwave" is accessible by application. The initial rule didn't work, because group of "/dev/bus/usb/001/004" was "root":

Code: Select all

crw-rw-r-T 1 root root 189, 3 Jan  1  1970 /dev/bus/usb/001/004

Re: udev wrong group

Posted: Thu Jan 02, 2014 6:03 pm
by jojopi
/dev/bus/usb/xxx/yyy is a different and lower-level interface than /dev/ttyUSBx. You need the provide the correct type of device for the application you are using.

You should not normally need to create your own udev rules or symlinks. If you want a persistent device name for a ttyUSBx, which does not change based on detection order, there should already be such a symlink under /dev/serial/by-id/.

Re: udev wrong group

Posted: Thu Jan 02, 2014 7:26 pm
by Lieta
jojopi wrote:/dev/bus/usb/xxx/yyy is a different and lower-level interface than /dev/ttyUSBx. You need the provide the correct type of device for the application you are using.

You should not normally need to create your own udev rules or symlinks. If you want a persistent device name for a ttyUSBx, which does not change based on detection order, there should already be such a symlink under /dev/serial/by-id/.
You are right, there is and it works.

Code: Select all

lrwxrwxrwx 1 root root 13 Jan  1  1970 usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 -> ../../ttyUSB0