Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess as another user?

QProcess as another user?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 6.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zester
    wrote on last edited by
    #1

    I am working on a application that will build a linux cross platform multilib toolchain. The first part of the application does some prep and needs to be run with root privileges. Everything after needs to be ran from a crippled user account. My question is how would I run a QProcess as another user?

    Thanks Zester.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      baysmith
      wrote on last edited by
      #2

      I don't think that is possible through Qt APIs. You'll probably have to use some platform specific functions.

      Nokia Certified Qt Specialist.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zester
        wrote on last edited by
        #3

        Until I find another way to do it I guess I will just write a function that wraps the following...

        @
        echo password | sudo -u username -S "command"
        @

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          If you are on KDE you can use kdesudo instead of sudo. It popups a password dialog.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zester
            wrote on last edited by
            #5

            Noooo I can't use kdesudo that would make my Qt only project a Kde project and suck in about a million dependences. I did however try setuid() and getuid() but it turns out there disabled in most distro's for security reasons. And I also did some digging threw kdesudo's and it's dependences source code. But it wasn't at all obvious to me as to how they were accomplishing the samething. In kdesudo's configure file it does check for /usr/bin/sudo

            1 Reply Last reply
            0
            • frankcyblogic.deF Offline
              frankcyblogic.deF Offline
              frankcyblogic.de
              wrote on last edited by
              #6

              Checkout out http://doc.qt.nokia.com/4.7/qprocess.html#setupChildProcess .

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                zester
                wrote on last edited by
                #7

                Thank you that is exactly what I was looking for. Can't beleve that I didn't see that before! Hmmm Thanks again.

                [quote author="unclewerner" date="1297353342"]Checkout out http://doc.qt.nokia.com/4.7/qprocess.html#setupChildProcess .[/quote]

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved