Well Iâll try to explain what Iâm trying to do here. So I want users in the group wheel to have write access to the file conservation_mode which appears under the /sys/ directory. In the first rule I tried to do wildcard matching with the path but it didnât work so I tried to write something simpler but to my surprise it doesnât work either.
The full path of the file in my case is /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode.
The udev file Iâm using to confirm if the contents appear in my new generation
Oh okay makes sense, looking at the readme, lets say if I were to fork that project and make changes that would work for Nix right after installation of that extension then what would be the best way?
Thatâs just translating the rule from that repo into NixOSâ more expressive attrset, and limiting it to wheel; you could use a stringly typed version if you prefer.
How did you come to believe you need to change the permissions on that file?
Well I inspected the code from that repo and it was writing to that file and the sudo rule itself tries to tee so I said why not try to make it writeable for wheel group and make this process easier this way the extension would work without having users to do anything else.
I really want to fork this repo and make it so that it works on almost any linux distro without having users to do anything which is what encouraged me to give udev rules a go (I even asked this in nixos matrix and they suggested udev as well)
The way to go would be polkit then. I do not know how (I havenât written my own rules so far) but that seems to be the most sensible way to allow partial elevation for a user, and it feels as if it should be possible.
There is one more issue here though. Even after applying this sudo rule it doesnât let my user write to that file. Looking at the extensionâs README this should suffice but Iâm not sure whatâs wrong
Do you get any logs in dmesg telling you that unathorized users attempted to use sudo or such?
Itâs possible the rule isnât correct, that the plugin doesnât run as your user, or that the command isnât the same as the one exposed by the package. I think the string has to match exactly, so perhaps using the absolute path is a problem.
(This is precisely why using PAM is preferable, since it exposes a proper API rather than string matching in sudoers, which is notoriously difficult to configure and easy to expose yourself to exploits with - that said, PAM is more effort and requires application support AIUI, so likely not an option without a ton of work).