diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2011-07-15 13:24:59 +1000 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2011-07-15 13:24:59 +1000 |
commit | fef3f1e4f9b59833547a48c807d15488435529f1 (patch) | |
tree | a6b15ef8c1b19df73719daf9e3fa5bdf07700f29 | |
parent | 3203e824c886212a2975b4a5333d95f46ef0fcaf (diff) | |
download | lightdm-git-lightdm-0.4.4.tar.gz |
Allow xauth to be in system location againlightdm-0.4.4
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | configure.ac | 23 | ||||
-rw-r--r-- | data/lightdm.conf | 18 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/display-manager.c | 72 | ||||
-rw-r--r-- | src/lightdm.c | 39 | ||||
-rw-r--r-- | src/session.c | 31 | ||||
-rw-r--r-- | src/xauth.c | 33 | ||||
-rw-r--r-- | src/xauth.h | 11 | ||||
-rw-r--r-- | src/xserver.c | 53 | ||||
-rw-r--r-- | src/xserver.h | 4 |
11 files changed, 131 insertions, 162 deletions
@@ -3,9 +3,10 @@ Overview of changes in lightdm 0.4.4 * Fix failure to accept XDMCP connections due to invalid assert. * Allow minimum-display-number to be set in lightdm.conf and on the command line. - * Write session X authority information to ~/.Xauthority - this fixes it not - being able to be used with the xauth util and allows you to have more than - one authorization. + * Session X authority now written to ~/.Xauthority by default. It can be + configured to run from the system location by setting + user-authority-in-system-dir=true in lightdm.conf. + * When using system authority the authority can be updated by the user. * Written X authority files now checks hostname and display number. * Enironment is no longer passed through to X servers and sessions, this is no longer required now PAM works correctly. diff --git a/configure.ac b/configure.ac index c67916a3..be22b762 100644 --- a/configure.ac +++ b/configure.ac @@ -150,6 +150,16 @@ AC_ARG_WITH(log-dir, ) AC_SUBST(LOG_DIR) +RUN_DIR=$localstatedir/run/lightdm +AC_ARG_WITH(xauth-dir, + AS_HELP_STRING(--with-run-dir=<dir>, + Directory to put running state in), + if test x$withval != x; then + RUN_DIR="$withval" + fi +) +AC_SUBST(RUN_DIR) + CACHE_DIR=${localstatedir}/cache/lightdm AC_ARG_WITH(cache-dir, AS_HELP_STRING(--with-cache-dir=<dir>, @@ -181,16 +191,6 @@ AC_ARG_WITH(xserver-binary, AC_SUBST(XSERVER_BINARY) AC_DEFINE_UNQUOTED(XSERVER_BINARY, "$XSERVER_BINARY", X server binary name) -XAUTH_DIR=$localstatedir/run/lightdm/authority -AC_ARG_WITH(xauth-dir, - AS_HELP_STRING(--with-xauth-dir=<dir>, - X server authorization directory), - if test x$withval != x; then - XAUTH_DIR="$withval" - fi -) -AC_SUBST(XAUTH_DIR) - XSESSIONS_DIR=/usr/share/xsessions AC_ARG_WITH(xsession-dir, AS_HELP_STRING(--with-xsession-dir=<dir>, @@ -327,7 +327,8 @@ echo " Log directory: $LOG_DIR D-Bus system directory: $DBUS_SYS_DIR X server binary: $XSERVER_BINARY - X authorization dir: $XAUTH_DIR + Run dir: $RUN_DIR + Cache dir: $CACHE_DIR X session dir: $XSESSIONS_DIR Default X session: $DEFAULT_XSESSION Greeter user: $GREETER_USER diff --git a/data/lightdm.conf b/data/lightdm.conf index eede4610..4f8f96ba 100644 --- a/data/lightdm.conf +++ b/data/lightdm.conf @@ -3,33 +3,35 @@ # # xserver = X server to run (FIXME) # default-xserver-command = Default X server command (FIXME) -# authorization-directory = Directory to store X authorization files # log-directory = Directory to log information to # theme-directory = Directory to load themes from # theme-engine-directory = Directory to load theme engines from # default-greeter-theme = Default greeter theme to use +# run-directory = Directory to put running state in # cache-directory = Directory to cache to # xsessions-directory = Directory to find X sessions # default-xsession Default X session to use # session-wrapper = Program to run sessions through # minimum-display-number = Minimum display number to use for X servers # minimum-vt = First VT to run displays on +# user-authority-in-system-dir = True if session authority should be in the system location # seats = list of seats to start displays on # [LightDM] #xserver=default-xserver #default-xserver-command= -#authorization-directory=/var/cache/lightdm/authority #log-directory=/var/log/lightdm #theme-directory=/usr/share/lightdm/themes #theme-engine-directory=/usr/libexec/lightdm #default-greeter-theme= +#run-directory=/var/run/lightdm #cache-directory=/var/cache/lightdm #xsessions-directory=/usr/share/xsessions #default-xsession= #session-wrapper=/etc/X11/Xsession #minimum-display-number=0 #minimum-vt=7 +#user-authority-in-system-dir=false seats=seat-0 # @@ -74,7 +76,7 @@ seats=seat-0 # # User manager configuration # -# load-users = true if can provide user list to greeter +# load-users = True if can provide user list to greeter # minimum-uid = Minimum UID required to be shown in greeter # hidden-users = Users that are not shown to the user # hidden-shells = Shells that indicate a user cannot login @@ -88,10 +90,10 @@ seats=seat-0 # # Guest account configuration # -# enabled = true if guest account is enabled -# username = username of guest account -# setup-script = script to be run to setup guest account -# cleanup-script = script to be run to cleanup guest account +# enabled = True if guest account is enabled +# username = Username of guest account +# setup-script = Script to be run to setup guest account +# cleanup-script = Script to be run to cleanup guest account # [GuestAccount] #enabled=false @@ -102,7 +104,7 @@ seats=seat-0 # # XDMCP Server configuration # -# enabled = true if XDMCP connections should be allowed +# enabled = True if XDMCP connections should be allowed # port = UDP/IP port to listen for connections on # key = Authentication key to use for XDM-AUTHENTICATION-1 or blank to not use authentication # diff --git a/src/Makefile.am b/src/Makefile.am index a8af67fa..554e180c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -57,7 +57,7 @@ lightdm_CFLAGS = \ -DDEFAULT_CONFIG_FILE=\"$(DEFAULT_CONFIG_FILE)\" \ -DLOG_DIR=\"$(LOG_DIR)\" \ -DGREETER_THEME_ENGINE_DIR=\"$(libexecdir)\" \ - -DXAUTH_DIR=\"$(XAUTH_DIR)\" \ + -DRUN_DIR=\"$(RUN_DIR)\" \ -DCACHE_DIR=\"$(CACHE_DIR)\" \ -DGREETER_THEME_DIR=\"$(GREETER_THEME_DIR)\" \ -DLIGHTDM_BINARY=\"lightdm\" diff --git a/src/display-manager.c b/src/display-manager.c index 7f2f1c64..a61c71c9 100644 --- a/src/display-manager.c +++ b/src/display-manager.c @@ -13,8 +13,6 @@ #include <stdlib.h> #include <string.h> -#include <xcb/xcb.h> -#include <fcntl.h> #include "display-manager.h" #include "configuration.h" @@ -35,12 +33,6 @@ static guint signals[LAST_SIGNAL] = { 0 }; struct DisplayManagerPrivate { - /* Directory to store authorization files */ - gchar *auth_dir; - - /* Counter to generate unique authorization file names */ - guint auth_counter; - /* Directory to write log files to */ gchar *log_dir; @@ -61,7 +53,6 @@ display_manager_new (void) { DisplayManager *self = g_object_new (DISPLAY_MANAGER_TYPE, NULL); - self->priv->auth_dir = config_get_string (config_get_instance (), "LightDM", "authorization-directory"); self->priv->log_dir = config_get_string (config_get_instance (), "LightDM", "log-directory"); return self; @@ -99,17 +90,6 @@ get_free_display_number (DisplayManager *manager) return display_number; } -static gchar * -get_authorization_path (DisplayManager *manager) -{ - gchar *path; - - path = g_strdup_printf ("%s/%d", manager->priv->auth_dir, manager->priv->auth_counter); - manager->priv->auth_counter++; - - return path; -} - static void start_session (Display *display, Session *session, gboolean is_greeter, DisplayManager *manager) { @@ -202,7 +182,7 @@ end_session_cb (Display *display, Session *session, DisplayManager *manager) authorization = xauth_new_cookie (xauth_get_family (old_authorization), xauth_get_address (old_authorization), xauth_get_number (old_authorization)); - xserver_set_authorization (xserver, authorization, xserver_get_authorization_path (xserver)); + xserver_set_authorization (xserver, authorization); g_object_unref (authorization); } } @@ -315,10 +295,8 @@ make_xserver (DisplayManager *manager, gchar *config_section) xserver_set_command (xserver, command); g_free (command); - path = get_authorization_path (manager); - xserver_set_authorization (xserver, authorization, path); + xserver_set_authorization (xserver, authorization); g_object_unref (authorization); - g_free (path); filename = g_strdup_printf ("%s.log", xserver_get_address (xserver)); path = g_build_filename (manager->priv->log_dir, filename, NULL); @@ -480,7 +458,6 @@ xdmcp_session_cb (XDMCPServer *server, XDMCPSession *session, DisplayManager *ma if (strcmp (xdmcp_session_get_authorization_name (session), "") != 0) { XAuthorization *authorization = NULL; - gchar *path; gchar *number; number = g_strdup_printf ("%d", xdmcp_session_get_display_number (session)); @@ -491,12 +468,9 @@ xdmcp_session_cb (XDMCPServer *server, XDMCPSession *session, DisplayManager *ma xdmcp_session_get_authorization_data (session), xdmcp_session_get_authorization_data_length (session)); g_free (number); - path = get_authorization_path (manager); - - xserver_set_authorization (xserver, authorization, path); + xserver_set_authorization (xserver, authorization); g_object_unref (authorization); - g_free (path); } result = display_start (display); @@ -507,43 +481,6 @@ xdmcp_session_cb (XDMCPServer *server, XDMCPSession *session, DisplayManager *ma return result; } -static void -setup_auth_dir (DisplayManager *manager) -{ - GDir *dir; - GError *error = NULL; - - g_mkdir_with_parents (manager->priv->auth_dir, S_IRWXU | S_IXGRP | S_IXOTH); - dir = g_dir_open (manager->priv->auth_dir, 0, &error); - if (!dir) - { - g_warning ("Authorization dir not created: %s", error->message); - g_clear_error (&error); - return; - } - - /* Clear out the directory */ - while (TRUE) - { - const gchar *filename; - gchar *path; - GFile *file; - - filename = g_dir_read_name (dir); - if (!filename) - break; - - path = g_build_filename (manager->priv->auth_dir, filename, NULL); - file = g_file_new_for_path (filename); - g_file_delete (file, NULL, NULL); - - g_free (path); - g_object_unref (file); - } - - g_dir_close (dir); -} - static gboolean plymouth_run_command (const gchar *command, gint *exit_status) { @@ -598,9 +535,6 @@ display_manager_start (DisplayManager *manager) g_return_if_fail (manager != NULL); - /* Make an empty authorization directory */ - setup_auth_dir (manager); - /* Load the static display entries */ seats = config_get_string (config_get_instance (), "LightDM", "seats"); /* Fallback to the old name for seats, this will be removed before 1.0 */ diff --git a/src/lightdm.c b/src/lightdm.c index 4abe1f10..707f1ce6 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -16,6 +16,7 @@ #include <glib.h> #include <glib/gi18n.h> #include <unistd.h> +#include <fcntl.h> #include "configuration.h" #include "display-manager.h" @@ -251,6 +252,7 @@ main(int argc, char **argv) gchar *theme_dir = g_strdup (GREETER_THEME_DIR), *theme_engine_dir = g_strdup (GREETER_THEME_ENGINE_DIR); gchar *default_greeter_theme = g_strdup (DEFAULT_GREETER_THEME); gchar *xsessions_dir = g_strdup (XSESSIONS_DIR); + gchar *run_dir = g_strdup (RUN_DIR); gchar *cache_dir = g_strdup (CACHE_DIR); gchar *default_xsession = g_strdup (DEFAULT_XSESSION); gchar *minimum_display_number = NULL; @@ -281,6 +283,9 @@ main(int argc, char **argv) { "default-xserver-command", 0, 0, G_OPTION_ARG_STRING, &default_xserver_command, /* Help string for command line --default-xserver-command flag */ N_("Default command to run X servers"), "COMMAND" }, + { "run-dir", 0, 0, G_OPTION_ARG_STRING, &run_dir, + /* Help string for command line --run-dir flag */ + N_("Directory to store run information"), "DIRECTORY" }, { "cache-dir", 0, 0, G_OPTION_ARG_STRING, &cache_dir, /* Help string for command line --cache-dir flag */ N_("Directory to cache information"), "DIRECTORY" }, @@ -348,14 +353,6 @@ main(int argc, char **argv) theme_engine_dir = path_make_absolute (theme_engine_dir); xsessions_dir = path_make_absolute (xsessions_dir); - /* Write PID file */ - pid_file = fopen (pid_path, "w"); - if (pid_file) - { - fprintf (pid_file, "%d\n", getpid ()); - fclose (pid_file); - } - /* Check if root */ if (!no_root && getuid () != 0) { @@ -384,6 +381,18 @@ main(int argc, char **argv) return EXIT_FAILURE; } + /* Write PID file */ + pid_file = fopen (pid_path, "w"); + if (pid_file) + { + fprintf (pid_file, "%d\n", getpid ()); + fclose (pid_file); + } + + /* Create run and cache directories */ + g_mkdir_with_parents (run_dir, S_IRWXU | S_IXGRP | S_IXOTH); + g_mkdir_with_parents (cache_dir, S_IRWXU | S_IXGRP | S_IXOTH); + loop = g_main_loop_new (NULL, FALSE); g_bus_own_name (no_root ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM, @@ -414,7 +423,7 @@ main(int argc, char **argv) config_set_string (config_get_instance (), "LightDM", "theme-directory", theme_dir); config_set_string (config_get_instance (), "LightDM", "theme-engine-directory", theme_engine_dir); config_set_string (config_get_instance (), "LightDM", "default-greeter-theme", default_greeter_theme); - config_set_string (config_get_instance (), "LightDM", "authorization-directory", XAUTH_DIR); + config_set_string (config_get_instance (), "LightDM", "run-directory", run_dir); config_set_string (config_get_instance (), "LightDM", "cache-directory", cache_dir); config_set_string (config_get_instance (), "LightDM", "xsessions-directory", xsessions_dir); config_set_string (config_get_instance (), "LightDM", "default-xsession", default_xsession); @@ -425,10 +434,16 @@ main(int argc, char **argv) if (no_root) { gchar *path; - path = g_build_filename (g_get_user_cache_dir (), "lightdm", "authority", NULL); - config_set_string (config_get_instance (), "LightDM", "authorization-directory", path); + + path = g_build_filename (g_get_user_cache_dir (), "lightdm", "run", NULL); + config_set_string (config_get_instance (), "LightDM", "run-directory", path); g_free (path); - path = g_build_filename (g_get_user_cache_dir (), "lightdm", NULL); + + path = g_build_filename (g_get_user_cache_dir (), "lightdm", "cache", NULL); + config_set_string (config_get_instance (), "LightDM", "cache-directory", path); + g_free (path); + + path = g_build_filename (g_get_user_cache_dir (), "lightdm", "log", NULL); config_set_string (config_get_instance (), "LightDM", "log-directory", path); g_free (path); } diff --git a/src/session.c b/src/session.c index ee3bc9de..906945cf 100644 --- a/src/session.c +++ b/src/session.c @@ -10,6 +10,8 @@ */ #include <stdlib.h> +#include <string.h> +#include <errno.h> #include <unistd.h> #include <sys/wait.h> #include <fcntl.h> @@ -17,6 +19,7 @@ #include <grp.h> #include "session.h" +#include "configuration.h" struct SessionPrivate { @@ -133,13 +136,35 @@ session_start (Session *session, gboolean create_pipe) if (session->priv->authorization) { gchar *path; + + if (config_get_boolean (config_get_instance (), "LightDM", "user-authority-in-system-dir")) + { + gchar *run_dir, *dir; + + run_dir = config_get_string (config_get_instance (), "LightDM", "run-directory"); + dir = g_build_filename (run_dir, user_get_name (session->priv->user), NULL); + g_free (run_dir); + + g_mkdir_with_parents (dir, S_IRWXU); + if (getuid () == 0) + { + if (chown (dir, user_get_uid (session->priv->user), user_get_gid (session->priv->user)) < 0) + g_warning ("Failed to set ownership of user authorization dir: %s", strerror (errno)); + } + + path = g_build_filename (dir, "xauthority", NULL); + g_free (dir); + + child_process_set_env (CHILD_PROCESS (session), "XAUTHORITY", path); + } + else + path = g_build_filename (user_get_home_directory (session->priv->user), ".Xauthority", NULL); - path = g_build_filename (user_get_home_directory (session->priv->user), ".Xauthority", NULL); session->priv->authorization_file = g_file_new_for_path (path); g_free (path); g_debug ("Adding session authority to %s", g_file_get_path (session->priv->authorization_file)); - if (!xauth_update (session->priv->authorization, session->priv->user, session->priv->authorization_file, &error)) + if (!xauth_write (session->priv->authorization, XAUTH_WRITE_MODE_REPLACE, session->priv->user, session->priv->authorization_file, &error)) g_warning ("Failed to write authorization: %s", error->message); g_clear_error (&error); } @@ -184,7 +209,7 @@ session_finalize (GObject *object) if (self->priv->authorization_file) { g_debug ("Removing session authority from %s", g_file_get_path (self->priv->authorization_file)); - xauth_remove (self->priv->authorization, self->priv->user, self->priv->authorization_file, NULL); + xauth_write (self->priv->authorization, XAUTH_WRITE_MODE_REMOVE, self->priv->user, self->priv->authorization_file, NULL); g_object_unref (self->priv->authorization_file); } diff --git a/src/xauth.c b/src/xauth.c index 72df2ca3..4cec4abf 100644 --- a/src/xauth.c +++ b/src/xauth.c @@ -231,19 +231,22 @@ write_string (GOutputStream *stream, const gchar *value, GError **error) write_data (stream, (guint8 *) value, strlen (value), error); } -static gboolean -xauth_merge (XAuthorization *auth, gboolean delete, User *user, GFile *file, GError **error) +gboolean +xauth_write (XAuthorization *auth, XAuthWriteMode mode, User *user, GFile *file, GError **error) { GList *link, *records = NULL; - GFileInputStream *input_stream; + GFileInputStream *input_stream = NULL; GFileOutputStream *output_stream; XAuthorization *a; gboolean matched = FALSE; /* Read out existing records */ - input_stream = g_file_read (file, NULL, error); - if (!input_stream && error && !g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) - return FALSE; + if (mode != XAUTH_WRITE_MODE_SET) + { + input_stream = g_file_read (file, NULL, error); + if (!input_stream && error && !g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) + return FALSE; + } while (input_stream) { @@ -276,7 +279,7 @@ xauth_merge (XAuthorization *auth, gboolean delete, User *user, GFile *file, GEr strcmp (auth->priv->number, a->priv->number) == 0) { matched = TRUE; - if (delete) + if (mode == XAUTH_WRITE_MODE_REMOVE) { g_object_unref (a); continue; @@ -337,22 +340,6 @@ xauth_merge (XAuthorization *auth, gboolean delete, User *user, GFile *file, GEr return TRUE; } -gboolean -xauth_update (XAuthorization *auth, User *user, GFile *file, GError **error) -{ - g_return_val_if_fail (auth != NULL, FALSE); - g_return_val_if_fail (file != NULL, FALSE); - return xauth_merge (auth, FALSE, user, file, error); -} - -gboolean -xauth_remove (XAuthorization *auth, User *user, GFile *file, GError **error) -{ - g_return_val_if_fail (auth != NULL, FALSE); - g_return_val_if_fail (file != NULL, FALSE); - return xauth_merge (auth, TRUE, user, file, error); -} - static void xauth_init (XAuthorization *auth) { diff --git a/src/xauth.h b/src/xauth.h index 6f4b3ae6..964207d3 100644 --- a/src/xauth.h +++ b/src/xauth.h @@ -46,6 +46,13 @@ typedef struct #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); XAuthorization *xauth_new (guint16 family, const gchar *address, const gchar *number, const gchar *name, const guint8 *data, gsize data_length); @@ -76,9 +83,7 @@ guint8 *xauth_copy_authorization_data (XAuthorization *auth); gsize xauth_get_authorization_data_length (XAuthorization *auth); -gboolean xauth_update (XAuthorization *auth, User *user, GFile *file, GError **error); - -gboolean xauth_remove (XAuthorization *auth, User *user, GFile *file, GError **error); +gboolean xauth_write (XAuthorization *auth, XAuthWriteMode mode, User *user, GFile *file, GError **error); G_END_DECLS diff --git a/src/xserver.c b/src/xserver.c index 2be2ef14..2f89e168 100644 --- a/src/xserver.c +++ b/src/xserver.c @@ -21,6 +21,7 @@ #include <glib/gstdio.h> #include "xserver.h" +#include "configuration.h" enum { READY, @@ -65,7 +66,6 @@ struct XServerPrivate /* Authorization */ XAuthorization *authorization; - gchar *authorization_path; GFile *authorization_file; /* VT to run on */ @@ -252,22 +252,32 @@ xserver_get_authentication_data_length (XServer *server) static void write_authorization_file (XServer *server) { + gchar *run_dir, *dir, *path; GError *error = NULL; /* Stop if not using authorization or already written */ if (!server->priv->authorization || server->priv->authorization_file) return; - g_debug ("Writing X server authorization to %s", server->priv->authorization_path); + run_dir = config_get_string (config_get_instance (), "LightDM", "run-directory"); + dir = g_build_filename (run_dir, "root", NULL); + g_free (run_dir); + g_mkdir_with_parents (dir, S_IRWXU); - server->priv->authorization_file = g_file_new_for_path (server->priv->authorization_path); - if (!xauth_update (server->priv->authorization, NULL, server->priv->authorization_file, &error)) + path = g_build_filename (dir, xserver_get_address (server), NULL); + g_free (dir); + server->priv->authorization_file = g_file_new_for_path (path); + + g_debug ("Writing X server authorization to %s", path); + g_free (path); + + if (!xauth_write (server->priv->authorization, XAUTH_WRITE_MODE_SET, NULL, server->priv->authorization_file, &error)) g_warning ("Failed to write authorization: %s", error->message); g_clear_error (&error); } void -xserver_set_authorization (XServer *server, XAuthorization *authorization, const gchar *path) +xserver_set_authorization (XServer *server, XAuthorization *authorization) { gboolean rewrite = FALSE; @@ -288,13 +298,6 @@ xserver_set_authorization (XServer *server, XAuthorization *authorization, const if (authorization) server->priv->authorization = g_object_ref (authorization); - /* Update path if it has changed */ - if (path != server->priv->authorization_path) - { - g_free (server->priv->authorization_path); - server->priv->authorization_path = g_strdup (path); - } - /* If already running then change authorization immediately */ if (rewrite) write_authorization_file (server); @@ -307,13 +310,6 @@ xserver_get_authorization (XServer *server) return server->priv->authorization; } -const gchar * -xserver_get_authorization_path (XServer *server) -{ - g_return_val_if_fail (server != NULL, NULL); - return server->priv->authorization_path; -} - void xserver_set_vt (XServer *server, gint vt) { @@ -349,8 +345,10 @@ xserver_connect (XServer *server) * for XDM-AUTHORIZATION-1 and the authorization data requires to know the source port */ if (server->priv->authorization_file) { + gchar *path = g_file_get_path (server->priv->authorization_file); xauthority = g_strdup (getenv ("XAUTHORITY")); - setenv ("XAUTHORITY", server->priv->authorization_path, TRUE); + setenv ("XAUTHORITY", path, TRUE); + g_free (path); } g_debug ("Connecting to XServer %s", xserver_get_address (server)); @@ -424,6 +422,9 @@ xserver_start (XServer *server) command = g_string_new (absolute_command); g_free (absolute_command); + /* Write the authorization file */ + write_authorization_file (server); + g_string_append_printf (command, " :%d", server->priv->display_number); if (server->priv->config_file) @@ -433,8 +434,12 @@ xserver_start (XServer *server) g_string_append_printf (command, " -layout %s", server->priv->layout); if (server->priv->authorization) - g_string_append_printf (command, " -auth %s", server->priv->authorization_path); - + { + gchar *path = g_file_get_path (server->priv->authorization_file); + g_string_append_printf (command, " -auth %s", path); + g_free (path); + } + if (server->priv->type == XSERVER_TYPE_LOCAL_TERMINAL) { if (server->priv->port != 0) @@ -461,9 +466,6 @@ xserver_start (XServer *server) if (server->priv->no_root) g_string_append (command, " -background none"); - /* Write the authorization file */ - write_authorization_file (server); - g_debug ("Launching X Server"); /* If running inside another display then pass through those variables */ @@ -551,7 +553,6 @@ xserver_finalize (GObject *object) g_free (self->priv->address); if (self->priv->authorization) g_object_unref (self->priv->authorization); - g_free (self->priv->authorization_path); if (self->priv->authorization_file) { g_file_delete (self->priv->authorization_file, NULL, NULL); diff --git a/src/xserver.h b/src/xserver.h index b6aaeff0..1bfa20f8 100644 --- a/src/xserver.h +++ b/src/xserver.h @@ -89,12 +89,10 @@ const guchar *xserver_get_authentication_data (XServer *server); gsize xserver_get_authentication_data_length (XServer *server); -void xserver_set_authorization (XServer *server, XAuthorization *authorization, const gchar *path); +void xserver_set_authorization (XServer *server, XAuthorization *authorization); XAuthorization *xserver_get_authorization (XServer *server); -const gchar *xserver_get_authorization_path (XServer *server); - void xserver_set_vt (XServer *server, gint vt); gint xserver_get_vt (XServer *server); |