Skip to content
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

Make udev rules work on distros without plugdev group #287

Closed
wants to merge 2 commits into from

Conversation

vinicentus
Copy link
Contributor

The plugdev group is from what I understand an Ubuntu specific thing. This fixes the udev rules so they work on other distros such as Arch. I also corrected the name of the udev rules file in the makefile.

Tested on Arch.

Let me know if this looks ok.

@dwillmore
Copy link
Collaborator

plugdev is a systemd thing, so any distro using it: Debian, Ubuntu, Fedora, SUSE, CoreOS, etc. This change will break udev for the majority of Linux users.

Please reconsider this change.

A reasonable change would include a test for the distro of the machine by testing the ID field of /etc/os-release.

@cnlohr
Copy link
Owner

cnlohr commented Mar 7, 2024

I think agree with @dwillmore here. If your distro is missing plugdev, add it. Otherwise, all users, including users you may want to have limited (non-USB access) can get access to it.

@cnlohr
Copy link
Owner

cnlohr commented Mar 7, 2024

It's pretty easy to say:

sudo groupadd plugdev
sudo sudo usermod -aG plugdev YOUR_USERNAME

We could document that.

@dwillmore
Copy link
Collaborator

dwillmore commented Mar 7, 2024 via email

@vinicentus
Copy link
Contributor Author

vinicentus commented Mar 7, 2024

Both of you have good points.
One solution for the systemd/non-systemd problem is to just include both GROUP="plugdev" and TAG+="uaccess".
Or if a check is implemented it should check for systemd, not for an indication of systemd such as the distribution.

But if the problem is that you don't want all users to gain access to the devices, then I'm not sure it can even be done with the uaccess tag.

If you think including both group and tag is ok, I can implement that. Otherwise let's just make a note in the wiki/readme.

Note also that the minichlink makefile currently references the wrong udev rules file name on the master branch.

@dwillmore
Copy link
Collaborator

Seems like the Makefile needs to be fixed at least.

@cnlohr
Copy link
Owner

cnlohr commented Mar 9, 2024

We definitely do not want to allow uaccess as that could definitely be a source of CVEs moving forward. We can add a check to minichlink to see if the current user is in the plugdev group, and if not, warn them?

cnlohr added a commit that referenced this pull request Mar 9, 2024
@cnlohr
Copy link
Owner

cnlohr commented Mar 9, 2024

I have added a check for plugdev in minichlink, as well as added a note on the installation instructions. https://github.com/cnlohr/ch32v003fun/wiki/Installation#archmanjaro

@cnlohr cnlohr closed this Mar 9, 2024
@vinicentus
Copy link
Contributor Author

That seems like a good solution. Please also update the makefile to install the correct udev riles file: https://github.com/cnlohr/ch32v003fun/blob/master/minichlink%2FMakefile#L43

Also, I think udevadm --reload and optionally udevadm trigger is a more universal way to reload the rules.

@cnlohr
Copy link
Owner

cnlohr commented Mar 11, 2024

Fixed.

@vinicentus
Copy link
Contributor Author

Amazing, thanks!

Actually it should be udevadm control --reload for it to work. I was typing my last message from memory on my phone :D

I tested with that modification and by adding the plugdev group and it works.

But, I can't get the minichlink plugdev group warning to trigger. How is it supposed to work? Shouldn't I see the message when trying to run any minichlink command when there is no such group or when I'm not in the group?

@vinicentus
Copy link
Contributor Author

Actually it should be udevadm control --reload for it to work. I was typing my last message from memory on my phone :D

@cnlohr did you ever fix this?

@CodeAsm

This comment was marked as outdated.

@prosper00
Copy link
Contributor

just my 2c, but i feel like sysadmin stuff - such as ensuring permissions - is my own responsibility. And how i choose to implement it - via groups, policies, udev, etc - is my job. Applications should simply assume that I've done my job correctly, and display an error -maybe with a hint- if i haven't. But it bugs me when they decide to enforce a particular assumption about how a thing must be done.

@dwillmore
Copy link
Collaborator

dwillmore commented Apr 7, 2024 via email

@vinicentus
Copy link
Contributor Author

Well yeah, arch linux also considers plugdev a bug. But I definitely get the concerns of automatically -perhaps without the user knowing about it- allowing all users on a system access to a physical device.

So I think the current solution is ok.

If you want to use uaccess, though, just apply the patch from my branch.

@cnlohr
Copy link
Owner

cnlohr commented Apr 22, 2024

Well yeah, arch linux also considers plugdev a bug. But I definitely get the concerns of automatically -perhaps without the user knowing about it- allowing all users on a system access to a physical device.

People use hidapi. They have to with it. You can only plug your ears and yell "I can't hear you" for so long. If a user has adm, then it's just silly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants