On a linux program, on the console (as in no xorg, etc), I’m using using /dev/input/event* to read keyboards and mice, however I need to be root to be able to read them. Is there an alternative form to read that stuff without needing root privileges (without having to change permisons and config files, etc)?
I understand why it does that by default no need to explain that.
Check to see to which group the device files belong to. For example, here I get:
The user executing your program needs to be in the
plugdevgroup on this system. Something similar is probably the case on your system.If you’re asking for a way to circumvent that (reading or writing to the device without being in the group), then no. That would obviously defeat the purpose of security though user groups.
An alternative to reading the event devices directly would be to use an appropriate user space API instead. For example, to read the keyboard you would use ncurses, and to read the mouse you would use GPM.
NOTE: To add existing user into group, execute the next command:
For example (for case above – ‘input’ group named
plugdev):