I use Eclipse as my IDE, and when I run my application I wish the application itself to run as root. My program currently checks if it is root, and if not it restarts itself with gksudo
. The output, however, isn't written to the console. I can't use sudo
, since it doesn't give me a graphical prompt. (While my program is CLI, Eclipse doesn't permit console interaction afaict)
我使用Eclipse作为我的IDE,当我运行应用程序时,我希望应用程序本身作为根用户运行。我的程序现在检查它是否为根,如果不是,它会重新启动gksudo。然而,输出并没有写到控制台。我不能使用sudo,因为它没有图形提示符。(虽然我的程序是CLI, Eclipse不允许控制台交互afaict)
What's the "right" way to be elevating my application?
提升我的应用程序的“正确”方法是什么?
3 个解决方案
#1
2
Restrictive execution dominates. I believe that Eclipse does permit console interaction, but a quick and dirty, brute force approach would be to use suid if you're not concerned about security. Or throw up your own graphical prompt in Tkinter/other and use a bit of Expect magic to spawn and respond to the sudo process. Careful with these, however :)
严格执行占主导地位。我相信Eclipse确实允许控制台交互,但是如果您不关心安全性,那么使用suid将是一种快速而笨拙的蛮力方法。或者在Tkinter/other中抛出您自己的图形提示符,并使用一些Expect魔术来生成和响应sudo进程。不过,要注意以下几点:
#2
3
It may not be an ideal solution, but the rare times that I need this same functionality I end up just running Eclipse as root.
这可能不是一个理想的解决方案,但是我很少需要这样的功能,我只是将Eclipse作为根运行。
#3
0
You might need to create a runner with external tools pointing to '/sur/bin/sudo' and pointing to variable ${resource_loc} Run -> External tools -> External Tools Configuration The below link will guide you on creating a external runner,
您可能需要创建一个运行器,外部工具指向'/sur/bin/sudo'并指向变量${resource_loc} Run ->外部工具->外部工具配置下面的链接将指导您创建一个外部运行器,
http://help.eclipse.org/mars/index.jsp?topic=%2forg.eclipse.platform.doc.user%2fgettingstarted%2fqs - 97 _standalone_ets.htm
To run, Click on the main python file Run -> External tools -> {choose your runner}
要运行,点击主python文件运行->外部工具->{选择你的跑步者}
This will serve your purpose.
这将符合你的目的。
#1
2
Restrictive execution dominates. I believe that Eclipse does permit console interaction, but a quick and dirty, brute force approach would be to use suid if you're not concerned about security. Or throw up your own graphical prompt in Tkinter/other and use a bit of Expect magic to spawn and respond to the sudo process. Careful with these, however :)
严格执行占主导地位。我相信Eclipse确实允许控制台交互,但是如果您不关心安全性,那么使用suid将是一种快速而笨拙的蛮力方法。或者在Tkinter/other中抛出您自己的图形提示符,并使用一些Expect魔术来生成和响应sudo进程。不过,要注意以下几点:
#2
3
It may not be an ideal solution, but the rare times that I need this same functionality I end up just running Eclipse as root.
这可能不是一个理想的解决方案,但是我很少需要这样的功能,我只是将Eclipse作为根运行。
#3
0
You might need to create a runner with external tools pointing to '/sur/bin/sudo' and pointing to variable ${resource_loc} Run -> External tools -> External Tools Configuration The below link will guide you on creating a external runner,
您可能需要创建一个运行器,外部工具指向'/sur/bin/sudo'并指向变量${resource_loc} Run ->外部工具->外部工具配置下面的链接将指导您创建一个外部运行器,
http://help.eclipse.org/mars/index.jsp?topic=%2forg.eclipse.platform.doc.user%2fgettingstarted%2fqs - 97 _standalone_ets.htm
To run, Click on the main python file Run -> External tools -> {choose your runner}
要运行,点击主python文件运行->外部工具->{选择你的跑步者}
This will serve your purpose.
这将符合你的目的。