简体   繁体   English

非root执行命令

[英]Executing command non root

I have a script which is being run as root. 我有一个以root身份运行的脚本。 Part of this script calls pythons webbrowser.open . 该脚本的一部分称为pythons webbrowser.open

Currently when webbrowser.open is executed it will attempt to open the browser but using the scripts root/sudo user. 当前,当执行webbrowser.open时,它将尝试使用脚本root/sudo用户打开浏览器。

Is there a way to open the script but as the current user and not root? 有没有办法以当前用户身份而不是以root用户身份打开脚本?

Maybe you should downgrade the privileges of your script, using 也许您应该使用以下命令降级脚本的特权

import os
os.setuid(1000)

Have a look to all other tools, like seteuid() and setgid() here : http://docs.python.org/2/library/os.html 在这里查看所有其他工具,例如seteuid()和setgid(): http ://docs.python.org/2/library/os.html

Cheers, 干杯,

K. K.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM