NAME

Xau library: XauFileName, XauReadAuth, XauLockAuth, XauUnlockAuth, XauWriteAuth, XauDisposeAuth, XauGetAuthByAddr, XauGetBestAuthByAddr - X authority database routines

SYNOPSIS

#include


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 *_a_u_t_h___f_i_l_e); int XauWriteAuth (FILE *_a_u_t_h___f_i_l_e, Xauth *_a_u_t_h); Xauth *XauGetAuthByAddr (unsigned short _f_a_m_i_l_y, unsigned short _a_d_d_r_e_s_s___l_e_n_g_t_h, char *_a_d_d_r_e_s_s, unsigned short _n_u_m_b_e_r___l_e_n_g_t_h, char *_n_u_m_b_e_r); Xauth *XauGetBestAuthByAddr (unsigned short _f_a_m_i_l_y, unsigned short _a_d_d_r_e_s_s___l_e_n_g_t_h, char *_a_d_d_r_e_s_s, unsigned short _n_u_m_b_e_r___l_e_n_g_t_h, char *_n_u_m_b_e_r, int _t_y_p_e_s___l_e_n_g_t_h, char **_t_y_p_e_s, int *_t_y_p_e___l_e_n_g_t_h_s); int XauLockAuth (char *_f_i_l_e___n_a_m_e, int _r_e_t_r_i_e_s, int _t_i_m_e_o_u_t, long _d_e_a_d); int XauUnlockAuth (char *_f_i_l_e___n_a_m_e); int XauDisposeAuth (Xauth *_a_u_t_h);

DESCRIPTION

XXaauuFFiilleeNNaammee generates the default authorization file name by first checking the XAUTHORITY environment variable if set, else it returns $HOME/.Xauthority. This name is statically allocated and should not be freed.

XXaauuRReeaaddAAuutthh reads the next entry from _a_u_t_h___f_i_l_e. The entry is nnoott statically allocated and should be freed by calling _X_a_u_D_i_s_p_o_s_e_A_u_t_h.

XXaauuWWrriitteeAAuutthh writes an authorization entry to _a_u_t_h___f_i_l_e. It returns 1 on success, 0 on failure.

XXaauuGGeettAAuutthhBByyAAddddrr searches for an entry which matches the given network address/display number pair. The entry is nnoott statically allocated and should be freed by calling _X_a_u_D_i_s_p_o_s_e_A_u_t_h.

XXaauuGGeettBBeessttAAuutthhBByyAAddddrr is similar to XXaauuGGeettAAuutthhBByyAAddddrr, except that a list of acceptable authentication methods is specified. Xau will choose the file entry which matches the earliest entry in this list (e.g., the most secure authentication method). The _t_y_p_e_s argument is an array of strings, one string for each authentication method. _t_y_p_e_s___l_e_n_g_t_h specifies how many elements are in the _t_y_p_e_s array. _t_y_p_e_s___l_e_n_g_t_h_s is an array of integers representing the length of each string.

XXaauuLLoocckkAAuutthh does the work necessary to synchronously update an authorization file. First it makes two file names, one with ``-c'' appended to _f_i_l_e___n_a_m_e, the other with ``-l'' appended. If the ``-c'' file already exists and is more than _d_e_a_d seconds old, _X_a_u_L_o_c_k_A_u_t_h removes it and the associated ``-l'' file. To prevent possible synchronization troubles with NFS, a _d_e_a_d value of zero forces the files to be removed. _X_a_u_L_o_c_k_A_u_t_h makes _r_e_t_r_i_e_s attempts to create and link the file names, pausing _t_i_m_e_o_u_t seconds between each attempt. _X_a_u_L_o_c_k_A_u_t_h returns a collection of values depending on the results:


     

LOCK_ERROR A system error occurred, either a file_name which is too long, or an unexpected failure from a system call. errno may prove useful.

LOCK_TIMEOUT _r_e_t_r_i_e_s attempts failed

LOCK_SUCCESS The lock succeeded.

XXaauuUUnnlloocckkAAuutthh undoes the work of _X_a_u_L_o_c_k_A_u_t_h by unlinking both the ``-c'' and ``-l'' file names.

XXaauuDDiissppoosseeAAuutthh frees storage allocated to hold an authorization entry.

SEE ALSO

xauth(1), xdm(1)

AUTHOR

Keith Packard, MIT X Consortium