首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >什么是xhost和xhost +si?

什么是xhost和xhost +si?
EN

Ask Ubuntu用户
提问于 2017-01-30 08:04:47
回答 1查看 30.2K关注 0票数 18

这个剧本在做什么?

代码语言:javascript
运行
复制
#!/bin/bash
xhost +local:
xhost +si:localuser:root

xhost的默认列表是什么?

EN

回答 1

Ask Ubuntu用户

发布于 2017-01-30 08:31:05

xhost +SI:localuser:root允许root用户访问正在运行的X服务器。当前的X服务器由DISPLAY环境变量指示。xhost +local:对每个用户都这样做,因此root行没有多大用处。

命令页有相当好的解释:

代码语言:javascript
运行
复制
   [+]name The given name (the plus sign is optional) is added to the list
           allowed to connect to the X server.  The name  can  be  a  host
           name or a complete name (See NAMES for more details).
...
NAMES
   A complete name has the syntax ``family:name'' where the  families  are
   as follows:
...
   local     contains only one name, the empty string
   si        Server Interpreted
...
   The  local family specifies all the local connections at once. However,
   the server interpreted address "si:localuser:username" can be  used  to
   specify a single local user. (See the Xsecurity(7) manual page for more
   details.)

Xsecurity命令页说:

代码语言:javascript
运行
复制
SERVER INTERPRETED ACCESS TYPES
   The  sample  implementation   includes   several   Server   Interpreted
   mechanisms:
       IPv6                          IPv6 literal addresses
       hostname                      Network host name
       localuser                     Local connection user id
       localgroup                    Local connection group id

有一点上下文:有两种常用的方式允许访问X服务器。一种是通过Xauthority文件,该文件由客户端共享,不需要进一步的服务器端配置。另一个是通过xhost列表,配置是在运行时在服务器上完成的(所以这不是一个永久的更改)。

因此,localuser是一个需要保留的关键字(root是这里的用户名)。这有点像添加到组中,因为组在服务器对授权的理解中。但是,不影响系统组或用户。只更改X服务器的运行时配置。

在没有参数的情况下运行xhost的默认行为是打印列表,如手册中所述:

代码语言:javascript
运行
复制
nothing If no command line arguments are given,  a  message  indicating
        whether  or not access control is currently enabled is printed,
        followed by the list of those allowed to connect.  

例如:

代码语言:javascript
运行
复制
$ xhost
access control enabled, only authorized clients can connect
SI:localuser:muru

(muru是我的用户名。)

(来自我在Unix & Linux上的文章)

票数 24
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/877820

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档