Nitrokey / nitrokey-app

Nitrokey's Application (Win, Linux, Mac)
https://www.nitrokey.com/
287 stars 55 forks source link

Set Udev rules through AppImage / Flatpak #435

Open szszszsz opened 4 years ago

szszszsz commented 4 years ago

Automatically set Udev rules, when installing from AppImage or Flatpak. From https://github.com/Nitrokey/nitrokey-app/issues/431:

@enleth BTW any idea, how to insert Udev rules into mentioned?

AppImage can do pre-sandbox wrapper scripts and some developers seem to be using those to invoke a script through sudo that would "install" the udev rules, such as: https://github.com/EspoTek/Labrador/issues/22#issuecomment-364594369 https://github.com/JvanKatwijk/qt-dab/issues/34#issuecomment-289270761

Maybe there is a way to do this that doesn't look really scary and hacky, not sure. First things first, something like that probably shouldn't add unmanaged files to /etc/. Instead, /run/udev/rules.d/ could be used - this seems to be a little known feature of udev despite being mentioned in the literally first sentence of the "RULES FILES" section of udev(7). Still requires root access, though, and is arguably even worse from the UX point of view - instead of asking for root once and leaving a mess in /etc/udev/rules.d/, the app requests root access after every system reboot because /run/udev/rules.d/ is volatile.

Flatpak doesn't even have that. Not even Valve managed to get around this for Flatpak version of Steam and the Steam Controller: https://github.com/flathub/flathub/issues/278 https://github.com/flathub/com.valvesoftware.Steam/issues/8

In effect, both work nice as a quick upgrade path for when your distro does include nitrokey-app but doesn't update it fast enough - so you can keep the distribution package installed for the udev rules but actually use the AppImage or Flatpak version. Otherwise it's horrible hacks, or manual changes to udev rules, or nothing. Honestly, I can't think of a proper way out at the moment.

szszszsz commented 2 years ago

Connected https://github.com/Nitrokey/nitrokey-app/issues/475