0
everyone.
I am developing applications in Qt5, but it requires low level hardware access and thus need to be executed as root. My target operating systems are Debian (ARM) and Ubuntu (x86).
Problem is, that all apps that are executed as root (via sudo) are using root settings and enviroment.
I need to somehow force Qt app to run with same theme and fonts as normal user.
Is it somehow possible to achieve this? Like executing via shell script with additional execution parameters and commands?
Here are screenshots to show difference:
2Better solution IMHO: Split off hardware dependent part, wrap in an API and execute as a separate process as root. Then the Qt GUI part can run as the user. That also makes it easier to add other UIs, e.g. commandline. – dirkt – 2017-10-28T16:58:02.787
I second dirkt's suggestion. Or, as an alternative, add the required POSIX capabilities (e.g.
CAP_SYS_RAWIO
) to the executable file and enable the capability only in the parts of the program where it is really needed. Seeman 7 capabilities
. Running GUI programs as root is generally considered a bad idea, since they contain a massive amount of software (Qt, for example) that has not been audited for this kind of use. – Johan Myréen – 2017-10-28T19:24:16.743Well, I am not that great developer to reimplement all in API. I developed C++ CLI apps few years, but quite new to Qt implementations. I am using hidapi library by signal11, thats main HW level implementation (with my small customizations). My first idea was to somehow allow opening all USB HID devices as user via something like udev rule, but not found any too "generic" solution yet... – HeliTux – 2017-10-28T19:45:13.783