2

Is there a group to which a user can be added, that gives permission to write to the LED subsystem of Linux (/sys/class/leds/)?

If not, is it possible to create such a group?

I do not want to run my application as sudo.

Edit: I only want to change permission of a few devices for which I really needed the write permission and not for the whole leds subsystem. I have posted a solution that works for me.

3
  • Thank you, but that is what I am doing. But on my distribution, access to these files is limited to root.
    – p0kR
    Jan 29, 2019 at 23:05
  • I have a new idea how to solve my problem and will post the answer when it works like I hope.
    – p0kR
    Jan 29, 2019 at 23:10

1 Answer 1

0

I found a solution fitting my problem. I added a udev rule like it is described in this answer to a similar question.

First I had to create a new group called leds. Then I created the udev rule in /etc/udev/rules.d/10-buzzers.rules (I created the file by myself, it did not exist before).

Since I wanted to only use the Buzzer LEDs of the Buzzer controllers for the Playstation 2, I optimized the rule to only affect the files for the controllers. The rule only applies to devices that match the kernel information in the field KERNEL.

The rule executes chgrp and chmod that the matching device files are owned by the leds group and that the owning group has write permission.

My final rule:

SUBSYSTEM=="leds", KERNEL=="0003:054C:1000.[0-9]*::buzz[1-4]", ACTION=="add", RUN+="/bin/chgrp -R leds /sys%p", RUN+="/bin/chmod -R g=u /sys%p"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .