File lightdm-xauthlocalhostname-support.patch of Package lightdm
Set XAUTHLOCALHOSTNAME to the hostname 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
@@ -74,7 +74,9 @@ lightdm_SOURCES = \
xdmcp-session.h \
xdmcp-session-private.h \
opensuse-sysconfig.c \
- opensuse-sysconfig.h
+ opensuse-sysconfig.h \
+ util.c \
+ util.h
lightdm_CFLAGS = \
$(LIGHTDM_CFLAGS) \
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 "x-server-local.h"
#include "plymouth.h"
#include "vt.h"
+#include "util.h"
G_DEFINE_TYPE (SeatXLocal, seat_xlocal, SEAT_TYPE);
@@ -235,12 +236,16 @@ static void
seat_xlocal_run_script (Seat *seat, DisplayServer *display_server, Process *script)
{
const gchar *path;
+ gchar *hostname;
XServerLocal *x_server;
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);
+ hostname = lightdm_gethostname ();
+ process_set_env (script, "XAUTHLOCALHOSTNAME", hostname);
+ g_free (hostname);
SEAT_CLASS (seat_xlocal_parent_class)->run_script (seat, display_server, script);
}
diff --git a/src/util.c b/src/util.c
new file mode 100644
--- /dev/null
+++ b/src/util.c
@@ -0,0 +1,15 @@
+#include <unistd.h>
+#include <limits.h>
+#include <glib.h>
+#include "util.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/x-server-local.c b/src/x-server-local.c
--- a/src/x-server-local.c
+++ b/src/x-server-local.c
@@ -22,6 +22,7 @@
#include "configuration.h"
#include "process.h"
#include "vt.h"
+#include "util.h"
struct XServerLocalPrivate
{
@@ -152,13 +153,14 @@ XServerLocal *
x_server_local_new (void)
{
XServerLocal *self = g_object_new (X_SERVER_LOCAL_TYPE, NULL);
- gchar hostname[1024], *number, *name;
+ gchar *hostname, *number, *name;
x_server_set_display_number (X_SERVER (self), x_server_local_get_unused_display_number ());
- gethostname (hostname, 1024);
+ hostname = lightdm_gethostname ();
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 (hostname);
g_free (number);
name = g_strdup_printf ("x-%d", x_server_get_display_number (X_SERVER (self)));
diff --git a/src/x-server.c b/src/x-server.c
--- a/src/x-server.c
+++ b/src/x-server.c
@@ -15,6 +15,8 @@
#include "x-server.h"
#include "configuration.h"
+#include "x-server-local.h"
+#include "util.h"
struct XServerPrivate
{
@@ -168,6 +170,12 @@ x_server_connect_session (DisplayServer
else
l_debug (session, "Not setting XDG_VTNR");
+ if (IS_X_SERVER_LOCAL (display_server))
+ {
+ gchar *hostname = lightdm_gethostname ();
+ session_set_env (session, "XAUTHLOCALHOSTNAME", hostname);
+ g_free (hostname);
+ }
session_set_env (session, "DISPLAY", 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)));