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)
{
XAuthority *x_authority_new_cookie (guint16 family, const guint8 *address, gsize address_length, const gchar *number);
+XAuthority *x_authority_new_local_cookie (const gchar *number);
+
void x_authority_set_family (XAuthority *auth, guint16 family);
guint16 x_authority_get_family (XAuthority *auth);
#include <config.h>
#include <string.h>
#include <fcntl.h>
-#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <glib/gstdio.h>
x_server_local_new (void)
{
XServerLocal *self;
- gchar hostname[1024], *number, *name;
+ gchar *number, *name;
XAuthority *cookie;
self = g_object_new (X_SERVER_LOCAL_TYPE, NULL);
x_server_set_display_number (X_SERVER (self), x_server_local_get_unused_display_number ());
- gethostname (hostname, 1024);
number = g_strdup_printf ("%d", x_server_get_display_number (X_SERVER (self)));
- cookie = x_authority_new_cookie (XAUTH_FAMILY_LOCAL, (guint8*) hostname, strlen (hostname), number);
+ cookie = x_authority_new_local_cookie (number);
x_server_set_authority (X_SERVER (self), cookie);
g_free (number);
g_object_unref (cookie);
#include <config.h>
#include <string.h>
#include <fcntl.h>
-#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <glib/gstdio.h>
gboolean result, backup_logs;
gchar *filename, *run_dir, *dir, *log_file, *absolute_command;
GString *command;
- gchar hostname[1024], *number;
+ gchar *number;
GError *error = NULL;
g_return_val_if_fail (server->priv->x_server_process == NULL, FALSE);
return FALSE;
}
- gethostname (hostname, 1024);
number = g_strdup_printf ("%d", x_server_get_display_number (X_SERVER (server)));
- authority = x_authority_new_cookie (XAUTH_FAMILY_LOCAL, (guint8*) hostname, strlen (hostname), number);
+ authority = x_authority_new_local_cookie (number);
x_server_set_authority (X_SERVER (server), authority);