[Qt-interest] Execute process as a different user

william.crocker at analog.com william.crocker at analog.com
Fri Jul 24 17:58:23 CEST 2009


> 
> I'd like the ability to execute a process as a different user. I'm
> reasonably certain that at the moment this is not possible without
> resorting to platform-specific system calls. Can anyone verify that
> this is the case? I've spent some time looking through the
> documentation for QProcess in Qt 4.5, and I can't see any way to do
> this.
>

1 - Your app will need to run as root if it wants to
     become a different user.
     This has its own set of problems:
     - LD_LIBRARY_PATH is no longer applicable.
       I statically link.

2 - Perform different-user-work from a forked context
     created using QProcess.
     This has its own set of problems.
     - You can not risk using any Qt code from a forked context
       because it may require a Mutex which was frozen in the
       locked state at fork time.

3 - Override QProcess::setupChildProcess () from
     which you call setgid and setuid in the forked context.

Bill




More information about the Qt-interest-old mailing list