Lieta
Posts: 8
Joined: Sat Mar 16, 2013 4:10 pm

udev wrong group

Fri Dec 27, 2013 8:06 pm

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

User avatar
DougieLawson
Posts: 39858
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: udev wrong group

Fri Dec 27, 2013 9:40 pm

/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?
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Lieta
Posts: 8
Joined: Sat Mar 16, 2013 4:10 pm

Re: udev wrong group

Sun Dec 29, 2013 7:10 am

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.

User avatar
DougieLawson
Posts: 39858
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: udev wrong group

Sun Dec 29, 2013 10:46 am

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.)
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Lieta
Posts: 8
Joined: Sat Mar 16, 2013 4:10 pm

Re: udev wrong group

Sun Dec 29, 2013 11:38 am

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)"

User avatar
DougieLawson
Posts: 39858
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: udev wrong group

Sun Dec 29, 2013 1:29 pm

So it's not a user permissions thing. It's a device driver / non-functional device problem.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

User avatar
nroff-man
Posts: 23
Joined: Mon Jul 30, 2012 7:31 pm
Location: /usr/bin

Re: udev wrong group

Sun Dec 29, 2013 6:20 pm

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.

Lieta
Posts: 8
Joined: Sat Mar 16, 2013 4:10 pm

Re: udev wrong group

Wed Jan 01, 2014 8:42 pm

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".

Lieta
Posts: 8
Joined: Sat Mar 16, 2013 4:10 pm

Re: udev wrong group

Wed Jan 01, 2014 8:43 pm

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

User avatar
rpdom
Posts: 17572
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: udev wrong group

Wed Jan 01, 2014 9:05 pm

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.

Lieta
Posts: 8
Joined: Sat Mar 16, 2013 4:10 pm

Re: udev wrong group

Thu Jan 02, 2014 8:24 am

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.

Lieta
Posts: 8
Joined: Sat Mar 16, 2013 4:10 pm

Re: udev wrong group

Thu Jan 02, 2014 5:47 pm

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

User avatar
jojopi
Posts: 3317
Joined: Tue Oct 11, 2011 8:38 pm

Re: udev wrong group

Thu Jan 02, 2014 6:03 pm

/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/.

Lieta
Posts: 8
Joined: Sat Mar 16, 2013 4:10 pm

Re: udev wrong group

Thu Jan 02, 2014 7:26 pm

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

Return to “Raspberry Pi OS”