Closed cheesits456 closed 2 years ago
Hi! Thanks for your feature request!
I thought about implementing this too, since user supplied scripts/per-user profiles would be really nice to have! I refrained from implementing it because of the security implications this has. It would require a huge change in the security model of Eruption. The Eruption daemon needs to run with elevated privileges to access the hardware. If it would be possible for a regular user to arbitrarily load and run Lua code, this could be easily exploited in multiple ways to gain root privileges. It would increase the attack surface of Eruption by a huge margin.
One possible solution to this problem is implemented in the eruption-gui
branch that I am working on. Basically the Eruption GUI uses PolicyKit to authenticate the user as an administrator. When the user changes a configuration value via the GUI, the Eruption GUI process (running as a regular user) calls into Eruption (running as root) via a D-Bus based API and requests a change of that configuration value (or even of Lua code). The Eruption daemon only executes this request if PolicyKit confirms that the user running the GUI process is authenticated with the required permissions. This basically resembles the way other shared hardware resources are managed on Linux, like e.g. printer devices.
Implementing it this way has the following disadvantages:
In the current security model, we basically have three levels of permissions: Monitor, Settings and Manage.
Excerpt of the PolicyKit configuration:
<!-- Monitor the Eruption daemons state -->
<action id="org.eruption.monitor">
<description>Monitor Eruption</description>
<message>Authentication is required to monitor Eruption</message>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
<!-- Change non-privileged settings like e.g.: LED Brightness -->
<action id="org.eruption.settings">
<description>Change settings of Eruption</description>
<message>Authentication is required to change the settings of Eruption</message>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
<!-- Change privileged settings like e.g.: Lua script code -->
<action id="org.eruption.manage">
<description>Manage the Eruption daemon</description>
<message>Authentication is required to manage the Eruption daemon</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
I will have to think about this some more...
Perhaps you could add a toggleable option to read profiles and scripts from the .config
directories, and provide a warning about the security implications? Because for people who only use their computers for themselves and only have a single account on the computer, that isn't so much of a problem. Just an idea ¯\_(ツ)_/¯
Hey there, i got my Roccat Vulcan today and i love this project! Im getting excited to script my own scripts!
In
/etc/eruption/eruption.conf
i tried to add my user-.conf folder to the search paths by adding them comma separated like this
[global]
profile_dirs = ["/var/lib/eruption/profiles/", "/home/USER/.config/eruption/profiles/"]
script_dirs = ["/usr/share/eruption/scripts/", "/home/USER/.config/eruption/scripts/"]
Seems that this does not work and is related to this task
Im not a very advanced user, so i thought my questions are here at the right place?
Hi @SHU-red, thanks for your feature request!
Eruption 0.1.23
built from the current master
branch is able to load scripts and profiles from the user's home directory. I just double checked this.
Support is in place for the following components:
eruption
daemon propereruptionctl
should mostly be able to deal with multiple script and profile pathsMissing support or erratic behavior:
eruptionctl scripts list
does not show some of the user's scriptsSteps to add custom directories:
mkdir -p /home/USER/.local/share/eruption/{scripts,profiles}
sudoedit /etc/eruption/eruption.conf
Now please add the directories as applicable to the [global]
section in eruption.conf
You need to create a my-profile.profile
file in the respective profile directory
You need to create script.lua
and a valid script.lua.manifest
file in the respective script directory. The .manifest
file is mandatory, without it it will not work
If it still does not work then please post debug logs of eruption
:
sudo systemctl mask eruption.service && sudo systemctl stop eruption.service
sudo RUST_LOG=debug eruption
# re-enable eruption.service
sudo systemctl unmask eruption.service && sudo systemctl start eruption.service
Please open up new issues as soon as you encounter further problems! Btw., please specify the version of Eruption that you are currently using.
Thanks for your friendly support! I installed eruption-git from AUR-package manager which seems to be (Eruption 0.1.23 (0.1.22.r28.g1ba264c) (release build))
/home/USER/.local/share/eruption
or can i choose whatever i want? Like /home/USER/.config/eruption
?@SHU-red thanks, you're welcome!
I just built Eruption from git commit 1ba264c and can confirm that this built is able to handle custom scripts and profiles. So there must be something else that is going on.
The location of the directories is not important. You can place the files wherever you like, as long as your user account has read/write access to the files it should be okay.
Could you please post your .profile
file and/or .lua
script and .lua.manifest
file?
Please post debug logs as well!
Now i did acknowledge, that you also created a eruption-gui! Awesome!
OK as said im not very advanced in all of this stuff but i tried my best:
I understood, that your commit 1ba264c from 24. Aug should already be contained in the eruption version i use from AUR eruption-git = 1.2.23 Hopefully i did understand you right
Based on that i now did try to crate
Here is what i did:
Attention: For the first step, i only used scripts already provided by eruption in my user.profile, so i did NOT use destinytwo.lua(.manifest) --> I only used scripts provided by eruption
active_scripts = [
'solid.lua',
'ghost.lua',
'wave.lua',
'default.lua',
]
Reboot my PC (because i dont know if there is something wich has to scan folders at first or somethin --> Roccat Vulcan basically working with default.profile active
$ eruptionctl switch profile /home/sebastian/.config/eruption/profiles/user.profile --> Nothing changed
$ eruptionctl status profile --> Still default.profile active
Check debug log during trying to change profile:
ERROR eruption::plugins::audio > Pulse Audio error: Could not open Pulse Audio: Connection refused DEBUG eruption::scripting::script::callbacks > Macros: Key down: Index: 89 ERROR eruption::plugins::audio > Could not initialize the audio backend: Pulse Audio error: Could not open Pulse Audio: Connection refused ERROR eruption > Pulse Audio error: Could not open Pulse Audio: Connection refused DEBUG eruption::hwdevices::roccat_vulcan_1xx > |0300fb6b 01000000| ...k.... 00000000 DEBUG eruption::hwdevices::roccat_vulcan_1xx > 00000008 DEBUG eruption::scripting::script::callbacks > Macros: HID event: 2 args: 107 INFO eruption > Loading profile: /home/sebastian/.config/eruption/profiles/user.profile INFO eruption > Switching to profile: /home/sebastian/.config/eruption/profiles/user.profile ERROR eruption > Script file or manifest inaccessible: default.lua ERROR eruption > Invalid profile: /home/sebastian/.config/eruption/profiles/user.profile, refusing to switch profiles DEBUG eruption::hwdevices::roccat_vulcan_1xx > |0300fb6b 00000000| ...k.... 00000000 DEBUG eruption::hwdevices::roccat_vulcan_1xx > 00000008 DEBUG eruption::scripting::script::callbacks > Macros: HID event: 1 args: 107 DEBUG eruption::scripting::script::callbacks > Macros: Key up: Index: 89 ERROR eruption::plugins::audio > Could not initialize the audio backend: Pulse Audio error: Could not open Pulse Audio: Connection refused ERROR eruption > Pulse Audio error: Could not open Pulse Audio: Connection refused
Despite the Pulse Audio error it says, that my Script file or manifest default.lua is inaccessible and the user.profile is invalid
The chance is high, that i did do something wrong.
Tell me if this is the case ...
Thank you again!
## eruption.conf
[global] profile_dirs = ["/var/lib/eruption/profiles/", "/home/USER/.config/eruption/profiles/"] script_dirs = ["/usr/share/eruption/scripts/", "/home/USER/.config/eruption/scripts/"]
keyboard_variant = "ISO"
enable_mouse = true grab_mouse = true
afk_profile = "/var/lib/eruption/profiles/rainbow-wave.profile" afk_timeout_secs = 0
## user.profile
id = '5cd23fa6-e965-45cb-a0cd-e87d28713092' name = 'USER' description = 'User defined profile' active_scripts = [ 'solid.lua', 'ghost.lua', 'wave.lua', 'default.lua', ]
## destinytwo.lua
no changes to gaming
## destinytwo.lua.manifest
only changed name and author
## System
inxi -Fxxxrz
System: Kernel: 5.14.18-1-MANJARO x86_64 bits: 64 compiler: gcc v: 11.1.0 Desktop: awesome 4.3-1307-g0246c44d4 vt: 1 dm: SDDM Distro: Manjaro Linux base: Arch Linux
@SHU-red
Yes you did understand that correctly. The AUR package eruption-git
does ship with support for multiple script and profile directories.
It seems that the Lua script default.lua
does not exist in your custom directory!? Eruption does have a eruption/src/scripts/lib/themes/default.lua
but it this is a color theme, not an effect script.
You are missing macros.lua
in your .profile
; it is possible to run a profile without macros.lua
but you will be lacking a lot of features:
FN
+ F1
- F4
won't switch slots anymoreSo please try to replace default.lua
with macros.lua
!
OK thanks a lot! I think there is something i completely got wrong!
I thougt each profile has slots fro F1 to F4 which are defined in the .profile file.
But i think one profile only defines the behaviour of for example ohnly the Slot F1
Thanks ...
I will try to discover this
I got it working!
One last thing, regarding the topic of this issue:
Thank you very much for helping me and i will try to contribute if necessary and possible for me! Looking forward to future releases 😉
Hi @SHU-red, great that it is working now!
The /etc/eruption/eruption.conf
file is handled as a conffile by most package managers, and should not be overwritten when it has been modified.
Mainly because of the security implications I will refrain from shipping such a change in the default installation, but I will continue to support this feature for the users who like to have that kind of setup.
If it doesn't get overwritten it's totally perfect for me!
Thanks!
I absolutely love this driver, it works amazingly well and opens up so many opportunities for doing cool stuff with the keyboard - you've done some amazing work :)
A suggestion I have is that the
eruptionctl switch profile
command should also look for profiles stored in a directory such as~/.config/eruption/profiles
, and theactive_scripts
array should also look for scripts stored in~/.config/eruption/scripts
. That'll allow each user to make their own configs and stuff unique to that individual user, and it won't require root privileges to modify