Blob Blame History Raw
From d8a1083e983478818e2d7b139cf0ab809c10b1b4 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 8 Jan 2014 11:46:24 -0500
Subject: [PATCH] worker: ignore '' username

Some PAM modules set a "" username to mean "user not set yet",
apparently, instead of NULL.

This commit guards against that to prevent a crash.

Red-Hat-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=965370

https://bugzilla.gnome.org/show_bug.cgi?id=721803
---
 daemon/gdm-session-worker.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index dd58af7..ad1b077 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -628,60 +628,61 @@ gdm_session_worker_update_username (GdmSessionWorker *worker)
         username = NULL;
         res = gdm_session_worker_get_username (worker, &username);
         if (res) {
                 g_debug ("GdmSessionWorker: old-username='%s' new-username='%s'",
                          worker->priv->username != NULL ? worker->priv->username : "<unset>",
                          username != NULL ? username : "<unset>");
 
 
                 gdm_session_auditor_set_username (worker->priv->auditor, worker->priv->username);
 
                 if ((worker->priv->username == username) ||
                     ((worker->priv->username != NULL) && (username != NULL) &&
                      (strcmp (worker->priv->username, username) == 0)))
                         goto out;
 
                 g_debug ("GdmSessionWorker: setting username to '%s'", username);
 
                 g_free (worker->priv->username);
                 worker->priv->username = username;
                 username = NULL;
 
                 gdm_dbus_worker_emit_username_changed (GDM_DBUS_WORKER (worker),
                                                        worker->priv->username);
 
                 /* We have a new username to try. If we haven't been able to
                  * read user settings up until now, then give it a go now
                  * (see the comment in do_setup for rationale on why it's useful
                  * to keep trying to read settings)
                  */
                 if (worker->priv->username != NULL &&
+                    worker->priv->username[0] != '\0' &&
                     !gdm_session_settings_is_loaded (worker->priv->user_settings)) {
                         attempt_to_load_user_settings (worker, worker->priv->username);
                 }
         }
 
  out:
         g_free (username);
 }
 
 static gboolean
 gdm_session_worker_ask_question (GdmSessionWorker *worker,
                                  const char       *question,
                                  char            **answerp)
 {
         return gdm_dbus_worker_manager_call_info_query_sync (worker->priv->manager,
                                                              worker->priv->service,
                                                              question,
                                                              answerp,
                                                              NULL,
                                                              NULL);
 }
 
 static gboolean
 gdm_session_worker_ask_for_secret (GdmSessionWorker *worker,
                                    const char       *question,
                                    char            **answerp)
 {
         return gdm_dbus_worker_manager_call_secret_info_query_sync (worker->priv->manager,
                                                                     worker->priv->service,
                                                                     question,
-- 
1.8.4.2