summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2012-10-15 11:37:28 -0400
committerRay Strode <rstrode@redhat.com>2012-10-15 11:42:57 -0400
commitc10f6c45bcc610030e127b005544d84a53831edd (patch)
treef020fde66a0db2fbb52606c092e41b5d0449b2ab
parent84a330a1ecb657f0512715361c834e3324d6a724 (diff)
downloadgdm-c10f6c45bcc610030e127b005544d84a53831edd.tar.gz
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
-rw-r--r--daemon/gdm-session-worker.c12
1 files 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: