Please nominate your Qt Champions for 2021!

Qt Creator deploy and execute with different users

  • I am surprised this is not already in, or that no one (I found) is talking about this...

    Here's the scenario:
    I have a generic linux remote target setup in qt-creator. The linux it runs is Yocto based. It works great with debugging integration and all. Problem is, the projects I build need to deploy things in directories such as /usr/lib and /etc in the target. For this to work, I need to setup the user for the remote device as "root". Thus when qt-creator executes programs on the target, they get run as root also. It runs and works of course as root can usually do anything in the system. Two things don't work though: if your executable registers D-Bus services and root is not allowed to own the service, then it doesn't work. Secondly, when having to develop and test a proper system-wide users and permissions scheme, having the exec run as root hides such problems.

    So this is kind of a feature request I guess, Qt-Creator should really deal with this as it's quite easy for it to do so. Two ways to do this:

    • Either the device has a deploy user and a "run as" user
    • or the project has the possibility to specify an alternate user in the "Run" configuration

    Implementation wise I guess it would be as simple as prefixing the gdbserver remote command with a "sudo -u $altuser"... or just use the proper user when invoking the ssh commands (sftp and ssh).

    In the mean time, I thought of hacking the remote's "/usr/bin/gdbserver" with a script that prefixes the call to the real gdbserver with sudo -u ...although the target's root filesystem tends to be a volatile environment so on top of being an ugly hack, this is kind of unsustainable.

    (BTW, adding "sudo" in the project's "alternate executable on device:" with "-u /usr/bin/myprogram" in the run arguments doesn't work for debug since gdbserver will be debugging the "sudo" executable instead of the executable we want.)

    Thoughts? Clues?

  • Moderators

    Sounds like a sensible idea... if you do not want this to get lost you should "file a feature request": via the bugtracker.

    Patches are of course welcome, too.

Log in to reply