If I execute print os.environ
without pkexec I get lots of useful system environment variables, however, once I execute with, most of them are gone. How can I get them back with using pkexec? I understand there's a workaround using sudo but haven't found one yet for pkexec
答案 0 :(得分:3)
pkexec
man page:
将运行PROGRAM的环境设置为最小的已知和安全环境,以避免通过LD_LIBRARY_PATH或类似机制注入代码。此外,PKEXEC_UID环境变量设置为调用pkexec的进程的用户标识。
您可以pkexec
使用$DISPLAY
注释保留一些环境变量(即允许X11程序通过保留$XAUTHORITY
和org.freedesktop.policykit.exec.allow_gui
来工作)。但是,保留所有环境变量似乎是故意拒绝的决定。