Here is explained how to gain access to the peripheral without being root. I've just tried in my environment (Raspbian Stretch, RPi2, Qt5.9) in this way:

int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);
    MyServer server;   
    return a.exec();

then, on the target:

$ sudo chown root:root MyServer
$ sudo chmod u+s MyServer

but running it as normal user leads to a segmentation fault. Here's the output of gdb:

$ gdb MyServer 
run(gdb) run
Starting program: /home/pi/bin/MyServer 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
bcm2835_init: Unable to open /dev/mem: Operation not permitted

Am I missing some steps?

  • Try throwing an explicit seteuid() call in and see whether it succeeds (and/or use geteuid() to check). – goldilocks Oct 2 '17 at 15:33
  • Is this not enough? $ ls -l -rwsr-xr-x 1 root root 3322439 Oct 2 16:35 MyServer – Mark Oct 2 '17 at 16:03
  • Furthermore if I don't set the SetuidAllowed to true, it refuses to start saying: " "FATAL: The application binary appears to be running setuid, this is a security hole." Hence I assume it succeeded. – Mark Oct 2 '17 at 16:04

Your Answer

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

Browse other questions tagged or ask your own question.