0

My App needs to have write access to /dev/input/event*. On my Ubuntu system /dev/input/event* is owned by root:input. My app runs fine if I use sudo, but I'm trying to avoid that. So I set my App up to be in the 'input' group and run with setgid. But it's a cross platform App (GTK) which detects and disallows that. (It literally says the GTK has detected it's trying to run as setgid or setuid and it's not going to allow it.) But it's really the .so file that wants to write to /dev/input/event*. I'd feel a lot better if I could allow just this .so (that's in good shape and won't change often) run as root. Or if the .so file got to run as setgid then the GTK environment may not detect it. I've tried setting the special bits on the .so file, but then when I run the app it has the same permissions problem on /dev/input/event*.

1
  • 1
    Maybe put the code that needs to consume /dev/input/event* in a separate binary (a helper program that can be setgid). Then have your UI program fork/exec that binary. You can set up a pipe between the two to communicate any needed data back to the UI program for consumption. Aug 4 '21 at 1:32
1

Permissions are tracked per process (in fact, per thread in Linux), not per object file loaded to run the process. As such, you can’t associate different permissions with a .so file.

As suggested by Andy Dalton, a common way of proceeding is to have a small helper binary, and ensuring that it has the appropriate privileges (using permissions, or capabilities, etc.).

Another possibility would be to add udev rules to grant permissions on the event device to your user, or perhaps whoever is at the console.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.