#[SOLVED] Changing sysfs permissions using udev rules?

63 messages · Page 1 of 1 (latest)

left shore
#

I'm slightly confused what SUBSYSTEM parameter does, is it equivalent of /sys/class/SUBSYSTEM? Or is it something else?
How would I change permissions for something like ideapad_acpi? Which is not even in /sys/class, but instead in /sys/bus/platform/drivers/

terse zephyr
left shore
#

It is not?

terse zephyr
#

It is not, udev is only in charge of /dev.

#

Files under /sys are direct kernel interfaces, created by the kernel and not affected by udev.

left shore
#

What the hell is this then?
/etc/udev/rules.d/99-swayosd.rules

ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
#

SwayOSD already added some rules and they apply to /sys

terse zephyr
#

This is the cause, RUN+= is just the effect.

left shore
#

are backlight devices in /dev? Sounds like nonsense

#

Or... SUBSYSTEM is like a hook?

#

triggers after certain SUBSYSTEM has initialized?

#

Doesn't matter where it got mounted I assume?

terse zephyr
left shore
#

Still confused

terse zephyr
# left shore Still confused

IIRC udev is part of systemd, it is not very clearly documented except in the code, I think you can find some logic from SUBSYSTEM.

left shore
#

udev is also a part of initramfs which is way before pid 0 afaik?

terse zephyr
left shore
#

What?

#

less /etc/mkinitcpio.conf

terse zephyr
#

Its source code is available under systemd/src/udev.

terse zephyr
left shore
#

wdymmmmmm

#

mkinitcpio isn't Arch Linux specific

#

or wait

left shore
#

Ok but then what does hook do

#

Actually, forget it

#

Back to original question

#

How would I change perms for ideapad_acpi

#

which SUBSYSTEM is it?

terse zephyr
#
                if (type == TK_M_SUBSYSTEM && STR_IN_SET(value, "subsystem", "bus", "class"))
                        match_type = MATCH_TYPE_SUBSYSTEM;
terse zephyr
left shore
#

so... it's platform?

left shore
terse zephyr
left shore
#

the one with some kind of id?

terse zephyr
left shore
#

yes

#

I want it to be available to all power group

terse zephyr
left shore
#

In original title I just asked for general udev help, I wasn't sure if I'm on the right track even

terse zephyr
#

What is the device name?

#

It should look like this: VPC2004:00.

terse zephyr
#

Albeit, if you do not want to deal with obscure udev rules, you can always use
/etc/tmpfiles.d, which is a common practice used by systemd itself
e.g.

m /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00 0664 root power - -
left shore
#

(udev-worker)[277]: VPC2004:00: Process '/usr/bin/chgrp power /devices/pci0000:00/0000:00:1f.0/PNP0C09:00/VPC2004:00/conservation_mode' failed with exit code 1

#

works when I run manually

left shore
#

Oh, nevermind

#

It works

left shore
terse zephyr
# left shore It works

Usually, if there is a device event, udev can be used, otherwise use tmpfiles.d or the systemd service.

left shore
#

I figured out from this page

#

that I needed $sys

terse zephyr
left shore
#

Now it works, thank you

#

[SOLVED] Changing sysfs permissions using udev rules?

terse zephyr