From c10f6c45bcc610030e127b005544d84a53831edd Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 15 Oct 2012 11:37:28 -0400 Subject: worker: sanity test libc passwd entries getpwnam returns a structure filled in by nsswitch modules. Those modules aren't always bug free, and can sometimes return e.g. an empty user's shell. When that happens the failure is pretty catastrophic and hard to debug. This commit does a quick sanity check of the user's home directory and shell to make sure they're not empty. If they are empty it picks defaults that are likely to at least sort of work. A better fix would probably be to fail earlier and post a message to the user explaining why login won't work, but this is good enough for now. https://bugzilla.gnome.org/show_bug.cgi?id=685423 --- daemon/gdm-session-worker.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c index 3acdfee7..228460cb 100644 --- a/daemon/gdm-session-worker.c +++ b/daemon/gdm-session-worker.c @@ -1405,10 +1405,18 @@ _lookup_passwd_info (const char *username, *gidp = passwd_entry->pw_gid; } if (homep != NULL) { - *homep = g_strdup (passwd_entry->pw_dir); + if (passwd_entry->pw_dir != NULL && passwd_entry->pw_dir[0] != '\0') { + *homep = g_strdup (passwd_entry->pw_dir); + } else { + *homep = g_strdup ("/"); + } } if (shellp != NULL) { - *shellp = g_strdup (passwd_entry->pw_shell); + if (passwd_entry->pw_shell != NULL && passwd_entry->pw_shell[0] != '\0') { + *shellp = g_strdup (passwd_entry->pw_shell); + } else { + *shellp = g_strdup ("/bin/bash"); + } } ret = TRUE; out: -- cgit v1.2.1