You are not logged in.

#1 2024-01-21 14:35:53

VesperLlama
Member
Registered: 2024-01-21
Posts: 6

[Solved] udev rule for uaccess not working

Hello,

I am using this driver compiled from source. It creates some files in '/sys/devices/platform/msi-ec/' and at ' /sys/class/power_supply/BAT1/' which I would like to edit without using root.
I tried following the steps to Allow regular users to use devices in the wiki, but it doesn't work after doing 'sudo udevadm control --reload && sudo udevadm trigger' or even after restarting the system. I still require the root password to edit the files.

I have created a file '70-msi-ec.rules' in /etc/udev/rules.d with the following content -

KERNEL=="msi-ec", SUBSYSTEM=="platform", DRIVER=="msi-ec", MODE="0660", TAG+="uaccess"

I have also created a file 50-bat.rules in the same folder with the following content -

KERNEL=="BAT1", SUBSYSTEM=="power_supply", MODE="0660", TAG+="uaccess"

Here the output of udevadm info for 'udevadm info --attribute-walk --path=/sys/devices/platform/msi-ec/'

looking at device '/devices/platform/msi-ec':
    KERNEL=="msi-ec"
    SUBSYSTEM=="platform"
    DRIVER=="msi-ec"
    ATTR{battery_mode}=="min"
    ATTR{cooler_boost}=="off"
    ATTR{cpu/realtime_fan_speed}=="43"
    ATTR{cpu/realtime_temperature}=="23"
    ATTR{driver_override}=="(null)"
    ATTR{fan_mode}=="auto"
    ATTR{fn_key}=="left"
    ATTR{fw_release_date}=="2021/07/16 11:01:58"
    ATTR{fw_version}=="158LEMS1.103"
    ATTR{gpu/realtime_fan_speed}=="128"
    ATTR{gpu/realtime_temperature}=="128"
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_time}=="0"
    ATTR{power/runtime_status}=="unsupported"
    ATTR{power/runtime_suspended_time}=="0"
    ATTR{shift_mode}=="comfort"
    ATTR{webcam}=="off"
    ATTR{webcam_block}=="off"
    ATTR{win_key}=="right"

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

Both of these rules do not work.

Here's the output of 'sudo udevadm test /sys/devices/platform/msi-ec/'

Trying to open "/etc/systemd/hwdb/hwdb.bin"...
Trying to open "/etc/udev/hwdb.bin"...
Trying to open "/usr/lib/systemd/hwdb/hwdb.bin"...
Trying to open "/usr/lib/udev/hwdb.bin"...
=== trie on-disk ===
tool version:          255
file size:        12550741 bytes
header size             80 bytes
strings            2586293 bytes
nodes              9964368 bytes
Loading kernel module index.
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Found container virtualization none.
Using default interface naming scheme 'v255'.
Parsed configuration file "/usr/lib/systemd/network/99-default.link"
Created link configuration context
...
Reading rules file: /etc/udev/rules.d/50-bat.rules
...
Reading rules file: /etc/udev/rules.d/70-msi-ec.rules
...
Reading rules file: /usr/lib/udev/rules.d/70-uaccess.rules
Reading rules file: /usr/lib/udev/rules.d/71-seat.rules
Reading rules file: /usr/lib/udev/rules.d/73-seat-late.rules
...
msi-ec: /usr/lib/udev/rules.d/50-udev-default.rules:18 Importing properties from results of builtin command 'hwdb --subsystem=platform'
msi-ec: hwdb modalias key: "platform:msi-ec"
msi-ec: No entry found from hwdb.
msi-ec: /usr/lib/udev/rules.d/50-udev-default.rules:18 Failed to run builtin 'hwdb --subsystem=platform': No data available
msi-ec: /usr/lib/udev/rules.d/50-udev-default.rules:27 Importing properties from results of builtin command 'path_id'
msi-ec: /etc/udev/rules.d/70-msi-ec.rules:1 MODE 0660
msi-ec: /usr/lib/udev/rules.d/80-drivers.rules:5 RUN 'kmod load'
msi-ec: sd-device: Created db file '/run/udev/data/+platform:msi-ec' for '/devices/platform/msi-ec'
DEVPATH=/devices/platform/msi-ec
DRIVER=msi-ec
MODALIAS=platform:msi-ec
ACTION=add
SUBSYSTEM=platform
TAGS=:uaccess:seat:
ID_PATH=platform-msi-ec
ID_PATH_TAG=platform-msi-ec
CURRENT_TAGS=:uaccess:seat:
ID_FOR_SEAT=platform-platform-msi-ec
USEC_INITIALIZED=7660911
run: 'kmod load'
Unload kernel module index.
Unloaded link configuration context.

The uaccess tag is applied in the test. I have also tried using GROUP and OWNER options but they also didn't work. I have also tried adding ATTR{fw_version}=="158LEMS1.103" it also didn't work.
Using 'sudo udevadm control --log-priority=debug' I don't see any errors except 'Failed to run builtin 'hwdb --subsystem=___' in many rules but not these ones.

Systemd version - 255.2-3
Kernel - 6.7.0-arch3-1

What can be the issue?

Thanks for the help!

Last edited by VesperLlama (2024-01-22 21:31:34)

Offline

#2 2024-01-21 15:31:07

seth
Member
Registered: 2012-09-03
Posts: 51,553

Re: [Solved] udev rule for uaccess not working

Looks like your adressing the path but not the devices?

getfacl /sys/devices/platform/msi-ec
getfacl /sys/devices/platform/msi-ec/webcam

Offline

#3 2024-01-21 15:50:38

VesperLlama
Member
Registered: 2024-01-21
Posts: 6

Re: [Solved] udev rule for uaccess not working

seth wrote:

Looks like your adressing the path but not the devices?

Can you explain this? I don't understand what you mean.

Here's the output of 'getfacl /sys/devices/platform/msi-ec' -

getfacl: Removing leading '/' from absolute path names
# file: sys/devices/platform/msi-ec
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

Here's the output of 'getfacl /sys/devices/platform/msi-ec/webcam' -

getfacl: Removing leading '/' from absolute path names
# file: sys/devices/platform/msi-ec/webcam
# owner: root
# group: root
user::rw-
group::r--
other::r--

Offline

#4 2024-01-21 16:03:17

seth
Member
Registered: 2012-09-03
Posts: 51,553

Re: [Solved] udev rule for uaccess not working

You're interested in sys/devices/platform/msi-ec/webcam but the rule only seemed to apply to sys/devices/platform/msi-ec
The ACLs aren't however set for either… did you only test them or also https://wiki.archlinux.org/title/Udev#Loading_new_rules ?

Offline

#5 2024-01-21 16:12:19

VesperLlama
Member
Registered: 2024-01-21
Posts: 6

Re: [Solved] udev rule for uaccess not working

I would like to apply the rule to all files inside '/sys/devices/platform/msi-ec/' (there are 10+ attribute files) and '/sys/class/power_supply/BAT1/charge_control_{start,end}_threshold' (2 files) so I can edit any file inside these folders without root. Is this not the way to do this?

I did run the commands here (https://wiki.archlinux.org/title/Udev#Loading_new_rules) and also restarted the system.

Offline

#6 2024-01-21 22:29:02

seth
Member
Registered: 2012-09-03
Posts: 51,553

Re: [Solved] udev rule for uaccess not working

It's the general approach but didn't apply.
The driver suggests

This driver exports a few files in /sys/devices/platform/msi-laptop:

?

udevadm info --attribute-walk --name=/sys/devices/platform/msi-ec/webcam

And you could just use the DEVPATHs directly, https://wiki.archlinux.org/title/Udev#M … s_as_eSATA

Offline

#7 2024-01-22 10:24:55

VesperLlama
Member
Registered: 2024-01-21
Posts: 6

Re: [Solved] udev rule for uaccess not working

seth wrote:

This driver exports a few files in /sys/devices/platform/msi-laptop:

It exports these files in /sys/devices/platform/msi-ec -

available_fan_modes    battery_mode  cpu     driver_override  fn_key           fw_version  leds      power       subsystem  webcam        win_key
available_shift_modes  cooler_boost  driver  fan_mode         fw_release_date  gpu         modalias  shift_mode  uevent     webcam_block

These control the EC of the laptop to change shift_modes, battery_mode, etc. I would like to edit these files without root to change shift_mode, battery_mode, etc.


seth wrote:

udevadm info --attribute-walk --name=/sys/devices/platform/msi-ec/webcam

This is giving the following error - 'Unknown device "/dev//sys/devices/platform/msi-ec/webcam": No such device'
Running 'udevadm info --attribute-walk --name=/sys/devices/platform/msi-ec/' also gives same error.

I have posted the output of 'udevadm info --attribute-walk --path=/sys/devices/platform/msi-ec/' above.


seth wrote:

you could just use the DEVPATHs directly

I changed the 70-msi-ec.rules file to this -

DEVPATH=="/sys/devices/platform/msi-ec", MODE="0660", TAG+="uaccess"

('find /sys/devices/ -name msi-ec' gave the above DEVPATH)

But it's still not working. getfacl shows the same output as before. I did run control --reload and trigger and also restarted the system.

Offline

#8 2024-01-22 16:01:30

seth
Member
Registered: 2012-09-03
Posts: 51,553

Re: [Solved] udev rule for uaccess not working

Sorry, "udevadm info --attribute-walk --path=/sys/devices/platform/msi-ec/webcam" and you want the device paths, not the directory for the latter option.

Offline

#9 2024-01-22 16:12:01

VesperLlama
Member
Registered: 2024-01-21
Posts: 6

Re: [Solved] udev rule for uaccess not working

seth wrote:

udevadm info --attribute-walk --path=/sys/devices/platform/msi-ec/webcam

Gives this error - Unknown device "/sys/devices/platform/msi-ec/webcam": No such device

/sys/devices/platform/msi-ec/webcam is a file which stores the current status of the webcam, i.e., on or off. It is not the webcam device. Similarly other files store other data like fan speed, power modes, etc.

Offline

#10 2024-01-22 16:18:00

seth
Member
Registered: 2012-09-03
Posts: 51,553

Re: [Solved] udev rule for uaccess not working

Have the rule RUN+="/some/script" that does

#!/bin/sh
(sleep 3; chmod -R 666 /sys/devices/platform/msi-ec/*) & # forked subshell to not stall udev

Offline

#11 2024-01-22 18:51:59

VesperLlama
Member
Registered: 2024-01-21
Posts: 6

Re: [Solved] udev rule for uaccess not working

I tried using the script in the udev rule but for some reason it was only working 1/3 times after rebooting. Other times it was showing that the script exited with error 1.

I have created a systemd service which runs the script on boot and it's working fine everytime. I think I'll just use the systemd service.

Thanks for your help!

Offline

#12 2024-01-22 21:03:36

seth
Member
Registered: 2012-09-03
Posts: 51,553

Re: [Solved] udev rule for uaccess not working

The path doesn't exist - you might have to sleep longer or actively wait for it to be populated.
But afaiu  this is integrated HW anyway and will be available w/ the system boot anyway in which case the systemd server (provided it's actiavted late enough™) will suffice.

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

Board footer

Powered by FluxBB