File lightdm-xauthlocalhostname-support.patch of Package lightdm
set XAUTHLOCALHOSTNAME to localhost for local logins to avoid issues in the session in case the hostname changes
diff --git a/src/Makefile.am b/src/Makefile.am
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,6 +50,8 @@ lightdm_SOURCES = \
session.h \
session-child.c \
session-child.h \
+ util.c \
+ util.h \
vnc-server.c \
vnc-server.h \
vt.c \
diff --git a/src/seat-xlocal.c b/src/seat-xlocal.c
--- a/src/seat-xlocal.c
+++ b/src/seat-xlocal.c
@@ -16,6 +16,7 @@
#include "xserver-local.h"
#include "xsession.h"
#include "vt.h"
+#include "util.h"
G_DEFINE_TYPE (SeatXLocal, seat_xlocal, SEAT_TYPE);
@@ -134,14 +135,17 @@ seat_xlocal_set_active_display (Seat *se
static void
seat_xlocal_run_script (Seat *seat, Display *display, Process *script)
{
- gchar *path;
+ gchar *path, *hostname;
XServerLocal *xserver;
xserver = XSERVER_LOCAL (display_get_display_server (display));
path = xserver_local_get_authority_file_path (xserver);
+ hostname = lightdm_gethostname ();
process_set_env (script, "DISPLAY", xserver_get_address (XSERVER (xserver)));
process_set_env (script, "XAUTHORITY", path);
+ process_set_env (script, "XAUTHLOCALHOSTNAME", hostname);
g_free (path);
+ g_free (hostname);
SEAT_CLASS (seat_xlocal_parent_class)->run_script (seat, display, script);
}
diff --git a/src/util.c b/src/util.c
new file mode 100644
--- /dev/null
+++ b/src/util.c
@@ -0,0 +1,14 @@
+#include <unistd.h>
+#include <limits.h>
+#include <glib.h>
+
+gchar *
+lightdm_gethostname (void)
+{
+ gchar hostname[HOST_NAME_MAX + 1];
+
+ if (gethostname (hostname, HOST_NAME_MAX) == 0)
+ return g_strdup (hostname);
+
+ return g_strdup ("localhost");
+}
diff --git a/src/util.h b/src/util.h
new file mode 100644
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,3 @@
+#include <glib.h>
+
+gchar * lightdm_gethostname (void);
diff --git a/src/xserver-local.c b/src/xserver-local.c
--- a/src/xserver-local.c
+++ b/src/xserver-local.c
@@ -21,6 +21,7 @@
#include "process.h"
#include "vt.h"
#include "plymouth.h"
+#include "util.h"
struct XServerLocalPrivate
{
@@ -397,7 +398,7 @@ xserver_local_start (DisplayServer *disp
XServerLocal *server = XSERVER_LOCAL (display_server);
gboolean result;
gchar *filename, *dir, *absolute_command;
- gchar hostname[1024], *number;
+ gchar *hostname, *number;
GString *command;
g_return_val_if_fail (server->priv->xserver_process == NULL, FALSE);
@@ -438,11 +439,13 @@ xserver_local_start (DisplayServer *disp
if (server->priv->layout)
g_string_append_printf (command, " -layout %s", server->priv->layout);
- gethostname (hostname, 1024);
+ hostname = lightdm_gethostname ();
+
number = g_strdup_printf ("%d", xserver_get_display_number (XSERVER (server)));
if (!server->priv->xdmcp_key)
xserver_set_authority (XSERVER (server), xauth_new_cookie (XAUTH_FAMILY_LOCAL, (guint8*) hostname, strlen (hostname), number));
g_free (number);
+ g_free (hostname);
write_authority_file (server);
if (server->priv->authority_file)
{
diff --git a/src/xsession.c b/src/xsession.c
--- a/src/xsession.c
+++ b/src/xsession.c
@@ -15,8 +15,10 @@
#include <sys/stat.h>
#include "xsession.h"
+#include "xserver-local.h"
#include "configuration.h"
#include "privileges.h"
+#include "util.h"
struct XSessionPrivate
{
@@ -35,6 +37,12 @@ xsession_new (XServer *xserver)
session = g_object_new (XSESSION_TYPE, NULL);
session->priv->xserver = g_object_ref (xserver);
+ if (IS_XSERVER_LOCAL (XSESSION (session)->priv->xserver))
+ {
+ gchar *hostname = lightdm_gethostname ();
+ session_set_env (SESSION (session), "XAUTHLOCALHOSTNAME", hostname);
+ g_free (hostname);
+ }
session_set_env (SESSION (session), "DISPLAY", xserver_get_address (xserver));
session_set_tty (SESSION (session), xserver_get_address (xserver));
session_set_xdisplay (SESSION (session), xserver_get_address (xserver));