如何启动具有根权限的QProcess? [英] How to launch a QProcess with root rights?
问题描述
我需要从Qt程序启动gphoto2
.我这样做:
I need to launch gphoto2
from a Qt program. I do this:
QString gphotoProgram = "/usr/bin/gphoto2";
QStringList gphotoArguments;
gphotoArguments << "--capture-image";
QProcess *gphotoProcess = new QProcess(this);
gphotoProcess->start(gphotoProgram, gphotoArguments);
,但它永远不会以这种方式进入Running
状态,因为gphoto2
通常需要在命令行上启动管理员权限.
but it never enters the Running
state this way, as gphoto2
usually needs admin rights to be launched on command line.
如何以适当的权限启动QProcess
来使gphoto2
工作?
How can I start this QProcess
with proper rights to make gphoto2
working?
我想我希望用户不必输入密码,这意味着gksudo,kdesudo或任何其他图形解决方案对我来说不是有效的选择.
I precise that I would prefer the user to not have to enter a password, which means gksudo, kdesudo or any other graphical solution is not a valid option for me.
推荐答案
我强烈建议找到一种方法,以允许gphoto2在登录用户权限下运行.也许本文有一些有用的信息.
I would strongly recommend finding a way to allow gphoto2 to be run with the logged in user's permissions. Perhaps this article has some helpful info.
这篇关于如何启动具有根权限的QProcess?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!