-
Notifications
You must be signed in to change notification settings - Fork 174
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
Feature request: allow non-root execution #692
Comments
after running tests, it seems that non-root keyd cannot detect new input devices, such as those created by itself and
without sudo:
which means runner.py detects no keys and fails the test. this is also seen when unplugging and replugging my keyboard/mouse; same error, different event files. not sure what's causing this issue. running keyd in gdb and slowly going through functions before getting to changes: peesock@8639aa7 |
by unplugging and replugging my mouse while running a test C program with
line 1: mouse device file does not exist yet so it looks like evloop needs to retry on failed event* file opens. edit: fixed with peesock@a15c0e1. tests are passing, so i'm going to start actually using this cool project now that i can run it as a user. |
keyd is deliberately written to run as root. My view is that if a user has compromised an account that can read or write input events, your system is effectively compromised anyway (apart from injection attacks, the attacker can just keylog everything).
This is a valid point, and there was some debate about adding command(), but its intended purpose is for running system level commands. It is not intended to be a substitute for window manager/user level bindings (sxhkd exists for this purpose). If the user can edit /etc/keyd/ they already have root access. |
yeah, that makes sense. projects like swhkd use a privileged daemon that communicates directly to a specific user-owned process, and that process only spawns shell commands, creating a model where all /dev/input access has to be explicitly granted per-process by root. this is quite secure, but not how i personally run my desktop. i basically give my user infinite permissions ( this is just me. i'm not advocating for per-user usage to be a common thing, only the flexibility to permit it. if it doesn't belong, i'm fine with maintaining my 3-commit fork. |
Sorry for the prolonged response.
I'm not sure how this applies to keyd. As I understand it, swhkd is a root level process that still reads all the input (like keyd), it just delegates command dispatch to a user level daemon ('the server'). The daemon which reads the config file still requires access to /dev/input/*, so it is unclear to me where the additional security comes from.
Don't we all ;). |
It doesn't, just citing an example of something more secure than running things directly, as I initially wanted from this project :) Anyway, i dug more into the matter of running as a user and am learning about seat management to maybe add this capability in the future. No promises. I don't even know how lock screens would be handled, in case you want to use keyd as a sxhkd replacement... After posting this issue, i started thinking a lot more about security and how a universal hotkey daemon could work. |
Adding proper support for this is non trivial and involves significantly increasing the attack surface. It is closely tied to implementing per-user configs, which is a feature I actually have a working prototype for that relies on the same kind of VT monitoring tricks that seatd does. Adding I am going to close this for now, since I am trying to prune the issue tree, but feel free to reopen it if you want to add something. |
Thank you for being clear on this and still open for future support.
Indeed, any administered company laptop is compromised, but it would still be useful to, say, map Capslock to Escape and Control as a user. |
Thanks to linux udev rules, it is possible for a normal user in a specific group (usually "input" or "uinput") to access /dev/input files.
In my opinion, hard-coding root-only actions, namely
setgid
andnice
(with negative values) into the daemon, especially when these actions can be taken care of by the init/service manager, isn't a good idea. It reduces flexibility and adds potentially unwanted behavior, like running commands as root.I was able to get the basic daemon working by removing root functions and adding command line options to customize the paths for SOCKET_PATH and CONFIG_DIR.
Assuming most people run keyd using the systemd service, the
setgid
andnice
behavior can be replaced with these service optionsto avoid breaking current behavior. If keyd's built-in version of this isn't a big deal for most people, then perhaps it could be locked behind new CLI options, or removed entirely.
The text was updated successfully, but these errors were encountered: