为什么 root 可以访问我的 x 服务器?

idl*_*n89 1 linux xorg debian

我在我的机器上运行 Debian 9.5,当我运行命令时,xhost有以下输出:

access control enabled, only authorized clients can connect
SI:localuser:username
Run Code Online (Sandbox Code Playgroud)

因此,在我的理解中,不应该允许 root 访问 x-server,但是当我切换到 rootsu并从终端运行 GUI 应用程序时,一切都运行良好,尽管不应该。

那么有人可以解释为什么我的 x-server 忽略访问控制列表中的条目吗?

mur*_*uru 8

如果您su以前切换到 root,则XAUTHORITY环境变量在由su. 由于 root 可以读取您的文件,因此它可以访问 Xauthority 文件。在我的系统上:

root@host# medit   
Run Code Online (Sandbox Code Playgroud)

开始正常,而清空XAUTHORITY会导致它失败:

root@host# XAUTHORITY= medit
No protocol specified

(medit:25388): Gtk-WARNING **: 12:35:31.963: cannot open display: :1
Run Code Online (Sandbox Code Playgroud)