[gdm/gnome-3-6] worker: sanity test libc passwd entries
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/gnome-3-6] worker: sanity test libc passwd entries
- Date: Tue, 16 Oct 2012 02:24:20 +0000 (UTC)
commit 70ad75f6ddb0b8ad3c8ccdb3533a8c7f352a1085
Author: Ray Strode <rstrode redhat com>
Date: Mon Oct 15 11:37:28 2012 -0400
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)
daemon/gdm-session-worker.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 3acdfee..228460c 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:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]