Back to index

lightdm  1.3.2
Classes | Typedefs | Enumerations | Functions
x-authority.h File Reference
#include <glib-object.h>
#include <gio/gio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  XAuthority
struct  XAuthorityClass
struct  XAuthorityRecord
struct  XAuthorityRecordClass

Typedefs

typedef struct XAuthorityPrivate
typedef struct XAuthorityRecordPrivate

Enumerations

enum  {
  XAUTH_FAMILY_INTERNET = 0, XAUTH_FAMILY_DECNET = 1, XAUTH_FAMILY_CHAOS = 2, XAUTH_FAMILY_SERVER_INTERPRETED = 5,
  XAUTH_FAMILY_INTERNET6 = 6, XAUTH_FAMILY_LOCALHOST = 252, XAUTH_FAMILY_KRB5_PRINCIPAL = 253, XAUTH_FAMILY_NETNAME = 254,
  XAUTH_FAMILY_LOCAL = 256, XAUTH_FAMILY_WILD = 65535
}

Functions

GType x_authority_get_type (void)
GType x_authority_record_get_type (void)
XAuthorityx_authority_new (void)
gboolean x_authority_load (XAuthority *authority, const gchar *filename, GError **error)
XAuthorityRecordx_authority_match_local (XAuthority *authority, const gchar *authorization_name)
XAuthorityRecordx_authority_match_localhost (XAuthority *authority, const gchar *authorization_name)
XAuthorityRecordx_authority_match_inet (XAuthority *authority, GInetAddress *address, const gchar *authorization_name)
guint16 x_authority_record_get_authorization_data_length (XAuthorityRecord *record)
const guint8 * x_authority_record_get_authorization_data (XAuthorityRecord *record)
gboolean x_authority_record_check_cookie (XAuthorityRecord *record, const guint8 *cookie_data, guint16 cookie_data_length)

Class Documentation

struct XAuthority

Definition at line 25 of file xauthority.h.

Collaboration diagram for XAuthority:
Class Members
GObject parent_instance
GObjectClass parent_instance
XAuthorityPrivate * priv
struct XAuthorityClass

Definition at line 31 of file xauthority.h.

Class Members
GObjectClass parent_class
struct XAuthorityRecord

Definition at line 38 of file x-authority.h.

Collaboration diagram for XAuthorityRecord:
Class Members
GObjectClass parent_instance
XAuthorityRecordPrivate * priv
struct XAuthorityRecordClass

Definition at line 44 of file x-authority.h.

Class Members
GObjectClass parent_class

Typedef Documentation

typedef struct XAuthorityPrivate

Definition at line 23 of file x-authority.h.

typedef struct XAuthorityRecordPrivate

Definition at line 36 of file x-authority.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
XAUTH_FAMILY_INTERNET 
XAUTH_FAMILY_DECNET 
XAUTH_FAMILY_CHAOS 
XAUTH_FAMILY_SERVER_INTERPRETED 
XAUTH_FAMILY_INTERNET6 
XAUTH_FAMILY_LOCALHOST 
XAUTH_FAMILY_KRB5_PRINCIPAL 
XAUTH_FAMILY_NETNAME 
XAUTH_FAMILY_LOCAL 
XAUTH_FAMILY_WILD 

Definition at line 9 of file x-authority.h.


Function Documentation

GType x_authority_get_type ( void  )

Here is the caller graph for this function:

gboolean x_authority_load ( XAuthority authority,
const gchar *  filename,
GError **  error 
)

Definition at line 32 of file x-authority.c.

