In Linux how to add a build step in Qt Creator that uses su privileges without getting the wrong password attempts on builds?

后端 未结 4 1720
故里飘歌
故里飘歌 2021-01-02 20:36

My goal is to successfully link a folder to /opt/ directory- which needs to be run with sudo.

I have tried this:

 system(sudo ln -s $$OUT_PWD/xampp /         


        
4条回答
  •  生来不讨喜
    2021-01-02 21:04

    After a lot of research:

    ssh-askpass Sudo Password | sudo -S bash ./script
    

    Worked like a charm, it asks for the password in a separate window/prompt box. I added it under custom build steps. The important thing is to let sudo know that it will expect a password input via -S option.

    echo "password" | sudo -S bash ./script
    

    Also works with bash scripts, however as you might think it is insecure storing the sudo password inside the script. It is said that read permissions should fix that issue.

提交回复
热议问题