XAddHost(3)
π XAddHost(3) β the Xlib host-access-control era π
okay so this is one of those XLIB FUNCTIONS pages, bestie. welcome to the whole who's allowed to connect to my X server situation. it's giving gatekeeping, but make it networking β¨
πΈ NAME πΈ
XAddHost, XAddHosts, XListHosts, XRemoveHost, XRemoveHosts, XSetAccessControl, XEnableAccessControl, XDisableAccessControl, XHostAddress, XServerInterpretedAddress β literally the whole girlboss squad for controlling host access and the host control structure π«Ά
β¨ SYNTAX β¨
like, here's every single one of them, verbatim, no cap:
int XAddHost(Display *display, XHostAddress *host);
int XAddHosts(Display *display, XHostAddress *hosts, int num_hosts);
XHostAddress *XListHosts(Display *display, int *nhosts_return, Bool
*state_return);
int XRemoveHost(Display *display, XHostAddress *host);
int XRemoveHosts(Display *display, XHostAddress *hosts, int num_hosts);
int XSetAccessControl(Display *display, int mode);
int XEnableAccessControl(Display *display);
int XDisableAccessControl(Display *display);
π¦ ARGUMENTS π¦
displayβ your connection to the X server. the main character of literally every Xlib call πhostβ the specific host getting added or removed. one (1) host, periodt.hostsβ each host that's getting added or removed. likehostbut a whole group chat.modeβ the mode, bestie. you can passEnableAccessorDisableAccess. those are the only two vibes allowed here.nhosts_returnβ returns the number of hosts currently chillin' in the access control list πnum_hostsβ specifies the number of hosts. yes, it's a count. yes, it matters.state_returnβ returns the state of the access control π
π DESCRIPTION π
okay so buckle up, because there's like eight functions here and each one has lore.
π§ XAddHost
XAddHost adds the specified host to the access control list for that display. the glow-up moment for a new machine β¨
but β the server must be on the same host as the client issuing the command, or a BadAccess error results. so like, no remote shenanigans, iykyk.
XAddHost can generate BadAccess and BadValue errors.
π§ XAddHosts
XAddHosts adds each specified host to the access control list for that display. group project energy.
same rule though: the server must be on the same host as the client issuing the command, or a BadAccess error results.
XAddHosts can generate BadAccess and BadValue errors.
π§ XListHosts
XListHosts returns the current access control list, plus whether the use of the list at connection setup was enabled or disabled. so it's literally the "who's on the list and are we even enforcing it" function π
XListHosts allows a program to find out what machines can make connections. it also returns a pointer to a list of host structures that were allocated by the function. when no longer needed, this memory should be freed by calling XFree β yes bestie, you have to free it, this is C, we don't do vibes-based memory management π
π§ XRemoveHost
XRemoveHost removes the specified host from the access control list for that display.
the server must be on the same host as the client process, or a BadAccess error results.
β οΈ bestie this is the scary one: if you remove your machine from the access list, you can no longer connect to that server, and this operation cannot be reversed unless you reset the server. you literally delete your own access. main character energy gone wrong π
XRemoveHost can generate BadAccess and BadValue errors.
π§ XRemoveHosts
XRemoveHosts removes each specified host from the access control list for that display.
the X server must be on the same host as the client process, or a BadAccess error results.
β οΈ same warning, same drama: if you remove your machine from the access list, you can no longer connect to that server, and this operation cannot be reversed unless you reset the server. blocklist yourself at your own risk π
XRemoveHosts can generate BadAccess and BadValue errors.
π§ XSetAccessControl
XSetAccessControl either enables or disables the use of the access control list at each connection setup. one function, two moods.
XSetAccessControl can generate BadAccess and BadValue errors.
π§ XEnableAccessControl
XEnableAccessControl enables the use of the access control list at each connection setup. it's the on switch π₯
XEnableAccessControl can generate a BadAccess error.
π§ XDisableAccessControl
XDisableAccessControl disables the use of the access control list at each connection setup. it's the off switch. (lowkey the chaotic option but okay πΈ)
XDisableAccessControl can generate a BadAccess error.
π STRUCTURES π
the XHostAddress struct
it contains:
typedef struct {
int family; /* for example FamilyInternet */
int length; /* length of address, in bytes */
char *address; /* pointer to where to find the address */
} XHostAddress;
so like, the run-down:
- the
familymember specifies which protocol address family to use (for example, TCP/IP or DECnet) and can beFamilyInternet,FamilyInternet6,FamilyServerInterpreted,FamilyDECnet, orFamilyChaosπ - the
lengthmember specifies the length of the address in bytes. - the
addressmember specifies a pointer to the address.
the XServerInterpretedAddress struct
for the ServerInterpreted family, the length is ignored and the address member is a pointer to a XServerInterpretedAddress structure, which contains:
typedef struct {
int typelength; /* length of type string, in bytes */
int valuelength; /* length of value string, in bytes */
char *type; /* pointer to where to find the type string */
char *value; /* pointer to where to find the address */
} XServerInterpretedAddress;
the type and value members point to strings representing the type and value of the server interpreted entry.
β οΈ heads up: these strings may not beNULL-terminated, so care should be used when accessing them. fr fr, don't justprintfthese and pray π
the typelength and valuelength members specify the length in bytes of the type and value strings. (the page says "in byte" but you know what she means π
)
π DIAGNOSTICS π
BadAccessβ a client attempted to modify the access control list from other than the local (or otherwise authorized) host. like, read the room, you're not on the list.BadValueβ some numeric value falls outside the range of values accepted by the request. unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. any argument defined as a set of alternatives can generate this error. so basically: numbers out here wildin' β¨
π SEE ALSO π
XFree(3)Xlib - C Language X Interface
and that's the whole page, bestie π«Ά go forth and manage your host access list responsibly. this tea was served fresh from X Version 11, libX11 1.8.14, and the XAddHost(3) page itself β slay π
β¨
π¦ where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- Copyright (c) 2004, Oracle and/or its affiliates
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms