Where does xhost store the allowed network addresses?
3 Answers
xhost
simply calls XAddHost
etc., which manipulates a list held by the server. See xhost/xhost.c
for the client-side and xserver/os/access.c
for the server-side.
You really should try to use xauth
instead of xhost
if possible. It keeps a list of permissible keys which can be used on a per-user, per-client basis instead of relying on just hostname (spoofable in an unfriendly environment).

- 198,619
- 38
- 280
- 391
I think the addresses are stored inside the xserver.
xhost
without any arguments should print out the current allowed list.

- 52,368
- 9
- 94
- 137
-
It does not print out a list of authorized hostnames on my Mac Big Sur, – Fred Zimmerman Apr 10 '21 at 00:40
-
Yes, it prints the list. But where does it store it? Memory only, no files? – Dan Jacobson Jul 22 '23 at 14:01
$ man xhost | grep -A 2 FILES
FILES
/etc/X*.hosts
So, I'd take a look in /etc for a file matching that pattern.
The more general lesson here: many commands that use certain files during their operation, will document these files on their manual pages. So, it's a good idea when one wonders something like this, to check the manual. The FILES section is often at the bottom, so a quick "man whatever" followed by ">" (less
command to go to the end of the file) will often reveal what you're looking for.

- 391,730
- 64
- 469
- 606
-
2None of those files exist on my system - but I think xhost would still work. – Douglas Leeder Mar 27 '09 at 09:54
-
I got the message "non-network local connections being added to access control list" but there is no /etc/X*.hosts. Therefore I conclude the mystery remains. – Dan Jacobson Jul 22 '23 at 13:56