问题
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