1Xau(3) Library Functions Manual Xau(3)
2
3
4
6 Xau library: XauFileName, XauReadAuth, XauLockAuth, XauUnlockAuth,
7 XauWriteAuth, XauDisposeAuth, XauGetAuthByAddr, XauGetBestAuthByAddr -
8 X authority database routines
9
11 #include <X11/Xauth.h>
12
13 typedef struct xauth {
14 unsigned short family;
15 unsigned short address_length;
16 char *address;
17 unsigned short number_length;
18 char *number;
19 unsigned short name_length;
20 char *name;
21 unsigned short data_length;
22 char *data;
23 } Xauth;
24
25 char *XauFileName (void);
26
27 Xauth *XauReadAuth (FILE *auth_file);
28
29 int XauWriteAuth (FILE *auth_file, Xauth *auth);
30
31 Xauth *XauGetAuthByAddr (unsigned short family, unsigned short
32 address_length, const char *address, unsigned short
33 number_length, const char *number, unsigned short
34 name_length, const char *name);
35
36 Xauth *XauGetBestAuthByAddr (unsigned short family, unsigned short
37 address_length, const char *address, unsigned short
38 number_length, const char *number, int types_length,
39 char **types, const int *type_lengths);
40
41 int XauLockAuth (const char *file_name, int retries, int
42 timeout, long dead);
43
44 int XauUnlockAuth (const char *file_name);
45
46 int XauDisposeAuth (Xauth *auth);
47
49 XauFileName generates the default authorization file name by first
50 checking the XAUTHORITY environment variable if set, else it returns
51 $HOME/.Xauthority. This name is statically allocated and should not be
52 freed.
53
54 XauReadAuth reads the next entry from auth_file. The entry is not
55 statically allocated and should be freed by calling XauDisposeAuth.
56
57 XauWriteAuth writes an authorization entry to auth_file. It returns 1
58 on success, 0 on failure.
59
60 XauGetAuthByAddr searches for an entry which matches the given network
61 address/display number pair. The entry is not statically allocated and
62 should be freed by calling XauDisposeAuth.
63
64 XauGetBestAuthByAddr is similar to XauGetAuthByAddr, except that a list
65 of acceptable authentication methods is specified. Xau will choose the
66 file entry which matches the earliest entry in this list (e.g., the
67 most secure authentication method). The types argument is an array of
68 strings, one string for each authentication method. types_length spec‐
69 ifies how many elements are in the types array. types_lengths is an
70 array of integers representing the length of each string.
71
72 XauLockAuth does the work necessary to synchronously update an autho‐
73 rization file. First it makes two file names, one with ``-c'' appended
74 to file_name, the other with ``-l'' appended. If the ``-c'' file al‐
75 ready exists and is more than dead seconds old, XauLockAuth removes it
76 and the associated ``-l'' file. To prevent possible synchronization
77 troubles with NFS, a dead value of zero forces the files to be removed.
78 XauLockAuth makes retries attempts to create and link the file names,
79 pausing timeout seconds between each attempt. XauLockAuth returns a
80 collection of values depending on the results:
81
82 LOCK_ERROR
83 A system error occurred, either a file_name which is too long,
84 or an unexpected failure from a system call. errno may prove
85 useful.
86
87 LOCK_TIMEOUT
88 retries attempts failed
89
90 LOCK_SUCCESS
91 The lock succeeded.
92
93 XauUnlockAuth undoes the work of XauLockAuth by unlinking both the
94 ``-c'' and ``-l'' file names.
95
96 XauDisposeAuth frees storage allocated to hold an authorization entry.
97
99 xauth(1), xdm(1)
100
102 Keith Packard, MIT X Consortium
103
104
105
106X Version 11 libXau 1.0.11 Xau(3)