diff --git a/common/gdm-common.c b/common/gdm-common.c index 31fc810..fbf5978 100644 --- a/common/gdm-common.c +++ b/common/gdm-common.c @@ -591,6 +591,8 @@ gdm_get_script_environment (const char *username, if (display_hostname) { g_hash_table_insert (hash, g_strdup ("REMOTE_HOST"), g_strdup (display_hostname)); + } else { + g_hash_table_insert (hash, g_strdup ("XAUTHLOCALHOSTNAME"), gdm_gethostname ()); } /* Runs as root */ @@ -797,3 +799,14 @@ gdm_shell_expand (const char *str, } return g_string_free (s, FALSE); } + +char * +gdm_gethostname (void) +{ + char localhost[HOST_NAME_MAX + 1] = ""; + if (gethostname (localhost, HOST_NAME_MAX) == 0) { + return g_strdup (localhost); + } else { + return g_strdup ("localhost"); + } +} diff --git a/common/gdm-common.h b/common/gdm-common.h index 8d83a12..bc13d70 100644 --- a/common/gdm-common.h +++ b/common/gdm-common.h @@ -54,6 +54,7 @@ const char * gdm_make_temp_dir (char *template); char *gdm_generate_random_bytes (gsize size, GError **error); gboolean gdm_goto_login_session (GError **error); +char *gdm_gethostname (void); GPtrArray *gdm_get_script_environment (const char *username, const char *display_name, diff --git a/daemon/gdm-display-access-file.c b/daemon/gdm-display-access-file.c index 02ec0a0..5cc18a4 100644 --- a/daemon/gdm-display-access-file.c +++ b/daemon/gdm-display-access-file.c @@ -443,13 +443,10 @@ _get_auth_info_for_display (GdmDisplayAccessFile *file, * * https://bugs.freedesktop.org/show_bug.cgi?id=43425 */ - char localhost[HOST_NAME_MAX + 1] = ""; *family = FamilyLocal; - if (gethostname (localhost, HOST_NAME_MAX) == 0) { - *address = g_strdup (localhost); - } else { - *address = g_strdup ("localhost"); - } + /* using the new function we create in the patch, to detect + * changes here, in the original code */ + *address = gdm_gethostname (); } else { *family = FamilyWild; gdm_display_get_remote_hostname (display, address, NULL); diff --git a/daemon/gdm-launch-environment.c b/daemon/gdm-launch-environment.c index a30276b..fded306 100644 --- a/daemon/gdm-launch-environment.c +++ b/daemon/gdm-launch-environment.c @@ -194,6 +194,11 @@ build_launch_environment (GdmLaunchEnvironment *launch_environment, g_hash_table_insert (hash, g_strdup ("GDM_SEAT_ID"), g_strdup (seat_id)); } + if (launch_environment->priv->x11_display_is_local) { + g_hash_table_remove (hash, "XAUTHLOCALHOSTNAME"); + g_hash_table_insert (hash, g_strdup ("XAUTHLOCALHOSTNAME"), gdm_gethostname ()); + } + g_hash_table_insert (hash, g_strdup ("PATH"), g_strdup (g_getenv ("PATH"))); g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true")); diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c index b839fea..83fb807 100644 --- a/daemon/gdm-session.c +++ b/daemon/gdm-session.c @@ -2548,6 +2548,14 @@ set_up_session_environment (GdmSession *self) } } + if (self->priv->display_is_local) { + char *hostname = gdm_gethostname (); + gdm_session_set_environment_variable (self, + "XAUTHLOCALHOSTNAME", + hostname); + g_free (hostname); + } + if (g_getenv ("WINDOWPATH") != NULL) { gdm_session_set_environment_variable (self, "WINDOWPATH",