Python - escalate privileges while running

不问归期 提交于 2019-12-11 14:24:08

问题


I'm writing a small extendable server management console, and I'd like to run it as a separate user that is really limited in actions - for security, of course, actually, I see no better way to do this. When somebody enters that console and tries to make some action that requires root privileges, such as putting network interface down, he'd be asked for a sudo password to do so, then this password would be used for the system to check if user has right to sudo, then - to execute the command. I've found one solution:

import os
os.popen("sudo -S somecommand", 'w').write("mypassword")

But it doesn't really seem like a Pythonic way... Or is it?

Also, in technical English, is there any difference between "elevating" and "escalating" privileges?

来源:https://stackoverflow.com/questions/20969320/python-escalate-privileges-while-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!