jbensmann / mouseless

A replacement for the mouse in Linux
MIT License
167 stars 16 forks source link

Start as sudo when on system start #29

Closed czhang03 closed 11 months ago

czhang03 commented 1 year ago

Is there a way to start mouseless on system start without allowing the current user to read keyboard input?

I think allowing user to read keyboard input seems dangerous, since that enables the possiblity of keyloggers. However I do aware that Windows allow user to read keyboard input without elevated previlages. But it seems more secure to only allow elevated program to read keyboard input.

I understand this is not necessarily related to mouseless, but I was wondering if anyone can help me here. And if we were able to find a simple way, maybe we can add it to the readme so that others can use this setup as well.

Here is what I have tried, apparently most people thinkg systemtcl is the modern way to do this. So I created the following file /etc/systemd/system/mouseless-daemon.service:

[Unit]
Description=Mouseless

[Service]
ExecStartPre=chmod +x /usr/local/bin/mouseless
ExecStart=/usr/local/bin/mouseless --config /usr/local/share/config/config.yaml

[Install]
WantedBy=multi-user.target

However I keep getting the following error in systemctl status mouseless-daemon.service

× mouseless-daemon.service - Mouseless
     Loaded: loaded (/etc/systemd/system/mouseless-daemon.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: failed (Result: exit-code) since Thu 2023-05-25 14:13:06 EDT; 17s ago
   Duration: 1ms
    Process: 7699 ExecStartPre=chmod +x /usr/local/bin/mouseless (code=exited, status=0/SUCCESS)
    Process: 7703 ExecStart=/usr/local/bin/mouseless --config /usr/local/share/config/config.yaml (code=exited, status=203/EXEC)
   Main PID: 7703 (code=exited, status=203/EXEC)
        CPU: 3ms

May 25 14:13:06 fedora systemd[1]: Starting mouseless-daemon.service - Mouseless...
May 25 14:13:06 fedora systemd[1]: Started mouseless-daemon.service - Mouseless.
May 25 14:13:06 fedora (ouseless)[7703]: mouseless-daemon.service: Failed to locate executable /usr/local/bin/mouseless: Permission denied
May 25 14:13:06 fedora (ouseless)[7703]: mouseless-daemon.service: Failed at step EXEC spawning /usr/local/bin/mouseless: Permission denied
May 25 14:13:06 fedora systemd[1]: mouseless-daemon.service: Main process exited, code=exited, status=203/EXEC
May 25 14:13:06 fedora systemd[1]: mouseless-daemon.service: Failed with result 'exit-code'.

When running /usr/local/bin/mouseless --config /usr/local/share/config/config.yaml as sudo works perfectly fine.

I was wondering if I can get any help with regard to this.

remembertoremind commented 1 year ago

I'm not sure how to fix this, but I have some toubleshooting suggestions :)

May 25 14:13:06 fedora (ouseless)[7703]: mouseless-daemon.service: Failed to locate executable /usr/local/bin/mouseless: Permission denied
May 25 14:13:06 fedora (ouseless)[7703]: mouseless-daemon.service: Failed at step EXEC spawning /usr/local/bin/mouseless: Permission denied
czhang03 commented 11 months ago

It is indeed the problem of SELinux, I redownloaded and extract it as sudo, then everything worked. I am not sure how would you write it as a guide, but the setup above indeed works for me.