/*
* Copyright (C) 2010-2011 Robert Ancell.
* Author: Robert Ancell <robert.ancell@canonical.com>
- *
+ *
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
/* Address of the X server (format dependent on family) */
guint8 *address;
gsize address_length;
-
+
/* Display number of X server */
gchar *number;
{
XAuthority *auth = g_object_new (X_AUTHORITY_TYPE, NULL);
- x_authority_set_family (auth, family);
+ x_authority_set_family (auth, family);
x_authority_set_address (auth, address, address_length);
x_authority_set_number (auth, number);
x_authority_set_authorization_name (auth, name);
{
guint8 cookie[16];
gint i;
-
+
for (i = 0; i < 16; i++)
cookie[i] = g_random_int () & 0xFF;
return x_authority_new (family, address, address_length, number, "MIT-MAGIC-COOKIE-1", cookie, 16);
}
+XAuthority *
+x_authority_new_local_cookie (const gchar *number)
+{
+ gchar hostname[1024];
+
+ gethostname (hostname, 1024);
+ return x_authority_new_cookie (XAUTH_FAMILY_LOCAL, (guint8 *) hostname, strlen (hostname), number);
+}
+
void
x_authority_set_family (XAuthority *auth, guint16 family)
{
if (data_length - *offset < length)
return FALSE;
-
+
*value = g_malloc0 (length + 1);
for (i = 0; i < length; i++)
(*value)[i] = data[*offset + i];
}
g_list_free (records);
+ fsync (output_fd);
close (output_fd);
if (!result)
}
return TRUE;
-}
+}
static void
x_authority_init (XAuthority *auth)
static void
x_authority_finalize (GObject *object)
{
- XAuthority *self;
-
- self = X_AUTHORITY (object);
+ XAuthority *self = X_AUTHORITY (object);
g_free (self->priv->address);
g_free (self->priv->number);
g_free (self->priv->authorization_name);
g_free (self->priv->authorization_data);
- G_OBJECT_CLASS (x_authority_parent_class)->finalize (object);
+ G_OBJECT_CLASS (x_authority_parent_class)->finalize (object);
}
static void