如何启动具有根权限的QProcess? [英] How to launch a QProcess with root rights?

查看:1224
本文介绍了如何启动具有根权限的QProcess?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