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

Linux install of /etc/udev/rules.d/52-airspyhf.rules maybe could add group and mode #46

Open
mahtin opened this issue Dec 7, 2023 · 11 comments

Comments

@mahtin
Copy link

mahtin commented Dec 7, 2023

In order to remove the need to run everything accessing the AirspyHF+ via sudo; I'm wondering if the following is acceptable as a change to the s/w? (If so, I'll PR it). It does work.

The distributed 52-airspyhf.rules file does not specify the group id or mode for the created device file /dev/airspyhf-*. I've added GROUP="dialout", MODE="0660", to the file and now I can use the AirspyHF+ without sudo. My file is as follows:

$ cat /etc/udev/rules.d/52-airspyhf.rules 
ATTR{idVendor}=="03eb", ATTR{idProduct}=="800c", SYMLINK+="airspyhf-%k", GROUP="dialout", MODE="0660", TAG+="uaccess"
$

I picked dialout as the group as I was already a member. I don't know if there's a better choice (maybe gpio or netdev? - neither is great!)

Thoughts. As I said, I'm happy to PR this.

@jketterl
Copy link

I'll just chime in here since I just noticed that the udev rules have been reduced to uaccess tagging in this repository. I don't know where this movement started, I think I do understand the idea behind it, but I can tell that it is insufficient to cover all use cases.

From what I can tell, the idea is that the uaccess tag will handle the permissions of the devices "automagically" through ACLs when a user logs in. From what I can tell, this is probably working for SDR applications running in userspace. The problem with the uaccess tagging is that it leaves a big hole for anything that does not run in a systemd user session, for example any application running as a systemd service unit will not be able to access the devices (unless it is run as root, which is probably not a good choice in general).

I have brought this to the attention of the Debian maintainers of the libairspy packages (yes, i know that's a different library, but they introduced the same change a while back and it cause the same issues) and they have now brought back the group assignment for "plugdev" in the most recent version.

See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1033121

I don't know if there's another solution to this in the systemd universe. If you know how to solve this differently, please let me know. For me, it seems there has to be at least some "classical" permissions in place for this to work correctly, so I'd recommend combining the best of both worlds, that is: having both a group assignment and uaccess tagging.

@mahtin
Copy link
Author

mahtin commented Dec 28, 2023

The key takeaway from that reference is:

 * use group plugdev along with uaccess to allow for systemd services

Which makes sense.

Plus, plugdev is a better choice and works well for me.

$ grep plugdev /etc/group
plugdev:x:46:martin
$
$ cat /etc/udev/rules.d/52-airspyhf.rules 
ATTR{idVendor}=="03eb", ATTR{idProduct}=="800c", SYMLINK+="airspyhf-%k", GROUP="plugdev", MODE="0660", TAG+="uaccess"
$

With 0660 mode and group "plugdev" this will be a step forward. Those still running as root (ie. Everyone following the instructions) won't be affected. Those following newer versions of instructions will benefit. (Or their system will benefit - more correctly).

I'll PR it and see how this goes.

@mahtin
Copy link
Author

mahtin commented Dec 28, 2023

Ok. There's history here. @aeroevan needs to chime in because of this edit. 6d4469d

A year ago the group and mode was removed and replaced uaccess. Why not both as I'd like to recommend?

@AsciiWolf
Copy link

It would be ideal if the udev rules (for both airspy and airspyhf) were submitted into upstream udevd (systemd), just like other devices do. It would prevent similar issues and make airspy work out-of-box on all modern Linux distributions (including containerized environments like Flatpak, Snap or AppImage).

@mahtin
Copy link
Author

mahtin commented Jan 20, 2024

Yes that would be idea (and I believe needs a different issue opened - along with an advocate to do that work); however, that doesn't detract from this issue and its (present day) need.

@aeroevan
Copy link
Contributor

On fedora there isn't a plugdev group, and removing that reference was needed to get running on my fedora-iot hosts. There probably is a better way to handle cross-distro support though, I'm not really an expert in udev rules and would be willing to test on a fedora install. I probably should have tested on the debian side too, but I don't currently run any debian based systems

@jj1bdx
Copy link
Contributor

jj1bdx commented Mar 21, 2024

The same modification was needed to run libairspyhf on Raspberry Pi OS 64bit. See this comment: jj1bdx/airspy-fmradion#77 (comment)

@jj1bdx
Copy link
Contributor

jj1bdx commented Mar 22, 2024

The same modification was also needed to run libairspyhf on Ubuntu 22.04.4 LTS.

@bigalnz
Copy link

bigalnz commented May 16, 2024

+1 on this issue - I just spent an hour trying to workout why airspyhf_info will only run as sudo. Still a little unclear on steps from here?
Add my user to plugdev and modify the udev rule?

@vielmetti
Copy link

I happened upon this issue when getting OpenWebRX+ to run on my AirSPY HF+. As distributed, the v1.2.61 version udev rules generate this exception:

owrx.source.airspy - ERROR - Exception during postStart()
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/owrx/source/__init__.py", line 427, in start
    self.postStart()
  File "/usr/lib/python3/dist-packages/owrx/source/connector.py", line 62, in postStart
self.controlSocket.connect(("localhost", self.controlPort))
ConnectionRefusedError: [Errno 111] Connection refused

see also discussion at https://groups.io/g/openwebrx/topic/103545886

@touil
Copy link
Member

touil commented Jul 7, 2024

Unrelated to this repos.

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

No branches or pull requests

8 participants