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. partially solved - interacting with "sudo" using C++
Forum Updated to NodeBB v4.3 + New Features

partially solved - interacting with "sudo" using C++

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 390 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by Anonymous_Banned275
    #1

    Partially solved
    I missed adding more options to the "sudo"
    sudo -S ps (password)
    That works .
    Now I need to figure out WHEN to actually reply to the correct prompt with a password.
    I have no idea from where is "unknown prompt" coming from
    ]

    DEBUG TRACE TODO check for running ....
    "[sudo] password for q5: "       correct prompt 
    ""                                                     unknown prompt 
    

    I have been relatively happy with passing "system" commands and running QProcess. I can live with QProcess blocking the main app flow.
    Now I need to figure a way to pass "sudo" command and interactively set the correct password.
    In other words - I cannot wait for QProcess to finish because it won't even start without a password.
    I was thinking to send "sudo su" command first, but I have no clue how to "intercept "the response and then input the password .
    I am looking for a sample code on how to setup for the command response.
    What "event" am I looking for ? Simple "while" ( for what ?) would be silly in event driven QT.

    And no, I do not want to disable password in OS settings.

    ADDENDUM
    I think the answer is in QProcess "wait for finish ".

    MORE ADD
    This is what sudo man say about -S option

    -S, --stdin
    Write the prompt to the standard error and read the
    password from the standard input instead of using the
    terminal device.

    BUT this

       BTUL->ProcessCommand_Ext(
                       "sudo -S ",
                       ui->listWidget_27,
                       ui->listWidget_29,
                       ui->listWidget_28,
                       0xF);
    

    brings up "sudo :help", but "sudo _S -v " works with QProcess taking time.

    PS
    I know this has very little to do with QT, so do not crucify me...

    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