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 22:21:07 -0400
commit70ad75f6ddb0b8ad3c8ccdb3533a8c7f352a1085 (patch)
tree70ac6162094b60d93185c78cf78c7982a73ddde5
parent36d41d39c8122e8b6494e61ef855b23276247a39 (diff)
downloadgdm-70ad75f6ddb0b8ad3c8ccdb3533a8c7f352a1085.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 (cherry picked from commit c10f6c45bcc610030e127b005544d84a53831edd)
-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: