How to test if a program was invoked by a console user?
2
votes
3
answers
240
views
I've built an application that emulates a HID device via
/dev/uhid
on linux. My application is broken into two programs. First, a very simple setuid root binary that opens /dev/uhid
and emulates just the one device, passing messages back and forth to the program that invoked it. Second, an application that actually contains all of the device logic, and uses the other binary just to encapsulate uhid_event
messages and talk to the kernel.
Anyone with console access can plug in a hardware USB device anyway, but for security, I would like the setuid program to refuse to run on behalf of non-console users.
My question: What's the simplest, most robust way for a setuid root application to check if it was invoked by a console user and bail if not, or to restrict execution of the program to console users in the first place?
Asked by user3188445
(5539 rep)
Jun 9, 2023, 09:19 PM
Last activity: Jun 14, 2023, 12:36 AM
Last activity: Jun 14, 2023, 12:36 AM