
請幫我理解這行命令:
xhost +SI:localuser:lightdm
在參考這篇文章的答案並建議是否有更好的方法以及為什麼需要這樣做。我無法從手冊頁中獲得太多信息,因此我希望有一些更詳細的答案以使其變得簡單。 (我應該用我的用戶名替換 localuser 嗎?這是否類似於添加到群組中?我知道 + 是用於添加,但不明白 SI 或 si !)
另請說明如何將使用者新增至“允許建立連線的清單”以及這意味著什麼。另外,如何查看目前清單?
答案1
xhost +SI:localuser:lightdm
允許lightdm
使用者存取正在運行的 X 伺服器。目前的 X 伺服器由環境變數指示DISPLAY
。
這線上說明頁有相當好的解釋:
[+]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:
...
si Server Interpreted
...
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
線上說明頁說:
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
是一個要按原樣保留的關鍵字(lightdm
這裡是用戶名,LightDM 運行時使用的用戶名)。這有點像是添加到群組,因為群組是伺服器對授權的理解。但是,系統群組或使用者不會受到影響。僅更改 X 伺服器的運行時配置。
不帶參數運行時的預設行為xhost
是列印列表,如線上說明頁所述:
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.
例如:
$ xhost
access control enabled, only authorized clients can connect
SI:localuser:muru
我們可能需要檢查代碼來確定如何使用者被加入到列表中,以及 X 如何使用該列表。
這樣做的原因是使用gsettings
,它使用dbus
,而這通常需要運行一個 X 伺服器。然而,這不是必需的,你可以看到這個 AskUbuntu 答案。