udev rule group ownership not working

5,034

I'm not sure there is a way to set the user and group for a symlink with udev. I don't see one either. I'm also doubting whether one should be needed.

I signed on to tty6 and as root, created a symbolic link/tmp/tty6 to /dev/tty6. After I did its user and group were both root, but /dev/tty6 was owned by me.

I was able to use

echo hi >/dev/tty6

but also echo hi >/tmp/tty6

The reason is that the necessary permission is carried by the final inode pointed to, not the symbolic link.

If I'm right, there is another reason for the problem you are having, although I guess it could be that the program you are using does, incorrectly, look at the permissions on the symbolic link.

If that's the case, as a circumvention, perhaps you could create your own link and use that instead of one udev sets.

ln -s /dev/arduino ~/arduino

should produce a symbolic link to the target of /dev/arduino but with your user and group.

As a test, as root, you might also change the group yourself on the udev created symbolic link and see if it helps when going through /dev/arduino.

Share:
5,034

Related videos on Youtube

tirithen
Author by

tirithen

System developer with focus on JavaScript (mostly excited about Polymer 3) and Go. Always eager to learn new things.

Updated on September 18, 2022

Comments

  • tirithen
    tirithen over 1 year

    I have added a udev rule for my Arduino, but the symlink gets the ownership "root root" instead of "root dialout".

    $ cat /etc/udev/rules.d/47-Arduino.rules 
    SUBSYSTEM=="usb", ATTR{idVendor}=="2341", ATTR{idProduct}=="0001", MODE="0666", SYMLINK+="arduino", GROUP="dialout"
    
    $ ls -la /dev/ar*
    lrwxrwxrwx 1 root root 15 sep  8 11:02 /dev/arduino -> bus/usb/003/007
    
    $ ls -la /dev/bus/usb/003/007 
    crw-rw-r-- 1 root dialout 189, 262 sep  8 11:12 /dev/bus/usb/003/007
    

    My user is a member of the group "dialout" but I still get permission denied error when I'm trying to communicate with the device.

    There are no problems when I'm using the "default" device "/etc/ttyACM3".

    $ ls -la /dev/ttyACM3 
    crw-rw---- 1 root dialout 166, 3 sep  8 11:12 /dev/ttyACM3
    

    I have tried to restart both the udev service and reboot my computer. How can I fix this?

  • tirithen
    tirithen over 11 years
    Thanks for the input, the whole point with udev is to solve that the usb devices get different names different times they are connected so I cannot have a script creating those symlinks which was what I needed. I'll try to check as you said if the programs looks on the symlink ownerships and gives up without trying. Maybe I could some how have a chown script hooked up to run when the device is connected. I thinking though that this would be a common problem and should have a simpler solution... Thanks for the input anyway.
  • John S Gruber
    John S Gruber over 11 years
    I understood what you were looking for. That's why I suggested ln -s /dev/arduino ~/arduino. The link produced, ~/arduino, should have your ownership and point to the ultimate /dev/bus/usb/x/y udev made /dev/arduino point to. As you said, perhaps a udev initiated script could run this command, and it could certainly go somewhere other than in your home directory.
  • tirithen
    tirithen over 11 years
    Ah now I understand what you mean :) thanks, I'll try that.