{
    guint8 *xauth_data;
    gsize xauth_length;
    gsize offset = 0;

    if (!g_file_get_contents (filename, (gchar **) &xauth_data, &xauth_length, error))
        return FALSE;

    while (offset < xauth_length)
    {
        XAuthorityRecord *record;
        guint16 length;

        record = g_object_new (x_authority_record_get_type (), NULL);
        record->priv->family = read_card16 (xauth_data, xauth_length, X_BYTE_ORDER_MSB, &offset);
        record->priv->address_length = read_card16 (xauth_data, xauth_length, X_BYTE_ORDER_MSB, &offset);
        record->priv->address = read_string8 (xauth_data, xauth_length, record->priv->address_length, &offset);
        length = read_card16 (xauth_data, xauth_length, X_BYTE_ORDER_MSB, &offset);
        record->priv->number = (gchar *) read_string8 (xauth_data, xauth_length, length, &offset);
        length = read_card16 (xauth_data, xauth_length, X_BYTE_ORDER_MSB, &offset);
        record->priv->authorization_name = (gchar *) read_string8 (xauth_data, xauth_length, length, &offset);
        record->priv->authorization_data_length = read_card16 (xauth_data, xauth_length, X_BYTE_ORDER_MSB, &offset);
        record->priv->authorization_data = read_string8 (xauth_data, xauth_length, record->priv->authorization_data_length, &offset);

        authority->priv->records = g_list_append (authority->priv->records, record);
    }

    return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

XAuthorityRecord* x_authority_match_inet ( XAuthority authority,
GInetAddress *  address,
const gchar *  authorization_name 
)

Definition at line 102 of file x-authority.c.

{
    GList *link;
    guint16 family;
    gssize address_data_length;
    const guint8 *address_data;

    switch (g_inet_address_get_family (address))
    {
    case G_SOCKET_FAMILY_IPV4:
        family = XAUTH_FAMILY_INTERNET;
        break;
    case G_SOCKET_FAMILY_IPV6:
        family = XAUTH_FAMILY_INTERNET6;
        break;
    default:
        return NULL;
    }

    address_data_length = g_inet_address_get_native_size (address);
    address_data = g_inet_address_to_bytes (address);
    for (link = authority->priv->records; link; link = link->next)
    {
        XAuthorityRecord *record = link->data;
        int i;
        gboolean matches = TRUE;

        if (strcmp (record->priv->authorization_name, authorization_name) != 0)
            continue;

        if (record->priv->family == XAUTH_FAMILY_WILD)
            return record;

        if (record->priv->family != family)
            continue;

        if (record->priv->address_length != address_data_length)
            continue;

        for (i = 0; i < address_data_length; i++)
        {
            if (address_data[i] != record->priv->address[i])
            {
                matches = FALSE;
                break;
            }
        }
        if (matches)
            return record;
    }

    return NULL;
}
XAuthorityRecord* x_authority_match_local ( XAuthority authority,
const gchar *  authorization_name 
)

Definition at line 64 of file x-authority.c.

{
    GList *link;

    for (link = authority->priv->records; link; link = link->next)
    {
        XAuthorityRecord *record = link->data;
      
        if (strcmp (record->priv->authorization_name, authorization_name) != 0)
            continue;
      
        if (record->priv->family == XAUTH_FAMILY_WILD || record->priv->family == XAUTH_FAMILY_LOCAL)
            return record;
    }

    return NULL;
}

Here is the caller graph for this function:

XAuthorityRecord* x_authority_match_localhost ( XAuthority authority,
const gchar *  authorization_name 
)

Definition at line 83 of file x-authority.c.

{
    GList *link;

    for (link = authority->priv->records; link; link = link->next)
    {
        XAuthorityRecord *record = link->data;
      
        if (strcmp (record->priv->authorization_name, authorization_name) != 0)
            continue;
      
        if (record->priv->family == XAUTH_FAMILY_WILD || record->priv->family == XAUTH_FAMILY_LOCALHOST)
            return record;
    }

    return NULL;
}

Here is the caller graph for this function:

Definition at line 26 of file x-authority.c.

{
    return g_object_new (x_authority_get_type (), NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean x_authority_record_check_cookie ( XAuthorityRecord record,
const guint8 *  cookie_data,
guint16  cookie_data_length 
)

Definition at line 190 of file x-authority.c.

{
    guint16 i;

    if (strcmp (record->priv->authorization_name, "MIT-MAGIC-COOKIE-1") != 0)
        return FALSE;
  
    if (cookie_data_length != record->priv->authorization_data_length)
        return FALSE;

    for (i = 0; i < cookie_data_length; i++)
        if (cookie_data[i] != record->priv->authorization_data[i])
            return FALSE;

    return TRUE;
}

Here is the caller graph for this function:

Definition at line 184 of file x-authority.c.

{
    return record->priv->authorization_data;
}

Definition at line 178 of file x-authority.c.

{
    return record->priv->authorization_data_length;
}
GType x_authority_record_get_type ( void  )

Here is the caller graph for this function: