Xau(3)
β¨ Xau β the X authority database besties π
okay so this is Xau(3) from the Library Functions Manual, and it's literally the whole X authority database situation. XauFileName, XauReadAuth, XauLockAuth, XauUnlockAuth, XauWriteAuth, XauDisposeAuth, XauGetAuthByAddr, XauGetBestAuthByAddr β all of them, right here, no cap. π
πΈ SYNOPSIS πΈ
#include <X11/Xauth.h>
typedef struct xauth {
unsigned short family;
unsigned short address_length;
char *address;
unsigned short number_length;
char *number;
unsigned short name_length;
char *name;
unsigned short data_length;
char *data;
} Xauth;
char *XauFileName (void);
Xauth *XauReadAuth (FILE *auth_file);
int XauWriteAuth (FILE *auth_file, Xauth *auth);
Xauth *XauGetAuthByAddr (unsigned short family, unsigned short
address_length, const char *address, unsigned short
number_length, const char *number, unsigned short
name_length, const char *name);
Xauth *XauGetBestAuthByAddr (unsigned short family, unsigned short
address_length, const char *address, unsigned short
number_length, const char *number, int types_length,
char **types, const int *type_lengths);
int XauLockAuth (const char *file_name, int retries, int
timeout, long dead);
int XauUnlockAuth (const char *file_name);
int XauDisposeAuth (Xauth *auth);
π¦ DESCRIPTION π¦
π XauFileName
XauFileName figures out the default authorization file name for you, and it's giving very "I already know what you need" energy. First it checks the XAUTHORITY environment variable if it's set, and otherwise it hands you back $HOME/.Xauthority. π«Ά
bestie listen. this name is statically allocated and should not be freed. do NOT free it. put the free() down. π
π XauReadAuth
XauReadAuth reads the next entry from auth_file. The entry is not statically allocated, so when you're done with it you free it by calling XauDisposeAuth. every read needs its dispose, it's a whole matching set β¨
βοΈ XauWriteAuth
XauWriteAuth writes an authorization entry to auth_file. It returns 1 on success, 0 on failure. simple as that, icon behavior π
π XauGetAuthByAddr
XauGetAuthByAddr searches for an entry that matches the given network address/display number pair. and again β the entry is not statically allocated, so free it with XauDisposeAuth. same deal, no exceptions π
π XauGetBestAuthByAddr
XauGetBestAuthByAddr is basically XauGetAuthByAddr's more discerning older sister. the difference? you hand her a list of acceptable authentication methods, and Xau picks the file entry that matches the earliest entry in that list (so likeβ¦ the most secure authentication method, periodt π).
typesis an array of strings β one string for each authentication method.types_lengthtells it how many elements are in thetypesarray.types_lengthsis an array of integers representing the length of each string.
π XauLockAuth
XauLockAuth does the work necessary to synchronously update an authorization file. the way she does it:
- First she makes two file names β one with
-cappended tofile_name, and the other with-lappended. - If the
-cfile already exists and is more thandeadseconds old,XauLockAuthremoves it and the associated-lfile. - To prevent possible synchronization troubles with NFS, a
deadvalue of zero forces the files to be removed. π«£ XauLockAuthmakesretriesattempts to create and link the file names, pausingtimeoutseconds between each attempt.
XauLockAuth returns a collection of values depending on the results:
LOCK_ERRORβ a system error occurred, either afile_namethat's too long, or an unexpected failure from a system call.errnomay prove useful.LOCK_TIMEOUTβretriesattempts failed.LOCK_SUCCESSβ the lock succeeded. slay π₯
π XauUnlockAuth
XauUnlockAuth undoes the work of XauLockAuth by unlinking both the -c and -l file names. cleanup crew, we love to see it π§
ποΈ XauDisposeAuth
XauDisposeAuth frees storage allocated to hold an authorization entry. the little goodbye kiss at the end of every auth entry's life ππ
π SEE ALSO π
π AUTHOR π
Keith Packard, MIT X Consortium β the originator, the blueprint, main character energy fr fr π
and that's the whole page bestie!! this came to you from X Version 11, libXau 1.0.12, filed under Xau(3) β so go forth, lock your auth files, dispose your Xauth structs, and don't you dare free that statically allocated file name. ily, bye πβ¨ππ¦
π¦ where this page comes from
- alpine 3.22: libxau-doc 1.0.12-r0 Β· MIT
- alpine 3.23: libxau-doc 1.0.12-r0 Β· MIT
- alpine 3.24: libxau-doc 1.0.12-r0 Β· MIT
- arch rolling: libxau 1.0.12-1 Β· MIT-open-group
- fedora 43: libXau-devel 1.0.12-3.fc43 Β· MIT-open-group
- fedora 43: libXau-devel 1.0.12-3.fc43 Β· MIT-open-group
- fedora 44: libXau-devel 1.0.12-4.fc44 Β· MIT-open-group
- fedora 44: libXau-devel 1.0.12-4.fc44 Β· MIT-open-group
- nixos 26.05: libxau 1.0.12
- nixpkgs unstable: libxau 1.0.12
- opensuse-leap 16.0: libXau-devel 1.0.12-160000.2.2 Β· MIT
- opensuse-leap 16.0: libXau-devel 1.0.12-160000.2.2 Β· MIT
- opensuse-leap 16.0: libXau-devel 1.0.12-160000.2.2 Β· MIT
- opensuse-leap 16.0: libXau-devel 1.0.12-160000.2.2 Β· MIT
- Copyright (c) 1994 X Consortium
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms