Deploy to remote and run in terminal (as root!)?



  • Hi

    I set up a crosscompile enviroment between my desktop-pc Qt-Creator and a RaspberryPi2 as described in this Guide.

    So I can already write,compile and deploy my code from my desktop-pc to the RaspberryPi, thats works flawlessly.

    The problem is I NEED to run the deployed executable:

    • with argument "--platform xcb"

    • as root

    because it accesses the bcm2835 library for SPI access, so there is no way around root.
    Is that possible at all?

    I normally would use "run in terminal" and then add a "-e sudo" if I would run it locally but with a deployed executable there is no such an option.

    Bildschirmfoto_2019-11-01_13-17-40.png

    I tried to invoke "Alternate executable on device" and used various commands like:

    /usr/bin/xterm -e sudo /home/pi/adas0002  --platform xcb
    

    but then I get

    Starting /usr/bin/xterm -e sudo /home/pi/adas0002 --platform xcb...
    bash: /usr/bin/xterm -e sudo /home/pi/adas0002 --platform xcb: File or directory not found
    13:22:40: Application finished with exit code 127.
    

    The executable is succesfuly transfered to the RaspberryPi and is in /home/pi and I can actually execute it with the same command directly on the Raspberry without problems...

    Bildschirmfoto_2019-11-01_13-26-05.png
    Any ideas how to solve that?



  • I somehow workaround it.
    On the RaspberryPi I created a bash script in /usr/bin:

    /usr/bin/x5

    #!/bin/bash
    xhost +local:
    sudo /home/pi/adas0002 --platform xcb
    

    I made it executable and then on my Desktop-Pc in Qt-Creator
    I have "/usr/bin/x5" in "Alternate executable on device".

    Now my application starts with root even without invoking any terminal.
    I know this is very bad in security point of view but I dont care on my little offline
    Raspi...