-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: mdev wrapper for udev rule emulation #89
Comments
I had a similar idea and I support this approach. Just one thing, what do you mean by "amalgamated"? Will the mdev.conf config be rewritten everytime? |
No, I just mean something like |
Oh, didn't think about this. This is a really cool approach! The only thing I'm concerned about is the fact that this would tie everything to mdev instead of having something like the init-agnostic hook system. I should have talked about this in the previous ticket IIRC, but basically IMO it'd be better to use something like the Linux hotplug interface which should also be exposed by mdev by making it call a script. It'd also not require to restart the whole mdev service everytime the device rules file would change. I got a POC installed on my system which works pretty well. I'm aware that my proposed solution is more complex, but IMO the advantage of being able to reuse rules across device managers outweighs the cons. |
Can you share the POC? Creating a framework is more portable but it would be more messy, and @illiliti has raised some concerns over fork + exec implementation for a framework: https://libera.irclog.whitequark.org/kisslinux/2022-08-30#32825590; https://libera.irclog.whitequark.org/kisslinux/2022-08-30#32825796 |
Sadly my POC uses scripts so it definitely has the issues pointed out by illiliti.
The programs run by mdev have access to a few environment variables outlined here: https://www.kernel.org/doc/html/v4.18/driver-api/usb/hotplug.html#usb-policy-agent I use this "framework" for running a little script that scans a list of regexes (with optional comments) and, if the usb product ID matches, it sets its permission to the one defined by the list's filename.
this script in turn looks for files into a
While this is very hackish, it works fine for my needs. |
What about coming up with an easy to parse format for udev rules which can be used to generate configs for individual device managers? |
@git-bruh that doesn't really convince me at all. You'd have to ship the udev rules and have always in your computer an udev parser, which to me just looks like a good way of supporting that hellish format. |
Sorry for the double post, but I and @illiliti have found a good compromise (IMO), which consists of having scripts run per subsystem by using the |
@git-bruh thanks for finding the ref! I didn't think about it. What do you think about this approach? |
@Riteo I still feel it's clunky due to duplication of matching functionality of mdev with |
@git-bruh you're right regarding the fact that this solution would duplicate some of mdev functionality. They're both hotplug managers really. The thing is though, that having a complete configuration parser and converter brings up its own issues, ranging to theoretical or kinda minor (in the case of using udev rules, wouldn't it reinforce it as a de facto standard?) to practical (wouldn't it be a duplication too? Why not patch the device manager directly to read said format? What if the target device manager doesn't support some features of the "generic" format? How do we choose the "generic" syntax?) The nice thing about scripts is that they're universal (well, as far as Linux is concerned). Another compromise of which I thought of was to make some "domain-specific" """language""" like with the most common case of giving certain permissions to specific USB ids. So you'd have your single script/binary concerning the USB subsystem that'd sieve through a list of ids and assign the group according to something like the filename or some other implementation-specific detail (i'd still expose the directory-per-subsystem approach thought by me and illiliti though). This'd keep forking to a minimum while giving space for esoteric packages to do the weirdest things would they need that. Wrapping this up, I think that this could be like an alternative generic package-accessible system for some weirder things which should be common to all device managers, while mdev, mdevd and whatever should handle the basic things and the dispatching to this fallback script-based system. Your idea sounds interesting, but it really feels like some slippery slope as something tells me that it'd either create a de facto standard or some intermediate thing which'd do either too much or too little. |
@Riteo I'm fine with your suggestion too, it's probably better for more complex rules as well which can't be expressed in a config file |
Packages can individually install rules in the
mdev.conf
syntax to/etc/mdev.conf.d/*
, which will be amalgamated and passed to the mdev implementationThe text was updated successfully, but these errors were encountered: