vnc-server.h \
vt.c \
vt.h \
- xauthority.c \
- xauthority.h \
+ x-authority.c \
+ x-authority.h \
+ x-server-local.c \
+ x-server-local.h \
+ x-server-remote.c \
+ x-server-remote.h \
+ x-server-xvnc.c \
+ x-server-xvnc.h \
+ x-server.c \
+ x-server.h \
xdmcp-protocol.c \
xdmcp-protocol.h \
xdmcp-server.c \
xdmcp-server.h \
xdmcp-session.c \
xdmcp-session.h \
- xdmcp-session-private.h \
- xserver-local.c \
- xserver-local.h \
- xserver-remote.c \
- xserver-remote.h \
- xserver-xvnc.c \
- xserver-xvnc.h \
- xserver.c \
- xserver.h
+ xdmcp-session-private.h
lightdm_CFLAGS = \
$(LIGHTDM_CFLAGS) \
#include "vnc-server.h"
#include "seat-xdmcp-session.h"
#include "seat-xvnc.h"
-#include "xserver.h"
+#include "x-server.h"
#include "process.h"
#include "session-child.h"
/* If running inside an X server use Xephyr for display */
if (getenv ("DISPLAY") && getuid () != 0)
{
- gchar *xserver_path;
+ gchar *x_server_path;
- xserver_path = g_find_program_in_path ("Xephyr");
- if (!xserver_path)
+ x_server_path = g_find_program_in_path ("Xephyr");
+ if (!x_server_path)
{
g_printerr ("Running inside an X server requires Xephyr to be installed but it cannot be found. Please install it or update your PATH environment variable.\n");
return EXIT_FAILURE;
}
- g_free (xserver_path);
+ g_free (x_server_path);
}
/* Make sure the system binary directory (where the greeters are installed) is in the path */
#include "seat-unity.h"
#include "configuration.h"
-#include "xserver-local.h"
+#include "x-server-local.h"
#include "mir-server.h"
#include "vt.h"
#include "plymouth.h"
static DisplayServer *
create_x_server (Seat *seat)
{
- XServerLocal *xserver;
+ XServerLocal *x_server;
const gchar *command = NULL, *layout = NULL, *config_file = NULL, *xdmcp_manager = NULL, *key_name = NULL;
gboolean allow_tcp;
gint port = 0;
g_debug ("Starting X server on Unity compositor");
- xserver = xserver_local_new ();
+ x_server = x_server_local_new ();
if (!SEAT_UNITY (seat)->priv->use_vt_switching)
{
id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id);
SEAT_UNITY (seat)->priv->next_id++;
- xserver_local_set_mir_id (xserver, id);
- xserver_local_set_mir_socket (xserver, SEAT_UNITY (seat)->priv->mir_socket_filename);
+ x_server_local_set_mir_id (x_server, id);
+ x_server_local_set_mir_socket (x_server, SEAT_UNITY (seat)->priv->mir_socket_filename);
g_free (id);
}
command = seat_get_string_property (seat, "xserver-command");
if (command)
- xserver_local_set_command (xserver, command);
+ x_server_local_set_command (x_server, command);
layout = seat_get_string_property (seat, "xserver-layout");
if (layout)
- xserver_local_set_layout (xserver, layout);
+ x_server_local_set_layout (x_server, layout);
config_file = seat_get_string_property (seat, "xserver-config");
if (config_file)
- xserver_local_set_config (xserver, config_file);
+ x_server_local_set_config (x_server, config_file);
allow_tcp = seat_get_boolean_property (seat, "xserver-allow-tcp");
- xserver_local_set_allow_tcp (xserver, allow_tcp);
+ x_server_local_set_allow_tcp (x_server, allow_tcp);
xdmcp_manager = seat_get_string_property (seat, "xdmcp-manager");
if (xdmcp_manager)
- xserver_local_set_xdmcp_server (xserver, xdmcp_manager);
+ x_server_local_set_xdmcp_server (x_server, xdmcp_manager);
port = seat_get_integer_property (seat, "xdmcp-port");
if (port > 0)
- xserver_local_set_xdmcp_port (xserver, port);
+ x_server_local_set_xdmcp_port (x_server, port);
key_name = seat_get_string_property (seat, "xdmcp-key");
if (key_name)
g_debug ("Key %s not defined", key_name);
if (key)
- xserver_local_set_xdmcp_key (xserver, key);
+ x_server_local_set_xdmcp_key (x_server, key);
g_free (key);
}
g_key_file_free (keys);
}
- return DISPLAY_SERVER (xserver);
+ return DISPLAY_SERVER (x_server);
}
static DisplayServer *
const gchar *id;
SEAT_UNITY (seat)->priv->active_display_server = g_object_ref (display_server);
- id = xserver_local_get_mir_id (XSERVER_LOCAL (display_server));
+ id = x_server_local_get_mir_id (X_SERVER_LOCAL (display_server));
g_debug ("Switching to Mir session %s", id);
write_message (SEAT_UNITY (seat), USC_MESSAGE_SET_ACTIVE_SESSION, (const guint8 *) id, strlen (id));
seat_unity_run_script (Seat *seat, DisplayServer *display_server, Process *script)
{
const gchar *path;
- XServerLocal *xserver;
+ XServerLocal *x_server;
- xserver = XSERVER_LOCAL (display_server);
- path = xserver_local_get_authority_file_path (xserver);
- process_set_env (script, "DISPLAY", xserver_get_address (XSERVER (xserver)));
+ x_server = X_SERVER_LOCAL (display_server);
+ path = x_server_local_get_authority_file_path (x_server);
+ process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
process_set_env (script, "XAUTHORITY", path);
SEAT_CLASS (seat_unity_parent_class)->run_script (seat, display_server, script);
#include <string.h>
#include "seat-xdmcp-session.h"
-#include "xserver-remote.h"
+#include "x-server-remote.h"
struct SeatXDMCPSessionPrivate
{
{
XAuthority *authority;
gchar *host;
- XServerRemote *xserver;
+ XServerRemote *x_server;
if (strcmp (session_type, "x") != 0)
{
authority = xdmcp_session_get_authority (SEAT_XDMCP_SESSION (seat)->priv->session);
host = g_inet_address_to_string (xdmcp_session_get_address (SEAT_XDMCP_SESSION (seat)->priv->session));
- xserver = xserver_remote_new (host, xdmcp_session_get_display_number (SEAT_XDMCP_SESSION (seat)->priv->session), authority);
+ x_server = x_server_remote_new (host, xdmcp_session_get_display_number (SEAT_XDMCP_SESSION (seat)->priv->session), authority);
g_free (host);
- return DISPLAY_SERVER (xserver);
+ return DISPLAY_SERVER (x_server);
}
static void
#include "seat-xlocal.h"
#include "configuration.h"
-#include "xserver-local.h"
+#include "x-server-local.h"
#include "mir-server.h"
#include "vt.h"
static DisplayServer *
create_x_server (Seat *seat)
{
- XServerLocal *xserver;
+ XServerLocal *x_server;
const gchar *command = NULL, *layout = NULL, *config_file = NULL, *xdmcp_manager = NULL, *key_name = NULL;
gboolean allow_tcp;
gint port = 0;
g_debug ("Starting local X display");
- xserver = xserver_local_new ();
+ x_server = x_server_local_new ();
/* If running inside an X server use Xephyr instead */
if (g_getenv ("DISPLAY"))
if (!command)
command = seat_get_string_property (seat, "xserver-command");
if (command)
- xserver_local_set_command (xserver, command);
+ x_server_local_set_command (x_server, command);
layout = seat_get_string_property (seat, "xserver-layout");
if (layout)
- xserver_local_set_layout (xserver, layout);
+ x_server_local_set_layout (x_server, layout);
config_file = seat_get_string_property (seat, "xserver-config");
if (config_file)
- xserver_local_set_config (xserver, config_file);
+ x_server_local_set_config (x_server, config_file);
allow_tcp = seat_get_boolean_property (seat, "xserver-allow-tcp");
- xserver_local_set_allow_tcp (xserver, allow_tcp);
+ x_server_local_set_allow_tcp (x_server, allow_tcp);
xdmcp_manager = seat_get_string_property (seat, "xdmcp-manager");
if (xdmcp_manager)
- xserver_local_set_xdmcp_server (xserver, xdmcp_manager);
+ x_server_local_set_xdmcp_server (x_server, xdmcp_manager);
port = seat_get_integer_property (seat, "xdmcp-port");
if (port > 0)
- xserver_local_set_xdmcp_port (xserver, port);
+ x_server_local_set_xdmcp_port (x_server, port);
key_name = seat_get_string_property (seat, "xdmcp-key");
if (key_name)
g_debug ("Key %s not defined", key_name);
if (key)
- xserver_local_set_xdmcp_key (xserver, key);
+ x_server_local_set_xdmcp_key (x_server, key);
g_free (key);
}
g_key_file_free (keys);
}
- return DISPLAY_SERVER (xserver);
+ return DISPLAY_SERVER (x_server);
}
static DisplayServer *
seat_xlocal_run_script (Seat *seat, DisplayServer *display_server, Process *script)
{
const gchar *path;
- XServerLocal *xserver;
+ XServerLocal *x_server;
- xserver = XSERVER_LOCAL (display_server);
- path = xserver_local_get_authority_file_path (xserver);
- process_set_env (script, "DISPLAY", xserver_get_address (XSERVER (xserver)));
+ x_server = X_SERVER_LOCAL (display_server);
+ path = x_server_local_get_authority_file_path (x_server);
+ process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
process_set_env (script, "XAUTHORITY", path);
SEAT_CLASS (seat_xlocal_parent_class)->run_script (seat, display_server, script);
#include "seat-xremote.h"
#include "configuration.h"
-#include "xserver-remote.h"
+#include "x-server-remote.h"
G_DEFINE_TYPE (SeatXRemote, seat_xremote, SEAT_TYPE);
static DisplayServer *
seat_xremote_create_display_server (Seat *seat, const gchar *session_type)
{
- XServerRemote *xserver;
+ XServerRemote *x_server;
const gchar *hostname;
gint number;
g_debug ("Starting remote X display %s:%d", hostname, number);
- xserver = xserver_remote_new (hostname, number, NULL);
+ x_server = x_server_remote_new (hostname, number, NULL);
- return DISPLAY_SERVER (xserver);
+ return DISPLAY_SERVER (x_server);
}
static Greeter *
static void
seat_xremote_run_script (Seat *seat, DisplayServer *display_server, Process *script)
{
- XServerRemote *xserver;
+ XServerRemote *x_server;
- xserver = XSERVER_REMOTE (display_server);
- process_set_env (script, "DISPLAY", xserver_get_address (XSERVER (xserver)));
- process_set_env (script, "REMOTE_HOST", xserver_get_hostname (XSERVER (xserver)));
+ x_server = X_SERVER_REMOTE (display_server);
+ process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
+ process_set_env (script, "REMOTE_HOST", x_server_get_hostname (X_SERVER (x_server)));
SEAT_CLASS (seat_xremote_parent_class)->run_script (seat, display_server, script);
}
#include <string.h>
#include "seat-xvnc.h"
-#include "xserver-xvnc.h"
+#include "x-server-xvnc.h"
#include "configuration.h"
G_DEFINE_TYPE (SeatXVNC, seat_xvnc, SEAT_TYPE);
static DisplayServer *
seat_xvnc_create_display_server (Seat *seat, const gchar *session_type)
{
- XServerXVNC *xserver;
+ XServerXVNC *x_server;
const gchar *command = NULL;
if (strcmp (session_type, "x") != 0)
return NULL;
}
- xserver = xserver_xvnc_new ();
- xserver_xvnc_set_socket (xserver, g_socket_get_fd (SEAT_XVNC (seat)->priv->connection));
+ x_server = x_server_xvnc_new ();
+ x_server_xvnc_set_socket (x_server, g_socket_get_fd (SEAT_XVNC (seat)->priv->connection));
command = config_get_string (config_get_instance (), "VNCServer", "command");
if (command)
- xserver_xvnc_set_command (xserver, command);
+ x_server_xvnc_set_command (x_server, command);
if (config_has_key (config_get_instance (), "VNCServer", "width") &&
config_has_key (config_get_instance (), "VNCServer", "height"))
width = config_get_integer (config_get_instance (), "VNCServer", "width");
height = config_get_integer (config_get_instance (), "VNCServer", "height");
if (height > 0 && width > 0)
- xserver_xvnc_set_geometry (xserver, width, height);
+ x_server_xvnc_set_geometry (x_server, width, height);
}
if (config_has_key (config_get_instance (), "VNCServer", "depth"))
{
gint depth;
depth = config_get_integer (config_get_instance (), "VNCServer", "depth");
if (depth == 8 || depth == 16 || depth == 24 || depth == 32)
- xserver_xvnc_set_depth (xserver, depth);
+ x_server_xvnc_set_depth (x_server, depth);
}
- return DISPLAY_SERVER (xserver);
+ return DISPLAY_SERVER (x_server);
}
static void
seat_xvnc_run_script (Seat *seat, DisplayServer *display_server, Process *script)
{
- XServerXVNC *xserver;
+ XServerXVNC *x_server;
GInetSocketAddress *address;
gchar *hostname;
const gchar *path;
- xserver = XSERVER_XVNC (display_server);
+ x_server = X_SERVER_XVNC (display_server);
address = G_INET_SOCKET_ADDRESS (g_socket_get_remote_address (SEAT_XVNC (seat)->priv->connection, NULL));
hostname = g_inet_address_to_string (g_inet_socket_address_get_address (address));
- path = xserver_xvnc_get_authority_file_path (xserver);
+ path = x_server_xvnc_get_authority_file_path (x_server);
process_set_env (script, "REMOTE_HOST", hostname);
- process_set_env (script, "DISPLAY", xserver_get_address (XSERVER (xserver)));
+ process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
process_set_env (script, "XAUTHORITY", path);
g_free (hostname);
#include "console-kit.h"
#include "login1.h"
#include "privileges.h"
-#include "xauthority.h"
+#include "x-authority.h"
#include "configuration.h"
/* Child process being run */
static XAuthority *
read_xauth (void)
{
- gchar *xauth_name;
- guint16 xauth_family;
- guint8 *xauth_address;
- gsize xauth_address_length;
- gchar *xauth_number;
- guint8 *xauth_data;
- gsize xauth_data_length;
-
- xauth_name = read_string ();
- if (!xauth_name)
+ gchar *x_authority_name;
+ guint16 x_authority_family;
+ guint8 *x_authority_address;
+ gsize x_authority_address_length;
+ gchar *x_authority_number;
+ guint8 *x_authority_data;
+ gsize x_authority_data_length;
+
+ x_authority_name = read_string ();
+ if (!x_authority_name)
return NULL;
- read_data (&xauth_family, sizeof (xauth_family));
- read_data (&xauth_address_length, sizeof (xauth_address_length));
- xauth_address = g_malloc (xauth_address_length);
- read_data (xauth_address, xauth_address_length);
- xauth_number = read_string ();
- read_data (&xauth_data_length, sizeof (xauth_data_length));
- xauth_data = g_malloc (xauth_data_length);
- read_data (xauth_data, xauth_data_length);
+ read_data (&x_authority_family, sizeof (x_authority_family));
+ read_data (&x_authority_address_length, sizeof (x_authority_address_length));
+ x_authority_address = g_malloc (x_authority_address_length);
+ read_data (x_authority_address, x_authority_address_length);
+ x_authority_number = read_string ();
+ read_data (&x_authority_data_length, sizeof (x_authority_data_length));
+ x_authority_data = g_malloc (x_authority_data_length);
+ read_data (x_authority_data, x_authority_data_length);
- return xauth_new (xauth_family, xauth_address, xauth_address_length, xauth_number, xauth_name, xauth_data, xauth_data_length);
+ return x_authority_new (x_authority_family, x_authority_address, x_authority_address_length, x_authority_number, x_authority_name, x_authority_data, x_authority_data_length);
}
int
gchar *tty;
gchar *remote_host_name;
gchar *xdisplay;
- XAuthority *xauthority = NULL;
- gchar *xauth_filename;
+ XAuthority *x_authority = NULL;
+ gchar *x_authority_filename;
GDBusConnection *bus;
gchar *console_kit_cookie = NULL;
gchar *login1_session = NULL;
tty = read_string ();
remote_host_name = read_string ();
xdisplay = read_string ();
- xauthority = read_xauth ();
+ x_authority = read_xauth ();
/* Setup PAM */
result = pam_start (service, username, &conversation, &pam_handle);
pam_set_item (pam_handle, PAM_TTY, tty);
#ifdef PAM_XAUTHDATA
- if (xauthority)
+ if (x_authority)
{
struct pam_xauth_data value;
- value.name = (char *) xauth_get_authorization_name (xauthority);
- value.namelen = strlen (xauth_get_authorization_name (xauthority));
- value.data = (char *) xauth_get_authorization_data (xauthority);
- value.datalen = xauth_get_authorization_data_length (xauthority);
+ value.name = (char *) x_authority_get_authorization_name (x_authority);
+ value.namelen = strlen (x_authority_get_authorization_name (x_authority));
+ value.data = (char *) x_authority_get_authorization_data (x_authority);
+ value.datalen = x_authority_get_authorization_data_length (x_authority);
pam_set_item (pam_handle, PAM_XAUTHDATA, &value);
}
#endif
g_free (tty);
tty = read_string ();
}
- xauth_filename = read_string ();
+ x_authority_filename = read_string ();
if (version >= 1)
{
g_free (xdisplay);
xdisplay = read_string ();
- if (xauthority)
- g_object_unref (xauthority);
- xauthority = read_xauth ();
+ if (x_authority)
+ g_object_unref (x_authority);
+ x_authority = read_xauth ();
}
read_data (&env_length, sizeof (env_length));
for (i = 0; i < env_length; i++)
}
/* Write X authority */
- if (xauthority)
+ if (x_authority)
{
gboolean drop_privileges, result;
gchar *value;
drop_privileges = geteuid () == 0;
if (drop_privileges)
privileges_drop (user);
- result = xauth_write (xauthority, XAUTH_WRITE_MODE_REPLACE, xauth_filename, &error);
+ result = x_authority_write (x_authority, XAUTH_WRITE_MODE_REPLACE, x_authority_filename, &error);
if (drop_privileges)
privileges_reclaim ();
if (!result)
return EXIT_FAILURE;
- value = g_strdup_printf ("XAUTHORITY=%s", xauth_filename);
+ value = g_strdup_printf ("XAUTHORITY=%s", x_authority_filename);
pam_putenv (pam_handle, value);
g_free (value);
}
}
/* Remove X authority */
- if (xauthority)
+ if (x_authority)
{
gboolean drop_privileges, result;
GError *error = NULL;
drop_privileges = geteuid () == 0;
if (drop_privileges)
privileges_drop (user);
- result = xauth_write (xauthority, XAUTH_WRITE_MODE_REMOVE, xauth_filename, &error);
+ result = x_authority_write (x_authority, XAUTH_WRITE_MODE_REMOVE, x_authority_filename, &error);
if (drop_privileges)
privileges_reclaim ();
/* X display connected to */
gchar *xdisplay;
- XAuthority *xauthority;
- gboolean xauth_use_system_location;
+ XAuthority *x_authority;
+ gboolean x_authority_use_system_location;
/* Remote host this session is being controlled from */
gchar *remote_host_name;
}
void
-session_set_xauthority (Session *session, XAuthority *authority, gboolean use_system_location)
+session_set_x_authority (Session *session, XAuthority *authority, gboolean use_system_location)
{
g_return_if_fail (session != NULL);
- if (session->priv->xauthority)
+ if (session->priv->x_authority)
{
- g_object_unref (session->priv->xauthority);
- session->priv->xauthority = NULL;
+ g_object_unref (session->priv->x_authority);
+ session->priv->x_authority = NULL;
}
if (authority)
- session->priv->xauthority = g_object_ref (authority);
- session->priv->xauth_use_system_location = use_system_location;
+ session->priv->x_authority = g_object_ref (authority);
+ session->priv->x_authority_use_system_location = use_system_location;
}
void
}
static void
-write_xauth (Session *session, XAuthority *xauthority)
+write_xauth (Session *session, XAuthority *x_authority)
{
guint16 family;
gsize length;
- if (!xauthority)
+ if (!x_authority)
{
write_string (session, NULL);
return;
}
- write_string (session, xauth_get_authorization_name (session->priv->xauthority));
- family = xauth_get_family (session->priv->xauthority);
+ write_string (session, x_authority_get_authorization_name (session->priv->x_authority));
+ family = x_authority_get_family (session->priv->x_authority);
write_data (session, &family, sizeof (family));
- length = xauth_get_address_length (session->priv->xauthority);
+ length = x_authority_get_address_length (session->priv->x_authority);
write_data (session, &length, sizeof (length));
- write_data (session, xauth_get_address (session->priv->xauthority), length);
- write_string (session, xauth_get_number (session->priv->xauthority));
- length = xauth_get_authorization_data_length (session->priv->xauthority);
+ write_data (session, x_authority_get_address (session->priv->x_authority), length);
+ write_string (session, x_authority_get_number (session->priv->x_authority));
+ length = x_authority_get_authorization_data_length (session->priv->x_authority);
write_data (session, &length, sizeof (length));
- write_data (session, xauth_get_authorization_data (session->priv->xauthority), length);
+ write_data (session, x_authority_get_authorization_data (session->priv->x_authority), length);
}
static ssize_t
write_string (session, session->priv->tty);
write_string (session, session->priv->remote_host_name);
write_string (session, session->priv->xdisplay);
- write_xauth (session, session->priv->xauthority);
+ write_xauth (session, session->priv->x_authority);
g_debug ("Started session %d with service '%s', username '%s'", session->priv->pid, session->priv->pam_service, session->priv->username);
session_real_run (Session *session)
{
gsize i, argc;
- gchar *command, *xauth_filename;
+ gchar *command, *x_authority_filename;
GList *link;
g_return_if_fail (session != NULL);
g_free (command);
/* Create authority location */
- if (session->priv->xauth_use_system_location)
+ if (session->priv->x_authority_use_system_location)
{
gchar *run_dir, *dir;
g_warning ("Failed to set ownership of user authority dir: %s", strerror (errno));
}
- xauth_filename = g_build_filename (dir, "xauthority", NULL);
+ x_authority_filename = g_build_filename (dir, "xauthority", NULL);
g_free (dir);
}
else
- xauth_filename = g_build_filename (user_get_home_directory (session_get_user (session)), ".Xauthority", NULL);
+ x_authority_filename = g_build_filename (user_get_home_directory (session_get_user (session)), ".Xauthority", NULL);
write_string (session, session->priv->log_filename);
write_string (session, session->priv->tty);
- write_string (session, xauth_filename);
- g_free (xauth_filename);
+ write_string (session, x_authority_filename);
+ g_free (x_authority_filename);
write_string (session, session->priv->xdisplay);
- write_xauth (session, session->priv->xauthority);
+ write_xauth (session, session->priv->x_authority);
argc = g_list_length (session->priv->env);
write_data (session, &argc, sizeof (argc));
for (link = session->priv->env; link; link = link->next)
g_free (self->priv->class);
g_free (self->priv->tty);
g_free (self->priv->xdisplay);
- if (self->priv->xauthority)
- g_object_unref (self->priv->xauthority);
+ if (self->priv->x_authority)
+ g_object_unref (self->priv->x_authority);
g_free (self->priv->remote_host_name);
g_free (self->priv->login1_session);
g_free (self->priv->console_kit_cookie);
#include "display-server.h"
#include "accounts.h"
-#include "xauthority.h"
+#include "x-authority.h"
G_BEGIN_DECLS
void session_set_xdisplay (Session *session, const gchar *xdisplay);
-void session_set_xauthority (Session *session, XAuthority *authority, gboolean use_system_location);
+void session_set_x_authority (Session *session, XAuthority *authority, gboolean use_system_location);
void session_set_remote_host_name (Session *session, const gchar *remote_host_name);
#include <unistd.h>
#include <sys/stat.h>
-#include "xauthority.h"
+#include "x-authority.h"
struct XAuthorityPrivate
{
gsize authorization_data_length;
};
-G_DEFINE_TYPE (XAuthority, xauth, G_TYPE_OBJECT);
+G_DEFINE_TYPE (XAuthority, x_authority, G_TYPE_OBJECT);
XAuthority *
-xauth_new (guint16 family, const guint8 *address, gsize address_length, const gchar *number, const gchar *name, const guint8 *data, gsize data_length)
+x_authority_new (guint16 family, const guint8 *address, gsize address_length, const gchar *number, const gchar *name, const guint8 *data, gsize data_length)
{
- XAuthority *auth = g_object_new (XAUTHORITY_TYPE, NULL);
+ XAuthority *auth = g_object_new (X_AUTHORITY_TYPE, NULL);
- xauth_set_family (auth, family);
- xauth_set_address (auth, address, address_length);
- xauth_set_number (auth, number);
- xauth_set_authorization_name (auth, name);
- xauth_set_authorization_data (auth, data, data_length);
+ 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);
+ x_authority_set_authorization_data (auth, data, data_length);
return auth;
}
XAuthority *
-xauth_new_cookie (guint16 family, const guint8 *address, gsize address_length, const gchar *number)
+x_authority_new_cookie (guint16 family, const guint8 *address, gsize address_length, const gchar *number)
{
guint8 cookie[16];
gint i;
for (i = 0; i < 16; i++)
cookie[i] = g_random_int () & 0xFF;
- return xauth_new (family, address, address_length, number, "MIT-MAGIC-COOKIE-1", cookie, 16);
+ return x_authority_new (family, address, address_length, number, "MIT-MAGIC-COOKIE-1", cookie, 16);
}
void
-xauth_set_family (XAuthority *auth, guint16 family)
+x_authority_set_family (XAuthority *auth, guint16 family)
{
g_return_if_fail (auth != NULL);
auth->priv->family = family;
}
guint16
-xauth_get_family (XAuthority *auth)
+x_authority_get_family (XAuthority *auth)
{
g_return_val_if_fail (auth != NULL, 0);
return auth->priv->family;
}
void
-xauth_set_address (XAuthority *auth, const guint8 *address, gsize address_length)
+x_authority_set_address (XAuthority *auth, const guint8 *address, gsize address_length)
{
g_return_if_fail (auth != NULL);
g_free (auth->priv->address);
}
const guint8 *
-xauth_get_address (XAuthority *auth)
+x_authority_get_address (XAuthority *auth)
{
g_return_val_if_fail (auth != NULL, NULL);
return auth->priv->address;
}
const gsize
-xauth_get_address_length (XAuthority *auth)
+x_authority_get_address_length (XAuthority *auth)
{
g_return_val_if_fail (auth != NULL, 0);
return auth->priv->address_length;
}
void
-xauth_set_number (XAuthority *auth, const gchar *number)
+x_authority_set_number (XAuthority *auth, const gchar *number)
{
g_return_if_fail (auth != NULL);
g_free (auth->priv->number);
}
const gchar *
-xauth_get_number (XAuthority *auth)
+x_authority_get_number (XAuthority *auth)
{
g_return_val_if_fail (auth != NULL, NULL);
return auth->priv->number;
}
void
-xauth_set_authorization_name (XAuthority *auth, const gchar *name)
+x_authority_set_authorization_name (XAuthority *auth, const gchar *name)
{
g_return_if_fail (auth != NULL);
g_free (auth->priv->authorization_name);
}
const gchar *
-xauth_get_authorization_name (XAuthority *auth)
+x_authority_get_authorization_name (XAuthority *auth)
{
g_return_val_if_fail (auth != NULL, NULL);
return auth->priv->authorization_name;
}
void
-xauth_set_authorization_data (XAuthority *auth, const guint8 *data, gsize data_length)
+x_authority_set_authorization_data (XAuthority *auth, const guint8 *data, gsize data_length)
{
g_return_if_fail (auth != NULL);
g_free (auth->priv->authorization_data);
}
const guint8 *
-xauth_get_authorization_data (XAuthority *auth)
+x_authority_get_authorization_data (XAuthority *auth)
{
g_return_val_if_fail (auth != NULL, NULL);
return auth->priv->authorization_data;
}
guint8 *
-xauth_copy_authorization_data (XAuthority *auth)
+x_authority_copy_authorization_data (XAuthority *auth)
{
guint8 *data;
}
gsize
-xauth_get_authorization_data_length (XAuthority *auth)
+x_authority_get_authorization_data_length (XAuthority *auth)
{
g_return_val_if_fail (auth != NULL, 0);
return auth->priv->authorization_data_length;
}
gboolean
-xauth_write (XAuthority *auth, XAuthWriteMode mode, const gchar *filename, GError **error)
+x_authority_write (XAuthority *auth, XAuthWriteMode mode, const gchar *filename, GError **error)
{
gchar *input;
gsize input_length = 0, input_offset = 0;
guint16 address_length = 0;
guint16 authorization_data_length = 0;
- a = g_object_new (XAUTHORITY_TYPE, NULL);
+ a = g_object_new (X_AUTHORITY_TYPE, NULL);
result = read_uint16 (input, input_length, &input_offset, &a->priv->family) &&
read_uint16 (input, input_length, &input_offset, &address_length) &&
continue;
}
else
- xauth_set_authorization_data (a, auth->priv->authorization_data, auth->priv->authorization_data_length);
+ x_authority_set_authorization_data (a, auth->priv->authorization_data, auth->priv->authorization_data_length);
}
records = g_list_append (records, a);
}
static void
-xauth_init (XAuthority *auth)
+x_authority_init (XAuthority *auth)
{
- auth->priv = G_TYPE_INSTANCE_GET_PRIVATE (auth, XAUTHORITY_TYPE, XAuthorityPrivate);
+ auth->priv = G_TYPE_INSTANCE_GET_PRIVATE (auth, X_AUTHORITY_TYPE, XAuthorityPrivate);
auth->priv->number = g_strdup ("");
}
static void
-xauth_finalize (GObject *object)
+x_authority_finalize (GObject *object)
{
XAuthority *self;
- self = XAUTHORITY (object);
+ 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 (xauth_parent_class)->finalize (object);
+ G_OBJECT_CLASS (x_authority_parent_class)->finalize (object);
}
static void
-xauth_class_init (XAuthorityClass *klass)
+x_authority_class_init (XAuthorityClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = xauth_finalize;
+ object_class->finalize = x_authority_finalize;
g_type_class_add_private (klass, sizeof (XAuthorityPrivate));
}
--- /dev/null
+/*
+ * 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
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef X_AUTHORITY_H_
+#define X_AUTHORITY_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define X_AUTHORITY_TYPE (x_authority_get_type())
+#define X_AUTHORITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), X_AUTHORITY_TYPE, XAuthority));
+
+typedef struct XAuthorityPrivate XAuthorityPrivate;
+
+typedef struct
+{
+ GObject parent_instance;
+ XAuthorityPrivate *priv;
+} XAuthority;
+
+typedef struct
+{
+ GObjectClass parent_class;
+} XAuthorityClass;
+
+#define XAUTH_FAMILY_INTERNET 0
+#define XAUTH_FAMILY_DECNET 1
+#define XAUTH_FAMILY_CHAOS 2
+#define XAUTH_FAMILY_SERVER_INTERPRETED 5
+#define XAUTH_FAMILY_INTERNET6 6
+#define XAUTH_FAMILY_LOCALHOST 252
+#define XAUTH_FAMILY_KRB5_PRINCIPAL 253
+#define XAUTH_FAMILY_NETNAME 254
+#define XAUTH_FAMILY_LOCAL 256
+#define XAUTH_FAMILY_WILD 65535
+
+typedef enum
+{
+ XAUTH_WRITE_MODE_REPLACE,
+ XAUTH_WRITE_MODE_REMOVE,
+ XAUTH_WRITE_MODE_SET
+} XAuthWriteMode;
+
+GType x_authority_get_type (void);
+
+XAuthority *x_authority_new (guint16 family, const guint8 *address, gsize address_length, const gchar *number, const gchar *name, const guint8 *data, gsize data_length);
+
+XAuthority *x_authority_new_cookie (guint16 family, const guint8 *address, gsize address_length, const gchar *number);
+
+void x_authority_set_family (XAuthority *auth, guint16 family);
+
+guint16 x_authority_get_family (XAuthority *auth);
+
+void x_authority_set_address (XAuthority *auth, const guint8 *address, gsize address_length);
+
+const guint8 *x_authority_get_address (XAuthority *auth);
+
+const gsize x_authority_get_address_length (XAuthority *auth);
+
+void x_authority_set_number (XAuthority *auth, const gchar *number);
+
+const gchar *x_authority_get_number (XAuthority *auth);
+
+void x_authority_set_authorization_name (XAuthority *auth, const gchar *name);
+
+const gchar *x_authority_get_authorization_name (XAuthority *auth);
+
+void x_authority_set_authorization_data (XAuthority *auth, const guint8 *data, gsize data_length);
+
+const guint8 *x_authority_get_authorization_data (XAuthority *auth);
+
+guint8 *x_authority_copy_authorization_data (XAuthority *auth);
+
+gsize x_authority_get_authorization_data_length (XAuthority *auth);
+
+gboolean x_authority_write (XAuthority *auth, XAuthWriteMode mode, const gchar *filename, GError **error);
+
+G_END_DECLS
+
+#endif /* X_AUTHORITY_H_ */
#include <glib/gstdio.h>
#include <stdlib.h>
-#include "xserver-local.h"
+#include "x-server-local.h"
#include "configuration.h"
#include "process.h"
#include "vt.h"
struct XServerLocalPrivate
{
/* X server process */
- Process *xserver_process;
+ Process *x_server_process;
/* File to log to */
gchar *log_file;
gboolean replacing_plymouth;
};
-G_DEFINE_TYPE (XServerLocal, xserver_local, XSERVER_TYPE);
+G_DEFINE_TYPE (XServerLocal, x_server_local, X_SERVER_TYPE);
static GList *display_numbers = NULL;
}
guint
-xserver_local_get_unused_display_number (void)
+x_server_local_get_unused_display_number (void)
{
guint number;
}
void
-xserver_local_release_display_number (guint display_number)
+x_server_local_release_display_number (guint display_number)
{
GList *link;
for (link = display_numbers; link; link = link->next)
}
XServerLocal *
-xserver_local_new (void)
+x_server_local_new (void)
{
- XServerLocal *self = g_object_new (XSERVER_LOCAL_TYPE, NULL);
+ XServerLocal *self = g_object_new (X_SERVER_LOCAL_TYPE, NULL);
gchar hostname[1024], *number, *name;
- xserver_set_display_number (XSERVER (self), xserver_local_get_unused_display_number ());
+ x_server_set_display_number (X_SERVER (self), x_server_local_get_unused_display_number ());
gethostname (hostname, 1024);
- number = g_strdup_printf ("%d", xserver_get_display_number (XSERVER (self)));
- xserver_set_authority (XSERVER (self), xauth_new_cookie (XAUTH_FAMILY_LOCAL, (guint8*) hostname, strlen (hostname), number));
+ number = g_strdup_printf ("%d", x_server_get_display_number (X_SERVER (self)));
+ x_server_set_authority (X_SERVER (self), x_authority_new_cookie (XAUTH_FAMILY_LOCAL, (guint8*) hostname, strlen (hostname), number));
g_free (number);
- name = g_strdup_printf ("x-%d", xserver_get_display_number (XSERVER (self)));
+ name = g_strdup_printf ("x-%d", x_server_get_display_number (X_SERVER (self)));
display_server_set_name (DISPLAY_SERVER (self), name);
g_free (name);
gint active_vt = vt_get_active ();
if (active_vt >= vt_get_min ())
{
- g_debug ("X server %s will replace Plymouth", xserver_get_address (XSERVER (self)));
+ g_debug ("X server %s will replace Plymouth", x_server_get_address (X_SERVER (self)));
self->priv->replacing_plymouth = TRUE;
self->priv->vt = active_vt;
plymouth_deactivate ();
}
void
-xserver_local_set_command (XServerLocal *server, const gchar *command)
+x_server_local_set_command (XServerLocal *server, const gchar *command)
{
g_return_if_fail (server != NULL);
g_free (server->priv->command);
}
void
-xserver_local_set_config (XServerLocal *server, const gchar *path)
+x_server_local_set_config (XServerLocal *server, const gchar *path)
{
g_return_if_fail (server != NULL);
g_free (server->priv->config_file);
}
void
-xserver_local_set_layout (XServerLocal *server, const gchar *layout)
+x_server_local_set_layout (XServerLocal *server, const gchar *layout)
{
g_return_if_fail (server != NULL);
g_free (server->priv->layout);
}
void
-xserver_local_set_allow_tcp (XServerLocal *server, gboolean allow_tcp)
+x_server_local_set_allow_tcp (XServerLocal *server, gboolean allow_tcp)
{
g_return_if_fail (server != NULL);
server->priv->allow_tcp = allow_tcp;
}
void
-xserver_local_set_xdmcp_server (XServerLocal *server, const gchar *hostname)
+x_server_local_set_xdmcp_server (XServerLocal *server, const gchar *hostname)
{
g_return_if_fail (server != NULL);
g_free (server->priv->xdmcp_server);
}
const gchar *
-xserver_local_get_xdmcp_server (XServerLocal *server)
+x_server_local_get_xdmcp_server (XServerLocal *server)
{
g_return_val_if_fail (server != NULL, 0);
return server->priv->xdmcp_server;
}
void
-xserver_local_set_xdmcp_port (XServerLocal *server, guint port)
+x_server_local_set_xdmcp_port (XServerLocal *server, guint port)
{
g_return_if_fail (server != NULL);
server->priv->xdmcp_port = port;
}
guint
-xserver_local_get_xdmcp_port (XServerLocal *server)
+x_server_local_get_xdmcp_port (XServerLocal *server)
{
g_return_val_if_fail (server != NULL, 0);
return server->priv->xdmcp_port;
}
void
-xserver_local_set_xdmcp_key (XServerLocal *server, const gchar *key)
+x_server_local_set_xdmcp_key (XServerLocal *server, const gchar *key)
{
g_return_if_fail (server != NULL);
g_free (server->priv->xdmcp_key);
server->priv->xdmcp_key = g_strdup (key);
- xserver_set_authority (XSERVER (server), NULL);
+ x_server_set_authority (X_SERVER (server), NULL);
}
void
-xserver_local_set_mir_id (XServerLocal *server, const gchar *id)
+x_server_local_set_mir_id (XServerLocal *server, const gchar *id)
{
g_return_if_fail (server != NULL);
g_free (server->priv->mir_id);
server->priv->vt = -1;
}
-const gchar *xserver_local_get_mir_id (XServerLocal *server)
+const gchar *x_server_local_get_mir_id (XServerLocal *server)
{
g_return_val_if_fail (server != NULL, NULL);
return server->priv->mir_id;
}
void
-xserver_local_set_mir_socket (XServerLocal *server, const gchar *socket)
+x_server_local_set_mir_socket (XServerLocal *server, const gchar *socket)
{
g_return_if_fail (server != NULL);
g_free (server->priv->mir_socket);
}
static gint
-xserver_local_get_vt (DisplayServer *server)
+x_server_local_get_vt (DisplayServer *server)
{
g_return_val_if_fail (server != NULL, 0);
- return XSERVER_LOCAL (server)->priv->vt;
+ return X_SERVER_LOCAL (server)->priv->vt;
}
const gchar *
-xserver_local_get_authority_file_path (XServerLocal *server)
+x_server_local_get_authority_file_path (XServerLocal *server)
{
g_return_val_if_fail (server != NULL, 0);
return server->priv->authority_file;
if (signum == SIGUSR1 && !server->priv->got_signal)
{
server->priv->got_signal = TRUE;
- g_debug ("Got signal from X server :%d", xserver_get_display_number (XSERVER (server)));
+ g_debug ("Got signal from X server :%d", x_server_get_display_number (X_SERVER (server)));
if (server->priv->replacing_plymouth)
{
}
// FIXME: Check return value
- DISPLAY_SERVER_CLASS (xserver_local_parent_class)->start (DISPLAY_SERVER (server));
+ DISPLAY_SERVER_CLASS (x_server_local_parent_class)->start (DISPLAY_SERVER (server));
}
}
{
g_debug ("X server stopped");
- xserver_local_release_display_number (xserver_get_display_number (XSERVER (server)));
+ x_server_local_release_display_number (x_server_get_display_number (X_SERVER (server)));
- if (xserver_get_authority (XSERVER (server)) && server->priv->authority_file)
+ if (x_server_get_authority (X_SERVER (server)) && server->priv->authority_file)
{
g_debug ("Removing X server authority %s", server->priv->authority_file);
plymouth_quit (FALSE);
}
- DISPLAY_SERVER_CLASS (xserver_local_parent_class)->stop (DISPLAY_SERVER (server));
+ DISPLAY_SERVER_CLASS (x_server_local_parent_class)->stop (DISPLAY_SERVER (server));
}
static void
XAuthority *authority;
GError *error = NULL;
- authority = xserver_get_authority (XSERVER (server));
+ authority = x_server_get_authority (X_SERVER (server));
if (!authority)
return;
if (g_mkdir_with_parents (dir, S_IRWXU) < 0)
g_warning ("Failed to make authority directory %s: %s", dir, strerror (errno));
- server->priv->authority_file = g_build_filename (dir, xserver_get_address (XSERVER (server)), NULL);
+ server->priv->authority_file = g_build_filename (dir, x_server_get_address (X_SERVER (server)), NULL);
g_free (dir);
}
g_debug ("Writing X server authority to %s", server->priv->authority_file);
- xauth_write (authority, XAUTH_WRITE_MODE_REPLACE, server->priv->authority_file, &error);
+ x_authority_write (authority, XAUTH_WRITE_MODE_REPLACE, server->priv->authority_file, &error);
if (error)
g_warning ("Failed to write authority: %s", error->message);
g_clear_error (&error);
}
static gboolean
-xserver_local_start (DisplayServer *display_server)
+x_server_local_start (DisplayServer *display_server)
{
- XServerLocal *server = XSERVER_LOCAL (display_server);
+ XServerLocal *server = X_SERVER_LOCAL (display_server);
gboolean result;
gchar *filename, *dir, *absolute_command;
GString *command;
- g_return_val_if_fail (server->priv->xserver_process == NULL, FALSE);
+ g_return_val_if_fail (server->priv->x_server_process == NULL, FALSE);
server->priv->got_signal = FALSE;
g_return_val_if_fail (server->priv->command != NULL, FALSE);
- server->priv->xserver_process = process_new ();
- process_set_clear_environment (server->priv->xserver_process, TRUE);
- g_signal_connect (server->priv->xserver_process, "run", G_CALLBACK (run_cb), server);
- g_signal_connect (server->priv->xserver_process, "got-signal", G_CALLBACK (got_signal_cb), server);
- g_signal_connect (server->priv->xserver_process, "stopped", G_CALLBACK (stopped_cb), server);
+ server->priv->x_server_process = process_new ();
+ process_set_clear_environment (server->priv->x_server_process, TRUE);
+ g_signal_connect (server->priv->x_server_process, "run", G_CALLBACK (run_cb), server);
+ g_signal_connect (server->priv->x_server_process, "got-signal", G_CALLBACK (got_signal_cb), server);
+ g_signal_connect (server->priv->x_server_process, "stopped", G_CALLBACK (stopped_cb), server);
/* Setup logging */
filename = g_strdup_printf ("%s.log", display_server_get_name (display_server));
if (!absolute_command)
{
g_debug ("Can't launch X server %s, not found in path", server->priv->command);
- stopped_cb (server->priv->xserver_process, XSERVER_LOCAL (server));
+ stopped_cb (server->priv->x_server_process, X_SERVER_LOCAL (server));
return FALSE;
}
command = g_string_new (absolute_command);
g_free (absolute_command);
- g_string_append_printf (command, " :%d", xserver_get_display_number (XSERVER (server)));
+ g_string_append_printf (command, " :%d", x_server_get_display_number (X_SERVER (server)));
if (server->priv->config_file)
g_string_append_printf (command, " -config %s", server->priv->config_file);
if (server->priv->replacing_plymouth)
g_string_append (command, " -background none");
- process_set_command (server->priv->xserver_process, command->str);
+ process_set_command (server->priv->x_server_process, command->str);
g_string_free (command, TRUE);
g_debug ("Launching X Server");
/* If running inside another display then pass through those variables */
if (g_getenv ("DISPLAY"))
{
- process_set_env (server->priv->xserver_process, "DISPLAY", g_getenv ("DISPLAY"));
+ process_set_env (server->priv->x_server_process, "DISPLAY", g_getenv ("DISPLAY"));
if (g_getenv ("XAUTHORITY"))
- process_set_env (server->priv->xserver_process, "XAUTHORITY", g_getenv ("XAUTHORITY"));
+ process_set_env (server->priv->x_server_process, "XAUTHORITY", g_getenv ("XAUTHORITY"));
else
{
gchar *path;
path = g_build_filename (g_get_home_dir (), ".Xauthority", NULL);
- process_set_env (server->priv->xserver_process, "XAUTHORITY", path);
+ process_set_env (server->priv->x_server_process, "XAUTHORITY", path);
g_free (path);
}
}
/* Variable required for regression tests */
if (g_getenv ("LIGHTDM_TEST_ROOT"))
{
- process_set_env (server->priv->xserver_process, "LIGHTDM_TEST_ROOT", g_getenv ("LIGHTDM_TEST_ROOT"));
- process_set_env (server->priv->xserver_process, "LD_PRELOAD", g_getenv ("LD_PRELOAD"));
- process_set_env (server->priv->xserver_process, "LD_LIBRARY_PATH", g_getenv ("LD_LIBRARY_PATH"));
+ process_set_env (server->priv->x_server_process, "LIGHTDM_TEST_ROOT", g_getenv ("LIGHTDM_TEST_ROOT"));
+ process_set_env (server->priv->x_server_process, "LD_PRELOAD", g_getenv ("LD_PRELOAD"));
+ process_set_env (server->priv->x_server_process, "LD_LIBRARY_PATH", g_getenv ("LD_LIBRARY_PATH"));
}
- result = process_start (server->priv->xserver_process, FALSE);
+ result = process_start (server->priv->x_server_process, FALSE);
if (result)
- g_debug ("Waiting for ready signal from X server :%d", xserver_get_display_number (XSERVER (server)));
+ g_debug ("Waiting for ready signal from X server :%d", x_server_get_display_number (X_SERVER (server)));
if (!result)
- stopped_cb (server->priv->xserver_process, XSERVER_LOCAL (server));
+ stopped_cb (server->priv->x_server_process, X_SERVER_LOCAL (server));
return result;
}
static void
-xserver_local_stop (DisplayServer *server)
+x_server_local_stop (DisplayServer *server)
{
- process_stop (XSERVER_LOCAL (server)->priv->xserver_process);
+ process_stop (X_SERVER_LOCAL (server)->priv->x_server_process);
}
static void
-xserver_local_init (XServerLocal *server)
+x_server_local_init (XServerLocal *server)
{
- server->priv = G_TYPE_INSTANCE_GET_PRIVATE (server, XSERVER_LOCAL_TYPE, XServerLocalPrivate);
+ server->priv = G_TYPE_INSTANCE_GET_PRIVATE (server, X_SERVER_LOCAL_TYPE, XServerLocalPrivate);
server->priv->vt = -1;
server->priv->command = g_strdup ("X");
}
static void
-xserver_local_finalize (GObject *object)
+x_server_local_finalize (GObject *object)
{
XServerLocal *self;
- self = XSERVER_LOCAL (object);
+ self = X_SERVER_LOCAL (object);
- if (self->priv->xserver_process)
+ if (self->priv->x_server_process)
{
- g_signal_handlers_disconnect_matched (self->priv->xserver_process, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self);
- g_object_unref (self->priv->xserver_process);
+ g_signal_handlers_disconnect_matched (self->priv->x_server_process, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self);
+ g_object_unref (self->priv->x_server_process);
}
g_free (self->priv->log_file);
g_free (self->priv->command);
if (self->priv->have_vt_ref)
vt_unref (self->priv->vt);
- G_OBJECT_CLASS (xserver_local_parent_class)->finalize (object);
+ G_OBJECT_CLASS (x_server_local_parent_class)->finalize (object);
}
static void
-xserver_local_class_init (XServerLocalClass *klass)
+x_server_local_class_init (XServerLocalClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
DisplayServerClass *display_server_class = DISPLAY_SERVER_CLASS (klass);
- display_server_class->get_vt = xserver_local_get_vt;
- display_server_class->start = xserver_local_start;
- display_server_class->stop = xserver_local_stop;
- object_class->finalize = xserver_local_finalize;
+ display_server_class->get_vt = x_server_local_get_vt;
+ display_server_class->start = x_server_local_start;
+ display_server_class->stop = x_server_local_stop;
+ object_class->finalize = x_server_local_finalize;
g_type_class_add_private (klass, sizeof (XServerLocalPrivate));
}
--- /dev/null
+/*
+ * 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
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef X_SERVER_LOCAL_H_
+#define X_SERVER_LOCAL_H_
+
+#include "x-server.h"
+
+G_BEGIN_DECLS
+
+#define X_SERVER_LOCAL_TYPE (x_server_local_get_type())
+#define X_SERVER_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), X_SERVER_LOCAL_TYPE, XServerLocal))
+#define IS_X_SERVER_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), X_SERVER_LOCAL_TYPE))
+
+typedef struct XServerLocalPrivate XServerLocalPrivate;
+
+typedef struct
+{
+ XServer parent_instance;
+ XServerLocalPrivate *priv;
+} XServerLocal;
+
+typedef struct
+{
+ XServerClass parent_class;
+
+ void (*ready)(XServerLocal *server);
+} XServerLocalClass;
+
+guint x_server_local_get_unused_display_number (void);
+
+void x_server_local_release_display_number (guint display_number);
+
+GType x_server_local_get_type (void);
+
+XServerLocal *x_server_local_new (void);
+
+void x_server_local_set_command (XServerLocal *server, const gchar *command);
+
+void x_server_local_set_config (XServerLocal *server, const gchar *path);
+
+void x_server_local_set_layout (XServerLocal *server, const gchar *layout);
+
+void x_server_local_set_allow_tcp (XServerLocal *server, gboolean allow_tcp);
+
+void x_server_local_set_xdmcp_server (XServerLocal *server, const gchar *hostname);
+
+const gchar *x_server_local_get_xdmcp_server (XServerLocal *server);
+
+void x_server_local_set_xdmcp_port (XServerLocal *server, guint port);
+
+guint x_server_local_get_xdmcp_port (XServerLocal *server);
+
+void x_server_local_set_xdmcp_key (XServerLocal *server, const gchar *key);
+
+void x_server_local_set_mir_id (XServerLocal *server, const gchar *id);
+
+const gchar *x_server_local_get_mir_id (XServerLocal *server);
+
+void x_server_local_set_mir_socket (XServerLocal *server, const gchar *socket);
+
+const gchar *x_server_local_get_authority_file_path (XServerLocal *server);
+
+G_END_DECLS
+
+#endif /* X_SERVER_LOCAL_H_ */
#include <config.h>
-#include "xserver-remote.h"
+#include "x-server-remote.h"
-G_DEFINE_TYPE (XServerRemote, xserver_remote, XSERVER_TYPE);
+G_DEFINE_TYPE (XServerRemote, x_server_remote, X_SERVER_TYPE);
XServerRemote *
-xserver_remote_new (const gchar *hostname, guint number, XAuthority *authority)
+x_server_remote_new (const gchar *hostname, guint number, XAuthority *authority)
{
- XServerRemote *self = g_object_new (XSERVER_REMOTE_TYPE, NULL);
+ XServerRemote *self = g_object_new (X_SERVER_REMOTE_TYPE, NULL);
gchar *name;
- xserver_set_hostname (XSERVER (self), hostname);
- xserver_set_display_number (XSERVER (self), number);
- xserver_set_authority (XSERVER (self), authority);
+ x_server_set_hostname (X_SERVER (self), hostname);
+ x_server_set_display_number (X_SERVER (self), number);
+ x_server_set_authority (X_SERVER (self), authority);
name = g_strdup_printf ("x-%s-%d", hostname, number);
display_server_set_name (DISPLAY_SERVER (self), name);
}
static void
-xserver_remote_init (XServerRemote *server)
+x_server_remote_init (XServerRemote *server)
{
}
static void
-xserver_remote_class_init (XServerRemoteClass *klass)
+x_server_remote_class_init (XServerRemoteClass *klass)
{
}
* license.
*/
-#ifndef XSERVER_REMOTE_H_
-#define XSERVER_REMOTE_H_
+#ifndef X_SERVER_REMOTE_H_
+#define X_SERVER_REMOTE_H_
-#include "xserver.h"
+#include "x-server.h"
G_BEGIN_DECLS
-#define XSERVER_REMOTE_TYPE (xserver_remote_get_type())
-#define XSERVER_REMOTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XSERVER_REMOTE_TYPE, XServerRemote))
+#define X_SERVER_REMOTE_TYPE (x_server_remote_get_type())
+#define X_SERVER_REMOTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), X_SERVER_REMOTE_TYPE, XServerRemote))
typedef struct
{
XServerClass parent_class;
} XServerRemoteClass;
-GType xserver_remote_get_type (void);
+GType x_server_remote_get_type (void);
-XServerRemote *xserver_remote_new (const gchar *hostname, guint number, XAuthority *authority);
+XServerRemote *x_server_remote_new (const gchar *hostname, guint number, XAuthority *authority);
G_END_DECLS
-#endif /* XSERVER_REMOTE_H_ */
+#endif /* X_SERVER_REMOTE_H_ */
#include <errno.h>
#include <glib/gstdio.h>
-#include "xserver-xvnc.h"
+#include "x-server-xvnc.h"
#include "configuration.h"
-#include "xserver-local.h"
+#include "x-server-local.h"
#include "process.h"
struct XServerXVNCPrivate
{
/* X server process */
- Process *xserver_process;
+ Process *x_server_process;
/* File to log to */
gchar *log_file;
gboolean got_signal;
};
-G_DEFINE_TYPE (XServerXVNC, xserver_xvnc, XSERVER_TYPE);
+G_DEFINE_TYPE (XServerXVNC, x_server_xvnc, X_SERVER_TYPE);
XServerXVNC *
-xserver_xvnc_new (void)
+x_server_xvnc_new (void)
{
- XServerXVNC *self = g_object_new (XSERVER_XVNC_TYPE, NULL);
+ XServerXVNC *self = g_object_new (X_SERVER_XVNC_TYPE, NULL);
gchar *name;
- xserver_set_display_number (XSERVER (self), xserver_local_get_unused_display_number ());
+ x_server_set_display_number (X_SERVER (self), x_server_local_get_unused_display_number ());
- name = g_strdup_printf ("xvnc-%d", xserver_get_display_number (XSERVER (self)));
+ name = g_strdup_printf ("xvnc-%d", x_server_get_display_number (X_SERVER (self)));
display_server_set_name (DISPLAY_SERVER (self), name);
g_free (name);
}
void
-xserver_xvnc_set_command (XServerXVNC *server, const gchar *command)
+x_server_xvnc_set_command (XServerXVNC *server, const gchar *command)
{
g_return_if_fail (server != NULL);
g_free (server->priv->command);
}
void
-xserver_xvnc_set_socket (XServerXVNC *server, int fd)
+x_server_xvnc_set_socket (XServerXVNC *server, int fd)
{
g_return_if_fail (server != NULL);
server->priv->socket_fd = fd;
}
int
-xserver_xvnc_get_socket (XServerXVNC *server)
+x_server_xvnc_get_socket (XServerXVNC *server)
{
g_return_val_if_fail (server != NULL, 0);
return server->priv->socket_fd;
}
void
-xserver_xvnc_set_geometry (XServerXVNC *server, gint width, gint height)
+x_server_xvnc_set_geometry (XServerXVNC *server, gint width, gint height)
{
g_return_if_fail (server != NULL);
server->priv->width = width;
}
void
-xserver_xvnc_set_depth (XServerXVNC *server, gint depth)
+x_server_xvnc_set_depth (XServerXVNC *server, gint depth)
{
g_return_if_fail (server != NULL);
server->priv->depth = depth;
}
const gchar *
-xserver_xvnc_get_authority_file_path (XServerXVNC *server)
+x_server_xvnc_get_authority_file_path (XServerXVNC *server)
{
g_return_val_if_fail (server != NULL, 0);
return server->priv->authority_file;
if (signum == SIGUSR1 && !server->priv->got_signal)
{
server->priv->got_signal = TRUE;
- g_debug ("Got signal from Xvnc server :%d", xserver_get_display_number (XSERVER (server)));
+ g_debug ("Got signal from Xvnc server :%d", x_server_get_display_number (X_SERVER (server)));
// FIXME: Check return value
- DISPLAY_SERVER_CLASS (xserver_xvnc_parent_class)->start (DISPLAY_SERVER (server));
+ DISPLAY_SERVER_CLASS (x_server_xvnc_parent_class)->start (DISPLAY_SERVER (server));
}
}
{
g_debug ("Xvnc server stopped");
- g_object_unref (server->priv->xserver_process);
- server->priv->xserver_process = NULL;
+ g_object_unref (server->priv->x_server_process);
+ server->priv->x_server_process = NULL;
- xserver_local_release_display_number (xserver_get_display_number (XSERVER (server)));
+ x_server_local_release_display_number (x_server_get_display_number (X_SERVER (server)));
g_debug ("Removing X server authority %s", server->priv->authority_file);
g_free (server->priv->authority_file);
server->priv->authority_file = NULL;
- DISPLAY_SERVER_CLASS (xserver_xvnc_parent_class)->stop (DISPLAY_SERVER (server));
+ DISPLAY_SERVER_CLASS (x_server_xvnc_parent_class)->stop (DISPLAY_SERVER (server));
}
static gboolean
-xserver_xvnc_start (DisplayServer *display_server)
+x_server_xvnc_start (DisplayServer *display_server)
{
- XServerXVNC *server = XSERVER_XVNC (display_server);
+ XServerXVNC *server = X_SERVER_XVNC (display_server);
XAuthority *authority;
gboolean result;
gchar *filename, *run_dir, *dir, *absolute_command;
gchar hostname[1024], *number;
GError *error = NULL;
- g_return_val_if_fail (server->priv->xserver_process == NULL, FALSE);
+ g_return_val_if_fail (server->priv->x_server_process == NULL, FALSE);
server->priv->got_signal = FALSE;
- server->priv->xserver_process = process_new ();
- process_set_clear_environment (server->priv->xserver_process, TRUE);
- g_signal_connect (server->priv->xserver_process, "run", G_CALLBACK (run_cb), server);
- g_signal_connect (server->priv->xserver_process, "got-signal", G_CALLBACK (got_signal_cb), server);
- g_signal_connect (server->priv->xserver_process, "stopped", G_CALLBACK (stopped_cb), server);
+ server->priv->x_server_process = process_new ();
+ process_set_clear_environment (server->priv->x_server_process, TRUE);
+ g_signal_connect (server->priv->x_server_process, "run", G_CALLBACK (run_cb), server);
+ g_signal_connect (server->priv->x_server_process, "got-signal", G_CALLBACK (got_signal_cb), server);
+ g_signal_connect (server->priv->x_server_process, "stopped", G_CALLBACK (stopped_cb), server);
/* Setup logging */
filename = g_strdup_printf ("%s.log", display_server_get_name (display_server));
if (!absolute_command)
{
g_debug ("Can't launch X server %s, not found in path", server->priv->command);
- stopped_cb (server->priv->xserver_process, XSERVER_XVNC (server));
+ stopped_cb (server->priv->x_server_process, X_SERVER_XVNC (server));
return FALSE;
}
gethostname (hostname, 1024);
- number = g_strdup_printf ("%d", xserver_get_display_number (XSERVER (server)));
- authority = xauth_new_cookie (XAUTH_FAMILY_LOCAL, (guint8*) hostname, strlen (hostname), number);
+ 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);
- xserver_set_authority (XSERVER (server), authority);
+ x_server_set_authority (X_SERVER (server), authority);
run_dir = config_get_string (config_get_instance (), "LightDM", "run-directory");
dir = g_build_filename (run_dir, "root", NULL);
if (g_mkdir_with_parents (dir, S_IRWXU) < 0)
g_warning ("Failed to make authority directory %s: %s", dir, strerror (errno));
- server->priv->authority_file = g_build_filename (dir, xserver_get_address (XSERVER (server)), NULL);
+ server->priv->authority_file = g_build_filename (dir, x_server_get_address (X_SERVER (server)), NULL);
g_free (dir);
g_debug ("Writing X server authority to %s", server->priv->authority_file);
- xauth_write (authority, XAUTH_WRITE_MODE_REPLACE, server->priv->authority_file, &error);
+ x_authority_write (authority, XAUTH_WRITE_MODE_REPLACE, server->priv->authority_file, &error);
if (error)
g_warning ("Failed to write authority: %s", error->message);
g_clear_error (&error);
command = g_string_new (absolute_command);
g_free (absolute_command);
- g_string_append_printf (command, " :%d", xserver_get_display_number (XSERVER (server)));
+ g_string_append_printf (command, " :%d", x_server_get_display_number (X_SERVER (server)));
g_string_append_printf (command, " -auth %s", server->priv->authority_file);
g_string_append (command, " -inetd -nolisten tcp");
if (server->priv->width > 0 && server->priv->height > 0)
if (server->priv->depth > 0)
g_string_append_printf (command, " -depth %d", server->priv->depth);
- process_set_command (server->priv->xserver_process, command->str);
+ process_set_command (server->priv->x_server_process, command->str);
g_string_free (command, TRUE);
g_debug ("Launching Xvnc server");
/* Variable required for regression tests */
if (g_getenv ("LIGHTDM_TEST_ROOT"))
{
- process_set_env (server->priv->xserver_process, "LIGHTDM_TEST_ROOT", g_getenv ("LIGHTDM_TEST_ROOT"));
- process_set_env (server->priv->xserver_process, "LD_LIBRARY_PATH", g_getenv ("LD_LIBRARY_PATH"));
+ process_set_env (server->priv->x_server_process, "LIGHTDM_TEST_ROOT", g_getenv ("LIGHTDM_TEST_ROOT"));
+ process_set_env (server->priv->x_server_process, "LD_LIBRARY_PATH", g_getenv ("LD_LIBRARY_PATH"));
}
- result = process_start (server->priv->xserver_process, FALSE);
+ result = process_start (server->priv->x_server_process, FALSE);
if (result)
- g_debug ("Waiting for ready signal from Xvnc server :%d", xserver_get_display_number (XSERVER (server)));
+ g_debug ("Waiting for ready signal from Xvnc server :%d", x_server_get_display_number (X_SERVER (server)));
if (!result)
- stopped_cb (server->priv->xserver_process, XSERVER_XVNC (server));
+ stopped_cb (server->priv->x_server_process, X_SERVER_XVNC (server));
return result;
}
static void
-xserver_xvnc_stop (DisplayServer *server)
+x_server_xvnc_stop (DisplayServer *server)
{
- process_stop (XSERVER_XVNC (server)->priv->xserver_process);
+ process_stop (X_SERVER_XVNC (server)->priv->x_server_process);
}
static void
-xserver_xvnc_init (XServerXVNC *server)
+x_server_xvnc_init (XServerXVNC *server)
{
- server->priv = G_TYPE_INSTANCE_GET_PRIVATE (server, XSERVER_XVNC_TYPE, XServerXVNCPrivate);
+ server->priv = G_TYPE_INSTANCE_GET_PRIVATE (server, X_SERVER_XVNC_TYPE, XServerXVNCPrivate);
server->priv->command = g_strdup ("Xvnc");
server->priv->width = 1024;
server->priv->height = 768;
}
static void
-xserver_xvnc_finalize (GObject *object)
+x_server_xvnc_finalize (GObject *object)
{
XServerXVNC *self;
- self = XSERVER_XVNC (object);
+ self = X_SERVER_XVNC (object);
- if (self->priv->xserver_process)
- g_object_unref (self->priv->xserver_process);
+ if (self->priv->x_server_process)
+ g_object_unref (self->priv->x_server_process);
g_free (self->priv->command);
g_free (self->priv->authority_file);
g_free (self->priv->log_file);
- G_OBJECT_CLASS (xserver_xvnc_parent_class)->finalize (object);
+ G_OBJECT_CLASS (x_server_xvnc_parent_class)->finalize (object);
}
static void
-xserver_xvnc_class_init (XServerXVNCClass *klass)
+x_server_xvnc_class_init (XServerXVNCClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
DisplayServerClass *display_server_class = DISPLAY_SERVER_CLASS (klass);
- display_server_class->start = xserver_xvnc_start;
- display_server_class->stop = xserver_xvnc_stop;
- object_class->finalize = xserver_xvnc_finalize;
+ display_server_class->start = x_server_xvnc_start;
+ display_server_class->stop = x_server_xvnc_stop;
+ object_class->finalize = x_server_xvnc_finalize;
g_type_class_add_private (klass, sizeof (XServerXVNCPrivate));
}
--- /dev/null
+/*
+ * 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
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef X_SERVER_XVNC_H_
+#define X_SERVER_XVNC_H_
+
+#include "x-server.h"
+
+G_BEGIN_DECLS
+
+#define X_SERVER_XVNC_TYPE (x_server_xvnc_get_type())
+#define X_SERVER_XVNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), X_SERVER_XVNC_TYPE, XServerXVNC))
+#define IS_X_SERVER_XVNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), X_SERVER_XVNC_TYPE))
+
+typedef struct XServerXVNCPrivate XServerXVNCPrivate;
+
+typedef struct
+{
+ XServer parent_instance;
+ XServerXVNCPrivate *priv;
+} XServerXVNC;
+
+typedef struct
+{
+ XServerClass parent_class;
+
+ void (*ready)(XServerXVNC *server);
+} XServerXVNCClass;
+
+GType x_server_xvnc_get_type (void);
+
+gboolean x_server_xvnc_check_available (void);
+
+XServerXVNC *x_server_xvnc_new (void);
+
+void x_server_xvnc_set_command (XServerXVNC *server, const gchar *command);
+
+void x_server_xvnc_set_socket (XServerXVNC *server, int fd);
+
+int x_server_xvnc_get_socket (XServerXVNC *server);
+
+void x_server_xvnc_set_geometry (XServerXVNC *server, gint width, gint height);
+
+void x_server_xvnc_set_depth (XServerXVNC *server, gint depth);
+
+const gchar *x_server_xvnc_get_authority_file_path (XServerXVNC *server);
+
+G_END_DECLS
+
+#endif /* X_SERVER_XVNC_H_ */
#include <string.h>
#include <xcb/xcb.h>
-#include "xserver.h"
+#include "x-server.h"
#include "configuration.h"
struct XServerPrivate
xcb_connection_t *connection;
};
-G_DEFINE_TYPE (XServer, xserver, DISPLAY_SERVER_TYPE);
+G_DEFINE_TYPE (XServer, x_server, DISPLAY_SERVER_TYPE);
void
-xserver_set_hostname (XServer *server, const gchar *hostname)
+x_server_set_hostname (XServer *server, const gchar *hostname)
{
g_return_if_fail (server != NULL);
g_free (server->priv->hostname);
}
gchar *
-xserver_get_hostname (XServer *server)
+x_server_get_hostname (XServer *server)
{
g_return_val_if_fail (server != NULL, NULL);
return server->priv->hostname;
}
void
-xserver_set_display_number (XServer *server, guint number)
+x_server_set_display_number (XServer *server, guint number)
{
g_return_if_fail (server != NULL);
server->priv->number = number;
}
guint
-xserver_get_display_number (XServer *server)
+x_server_get_display_number (XServer *server)
{
g_return_val_if_fail (server != NULL, 0);
return server->priv->number;
}
const gchar *
-xserver_get_address (XServer *server)
+x_server_get_address (XServer *server)
{
g_return_val_if_fail (server != NULL, NULL);
}
void
-xserver_set_authority (XServer *server, XAuthority *authority)
+x_server_set_authority (XServer *server, XAuthority *authority)
{
g_return_if_fail (server != NULL);
}
XAuthority *
-xserver_get_authority (XServer *server)
+x_server_get_authority (XServer *server)
{
g_return_val_if_fail (server != NULL, NULL);
return server->priv->authority;
}
static gboolean
-xserver_start (DisplayServer *display_server)
+x_server_start (DisplayServer *display_server)
{
- XServer *server = XSERVER (display_server);
+ XServer *server = X_SERVER (display_server);
xcb_auth_info_t *auth = NULL, a;
if (server->priv->authority)
{
- a.namelen = strlen (xauth_get_authorization_name (server->priv->authority));
- a.name = (char *) xauth_get_authorization_name (server->priv->authority);
- a.datalen = xauth_get_authorization_data_length (server->priv->authority);
- a.data = (char *) xauth_get_authorization_data (server->priv->authority);
+ a.namelen = strlen (x_authority_get_authorization_name (server->priv->authority));
+ a.name = (char *) x_authority_get_authorization_name (server->priv->authority);
+ a.datalen = x_authority_get_authorization_data_length (server->priv->authority);
+ a.data = (char *) x_authority_get_authorization_data (server->priv->authority);
auth = &a;
}
/* Open connection */
- g_debug ("Connecting to XServer %s", xserver_get_address (server));
- server->priv->connection = xcb_connect_to_display_with_auth_info (xserver_get_address (server), auth, NULL);
+ g_debug ("Connecting to XServer %s", x_server_get_address (server));
+ server->priv->connection = xcb_connect_to_display_with_auth_info (x_server_get_address (server), auth, NULL);
if (xcb_connection_has_error (server->priv->connection))
{
- g_debug ("Error connecting to XServer %s", xserver_get_address (server));
+ g_debug ("Error connecting to XServer %s", x_server_get_address (server));
return FALSE;
}
- return DISPLAY_SERVER_CLASS (xserver_parent_class)->start (display_server);
+ return DISPLAY_SERVER_CLASS (x_server_parent_class)->start (display_server);
}
static void
-xserver_setup_session (DisplayServer *display_server, Session *session)
+x_server_setup_session (DisplayServer *display_server, Session *session)
{
gint vt;
g_free (t);
}
- session_set_env (session, "DISPLAY", xserver_get_address (XSERVER (display_server)));
- session_set_tty (session, xserver_get_address (XSERVER (display_server)));
- session_set_xdisplay (session, xserver_get_address (XSERVER (display_server)));
- session_set_remote_host_name (session, xserver_get_hostname (XSERVER (display_server)));
- session_set_xauthority (session,
- xserver_get_authority (XSERVER (display_server)),
- config_get_boolean (config_get_instance (), "LightDM", "user-authority-in-system-dir"));
+ session_set_env (session, "DISPLAY", x_server_get_address (X_SERVER (display_server)));
+ session_set_tty (session, x_server_get_address (X_SERVER (display_server)));
+ session_set_xdisplay (session, x_server_get_address (X_SERVER (display_server)));
+ session_set_remote_host_name (session, x_server_get_hostname (X_SERVER (display_server)));
+ session_set_x_authority (session,
+ x_server_get_authority (X_SERVER (display_server)),
+ config_get_boolean (config_get_instance (), "LightDM", "user-authority-in-system-dir"));
}
-static void
-xserver_init (XServer *server)
+void
+x_server_init (XServer *server)
{
- server->priv = G_TYPE_INSTANCE_GET_PRIVATE (server, XSERVER_TYPE, XServerPrivate);
+ server->priv = G_TYPE_INSTANCE_GET_PRIVATE (server, X_SERVER_TYPE, XServerPrivate);
}
static void
-xserver_finalize (GObject *object)
+x_server_finalize (GObject *object)
{
XServer *self;
- self = XSERVER (object);
+ self = X_SERVER (object);
g_free (self->priv->hostname);
g_free (self->priv->address);
if (self->priv->connection)
xcb_disconnect (self->priv->connection);
- G_OBJECT_CLASS (xserver_parent_class)->finalize (object);
+ G_OBJECT_CLASS (x_server_parent_class)->finalize (object);
}
static void
-xserver_class_init (XServerClass *klass)
+x_server_class_init (XServerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
DisplayServerClass *display_server_class = DISPLAY_SERVER_CLASS (klass);
- display_server_class->start = xserver_start;
- display_server_class->setup_session = xserver_setup_session;
- object_class->finalize = xserver_finalize;
+ display_server_class->start = x_server_start;
+ display_server_class->setup_session = x_server_setup_session;
+ object_class->finalize = x_server_finalize;
g_type_class_add_private (klass, sizeof (XServerPrivate));
}
--- /dev/null
+/*
+ * 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
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef X_SERVER_H_
+#define X_SERVER_H_
+
+#include <glib-object.h>
+#include "display-server.h"
+#include "x-authority.h"
+
+G_BEGIN_DECLS
+
+#define X_SERVER_TYPE (x_server_get_type())
+#define X_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), X_SERVER_TYPE, XServer))
+#define X_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), X_SERVER_TYPE, XServerClass))
+#define X_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), X_SERVER_TYPE, XServerClass))
+#define IS_X_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), X_SERVER_TYPE))
+
+typedef struct XServerPrivate XServerPrivate;
+
+typedef struct
+{
+ DisplayServer parent_instance;
+ XServerPrivate *priv;
+} XServer;
+
+typedef struct
+{
+ DisplayServerClass parent_class;
+} XServerClass;
+
+GType x_server_get_type (void);
+
+void x_server_set_hostname (XServer *server, const gchar *hostname);
+
+gchar *x_server_get_hostname (XServer *server);
+
+void x_server_set_display_number (XServer *server, guint number);
+
+guint x_server_get_display_number (XServer *server);
+
+const gchar *x_server_get_address (XServer *server);
+
+const gchar *x_server_get_authentication_name (XServer *server);
+
+const guint8 *x_server_get_authentication_data (XServer *server);
+
+gsize x_server_get_authentication_data_length (XServer *server);
+
+void x_server_set_authority (XServer *server, XAuthority *authority);
+
+XAuthority *x_server_get_authority (XServer *server);
+
+G_END_DECLS
+
+#endif /* X_SERVER_H_ */
+++ /dev/null
-/*
- * 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
- * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
- * license.
- */
-
-#ifndef XAUTHORITY_H_
-#define XAUTHORITY_H_
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XAUTHORITY_TYPE (xauth_get_type())
-#define XAUTHORITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XAUTHORITY_TYPE, XAuthority));
-
-typedef struct XAuthorityPrivate XAuthorityPrivate;
-
-typedef struct
-{
- GObject parent_instance;
- XAuthorityPrivate *priv;
-} XAuthority;
-
-typedef struct
-{
- GObjectClass parent_class;
-} XAuthorityClass;
-
-#define XAUTH_FAMILY_INTERNET 0
-#define XAUTH_FAMILY_DECNET 1
-#define XAUTH_FAMILY_CHAOS 2
-#define XAUTH_FAMILY_SERVER_INTERPRETED 5
-#define XAUTH_FAMILY_INTERNET6 6
-#define XAUTH_FAMILY_LOCALHOST 252
-#define XAUTH_FAMILY_KRB5_PRINCIPAL 253
-#define XAUTH_FAMILY_NETNAME 254
-#define XAUTH_FAMILY_LOCAL 256
-#define XAUTH_FAMILY_WILD 65535
-
-typedef enum
-{
- XAUTH_WRITE_MODE_REPLACE,
- XAUTH_WRITE_MODE_REMOVE,
- XAUTH_WRITE_MODE_SET
-} XAuthWriteMode;
-
-GType xauth_get_type (void);
-
-XAuthority *xauth_new (guint16 family, const guint8 *address, gsize address_length, const gchar *number, const gchar *name, const guint8 *data, gsize data_length);
-
-XAuthority *xauth_new_cookie (guint16 family, const guint8 *address, gsize address_length, const gchar *number);
-
-void xauth_set_family (XAuthority *auth, guint16 family);
-
-guint16 xauth_get_family (XAuthority *auth);
-
-void xauth_set_address (XAuthority *auth, const guint8 *address, gsize address_length);
-
-const guint8 *xauth_get_address (XAuthority *auth);
-
-const gsize xauth_get_address_length (XAuthority *auth);
-
-void xauth_set_number (XAuthority *auth, const gchar *number);
-
-const gchar *xauth_get_number (XAuthority *auth);
-
-void xauth_set_authorization_name (XAuthority *auth, const gchar *name);
-
-const gchar *xauth_get_authorization_name (XAuthority *auth);
-
-void xauth_set_authorization_data (XAuthority *auth, const guint8 *data, gsize data_length);
-
-const guint8 *xauth_get_authorization_data (XAuthority *auth);
-
-guint8 *xauth_copy_authorization_data (XAuthority *auth);
-
-gsize xauth_get_authorization_data_length (XAuthority *auth);
-
-gboolean xauth_write (XAuthority *auth, XAuthWriteMode mode, const gchar *filename, GError **error);
-
-G_END_DECLS
-
-#endif /* XAUTHORITY_H_ */
#include "xdmcp-server.h"
#include "xdmcp-protocol.h"
#include "xdmcp-session-private.h"
-#include "xauthority.h"
+#include "x-authority.h"
enum {
NEW_SESSION,
gsize session_authorization_data_length = 0;
gchar **j;
guint16 family;
- GInetAddress *xserver_address = NULL;
+ GInetAddress *x_server_address = NULL;
gchar *display_number;
XdmAuthKeyRec rho;
if (connection->type == XAUTH_FAMILY_INTERNET6 && connection->address.length == 16)
{
family = connection->type;
- xserver_address = g_inet_address_new_from_bytes (connection->address.data, G_SOCKET_FAMILY_IPV6);
+ x_server_address = g_inet_address_new_from_bytes (connection->address.data, G_SOCKET_FAMILY_IPV6);
/* We can't use link-local addresses, as we need to know what interface it is on */
- if (g_inet_address_get_is_link_local (xserver_address))
+ if (g_inet_address_get_is_link_local (x_server_address))
{
- g_object_unref (xserver_address);
- xserver_address = NULL;
+ g_object_unref (x_server_address);
+ x_server_address = NULL;
}
else
break;
}
/* If no IPv6 address, then try and find an IPv4 one */
- if (!xserver_address)
+ if (!x_server_address)
{
for (i = 0; i < packet->Request.n_connections; i++)
{
if (connection->type == XAUTH_FAMILY_INTERNET && connection->address.length == 4)
{
family = connection->type;
- xserver_address = g_inet_address_new_from_bytes (connection->address.data, G_SOCKET_FAMILY_IPV4);
+ x_server_address = g_inet_address_new_from_bytes (connection->address.data, G_SOCKET_FAMILY_IPV4);
break;
}
}
}
/* Decline if haven't got an address we can connect on */
- if (!xserver_address)
+ if (!x_server_address)
{
response = xdmcp_packet_alloc (XDMCP_Decline);
response->Decline.status = g_strdup ("No valid address found");
XAuthority *auth;
/* Data is the cookie */
- auth = xauth_new_cookie (XAUTH_FAMILY_WILD, NULL, 0, "");
- authorization_data = xauth_copy_authorization_data (auth);
- authorization_data_length = xauth_get_authorization_data_length (auth);
- session_authorization_data = xauth_copy_authorization_data (auth);
- session_authorization_data_length = xauth_get_authorization_data_length (auth);
+ auth = x_authority_new_cookie (XAUTH_FAMILY_WILD, NULL, 0, "");
+ authorization_data = x_authority_copy_authorization_data (auth);
+ authorization_data_length = x_authority_get_authorization_data_length (auth);
+ session_authorization_data = x_authority_copy_authorization_data (auth);
+ session_authorization_data_length = x_authority_get_authorization_data_length (auth);
g_object_unref (auth);
}
session = add_session (server);
- session->priv->address = xserver_address;
+ session->priv->address = x_server_address;
session->priv->display_number = packet->Request.display_number;
display_number = g_strdup_printf ("%d", packet->Request.display_number);
/* We need to check if this is the loopback address and set the authority
* for a local connection if this is so as XCB treats "127.0.0.1" as local
* always */
- if (g_inet_address_get_is_loopback (xserver_address))
+ if (g_inet_address_get_is_loopback (x_server_address))
{
gchar hostname[1024];
gethostname (hostname, 1024);
- session->priv->authority = xauth_new (XAUTH_FAMILY_LOCAL,
+ session->priv->authority = x_authority_new (XAUTH_FAMILY_LOCAL,
(guint8 *) hostname,
strlen (hostname),
display_number,
session_authorization_data_length);
}
else
- session->priv->authority = xauth_new (family,
- g_inet_address_to_bytes (G_INET_ADDRESS (xserver_address)),
- g_inet_address_get_native_size (G_INET_ADDRESS (xserver_address)),
+ session->priv->authority = x_authority_new (family,
+ g_inet_address_to_bytes (G_INET_ADDRESS (x_server_address)),
+ g_inet_address_get_native_size (G_INET_ADDRESS (x_server_address)),
display_number,
authorization_name,
session_authorization_data,
#define XDMCP_SESSION_PRIVATE_H_
#include "xdmcp-server.h"
-#include "xauthority.h"
+#include "x-authority.h"
struct XDMCPSessionPrivate
{
#include <glib-object.h>
#include <gio/gio.h>
-#include "xauthority.h"
+#include "x-authority.h"
G_BEGIN_DECLS
+++ /dev/null
-/*
- * 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
- * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
- * license.
- */
-
-#ifndef XSERVER_LOCAL_H_
-#define XSERVER_LOCAL_H_
-
-#include "xserver.h"
-
-G_BEGIN_DECLS
-
-#define XSERVER_LOCAL_TYPE (xserver_local_get_type())
-#define XSERVER_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XSERVER_LOCAL_TYPE, XServerLocal))
-#define IS_XSERVER_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XSERVER_LOCAL_TYPE))
-
-typedef struct XServerLocalPrivate XServerLocalPrivate;
-
-typedef struct
-{
- XServer parent_instance;
- XServerLocalPrivate *priv;
-} XServerLocal;
-
-typedef struct
-{
- XServerClass parent_class;
-
- void (*ready)(XServerLocal *server);
-} XServerLocalClass;
-
-guint xserver_local_get_unused_display_number (void);
-
-void xserver_local_release_display_number (guint display_number);
-
-GType xserver_local_get_type (void);
-
-XServerLocal *xserver_local_new (void);
-
-void xserver_local_set_command (XServerLocal *server, const gchar *command);
-
-void xserver_local_set_config (XServerLocal *server, const gchar *path);
-
-void xserver_local_set_layout (XServerLocal *server, const gchar *layout);
-
-void xserver_local_set_allow_tcp (XServerLocal *server, gboolean allow_tcp);
-
-void xserver_local_set_xdmcp_server (XServerLocal *server, const gchar *hostname);
-
-const gchar *xserver_local_get_xdmcp_server (XServerLocal *server);
-
-void xserver_local_set_xdmcp_port (XServerLocal *server, guint port);
-
-guint xserver_local_get_xdmcp_port (XServerLocal *server);
-
-void xserver_local_set_xdmcp_key (XServerLocal *server, const gchar *key);
-
-void xserver_local_set_mir_id (XServerLocal *server, const gchar *id);
-
-const gchar *xserver_local_get_mir_id (XServerLocal *server);
-
-void xserver_local_set_mir_socket (XServerLocal *server, const gchar *socket);
-
-const gchar *xserver_local_get_authority_file_path (XServerLocal *server);
-
-G_END_DECLS
-
-#endif /* XSERVER_LOCAL_H_ */
+++ /dev/null
-/*
- * 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
- * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
- * license.
- */
-
-#ifndef XSERVER_XVNC_H_
-#define XSERVER_XVNC_H_
-
-#include "xserver.h"
-
-G_BEGIN_DECLS
-
-#define XSERVER_XVNC_TYPE (xserver_xvnc_get_type())
-#define XSERVER_XVNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XSERVER_XVNC_TYPE, XServerXVNC))
-#define IS_XSERVER_XVNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XSERVER_XVNC_TYPE))
-
-typedef struct XServerXVNCPrivate XServerXVNCPrivate;
-
-typedef struct
-{
- XServer parent_instance;
- XServerXVNCPrivate *priv;
-} XServerXVNC;
-
-typedef struct
-{
- XServerClass parent_class;
-
- void (*ready)(XServerXVNC *server);
-} XServerXVNCClass;
-
-GType xserver_xvnc_get_type (void);
-
-gboolean xserver_xvnc_check_available (void);
-
-XServerXVNC *xserver_xvnc_new (void);
-
-void xserver_xvnc_set_command (XServerXVNC *server, const gchar *command);
-
-void xserver_xvnc_set_socket (XServerXVNC *server, int fd);
-
-int xserver_xvnc_get_socket (XServerXVNC *server);
-
-void xserver_xvnc_set_geometry (XServerXVNC *server, gint width, gint height);
-
-void xserver_xvnc_set_depth (XServerXVNC *server, gint depth);
-
-const gchar *xserver_xvnc_get_authority_file_path (XServerXVNC *server);
-
-G_END_DECLS
-
-#endif /* XSERVER_XVNC_H_ */
+++ /dev/null
-/*
- * 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
- * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
- * license.
- */
-
-#ifndef XSERVER_H_
-#define XSERVER_H_
-
-#include <glib-object.h>
-#include "display-server.h"
-#include "xauthority.h"
-
-G_BEGIN_DECLS
-
-#define XSERVER_TYPE (xserver_get_type())
-#define XSERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XSERVER_TYPE, XServer))
-#define XSERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XSERVER_TYPE, XServerClass))
-#define XSERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XSERVER_TYPE, XServerClass))
-#define IS_XSERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XSERVER_TYPE))
-
-typedef struct XServerPrivate XServerPrivate;
-
-typedef struct
-{
- DisplayServer parent_instance;
- XServerPrivate *priv;
-} XServer;
-
-typedef struct
-{
- DisplayServerClass parent_class;
-} XServerClass;
-
-GType xserver_get_type (void);
-
-void xserver_set_hostname (XServer *server, const gchar *hostname);
-
-gchar *xserver_get_hostname (XServer *server);
-
-void xserver_set_display_number (XServer *server, guint number);
-
-guint xserver_get_display_number (XServer *server);
-
-const gchar *xserver_get_address (XServer *server);
-
-const gchar *xserver_get_authentication_name (XServer *server);
-
-const guint8 *xserver_get_authentication_data (XServer *server);
-
-gsize xserver_get_authentication_data_length (XServer *server);
-
-void xserver_set_authority (XServer *server, XAuthority *authority);
-
-XAuthority *xserver_get_authority (XServer *server);
-
-G_END_DECLS
-
-#endif /* XSERVER_H_ */