[gnome-keyring] Fix broken startup when used with gdm and password-less login.



commit 28f19c9b4cdc2fa3cfc0aa25f34760aee3c3c802
Author: Stef Walter <stef memberwebs com>
Date:   Sun May 23 16:19:39 2010 +0000

    Fix broken startup when used with gdm and password-less login.
    
    Fixes bug #611002

 daemon/gkd-main.c    |   16 +++++++---------
 pam/gkr-pam-module.c |   31 ++++++++++++-------------------
 2 files changed, 19 insertions(+), 28 deletions(-)
---
diff --git a/daemon/gkd-main.c b/daemon/gkd-main.c
index 6ac0b65..55790eb 100644
--- a/daemon/gkd-main.c
+++ b/daemon/gkd-main.c
@@ -396,7 +396,7 @@ read_login_password (int fd)
 	/*
 	 * When --login is specified then the login password is passed
 	 * in on stdin. All data (including newlines) are part of the
-	 * password.
+	 * password. A zero length password is no password.
 	 */
 
 	gchar *buf = egg_secure_alloc (MAX_BLOCK);
@@ -412,17 +412,15 @@ read_login_password (int fd)
 			egg_secure_free (buf);
 			return NULL;
 
-		} else  {
-			char *n = egg_secure_realloc (ret, len + r + 1);
-			memset(n + len, 0, r + 1);
-			ret = n;
-			len = len + r;
+		} else if (r == 0 || len > MAX_LENGTH) {
+			break;
 
+		} else {
+			ret = egg_secure_realloc (ret, len + r + 1);
+			memset (ret + len, 0, r + 1);
+			len = len + r;
 			strncat (ret, buf, r);
 		}
-
-		if (r == 0 || len > MAX_LENGTH)
-			break;
 	}
 
 	egg_secure_free (buf);
diff --git a/pam/gkr-pam-module.c b/pam/gkr-pam-module.c
index bf3c844..d6fc17d 100644
--- a/pam/gkr-pam-module.c
+++ b/pam/gkr-pam-module.c
@@ -318,14 +318,11 @@ cleanup_free_password (pam_handle_t *ph, void *data, int pam_end_status)
 }
 
 static void
-setup_child (int inp[2], int outp[2], int errp[2], 
-             pam_handle_t *ph, struct passwd *pwd, const char *password)
+setup_child (int inp[2], int outp[2], int errp[2], pam_handle_t *ph, struct passwd *pwd)
 {
 	const char* display;
 	int i, ret;
 
-	/* The --login argument comes last, because of code below */
-	
 #ifdef VALGRIND 	
 	char *args[] = { VALGRIND, VALGRIND_ARG, GNOME_KEYRING_DAEMON, "--daemonize", "--login", NULL};
 #else
@@ -335,14 +332,6 @@ setup_child (int inp[2], int outp[2], int errp[2],
 	assert (pwd);
 	assert (pwd->pw_dir);
 
-	/* If no password, don't pass in --login */
-	if (password == NULL) {
-		for (i = 0; args[i]; ++i) {
-			if (strcmp ("--login", args[i]) == 0)
-				args[i] = NULL;
-		}
-	}
-
 	/* Fix up our end of the pipes */
 	if (dup2 (inp[READ_END], STDIN) < 0 ||
 	    dup2 (outp[WRITE_END], STDOUT) < 0 || 
@@ -499,7 +488,7 @@ start_daemon (pam_handle_t *ph, struct passwd *pwd, const char *password)
 		
 	/* This is the child */
 	case 0:
-		setup_child (inp, outp, errp, ph, pwd, password);
+		setup_child (inp, outp, errp, ph, pwd);
 		/* Should never be reached */
 		break;
 		
@@ -507,19 +496,23 @@ start_daemon (pam_handle_t *ph, struct passwd *pwd, const char *password)
 	default:
 		break;
 	};
-	
+
 	/* Close our unneeded ends of the pipes */
 	close (inp[READ_END]);
 	close (outp[WRITE_END]);
 	close (errp[WRITE_END]);
 	inp[READ_END] = outp[WRITE_END] = errp[WRITE_END] = -1; 
 
-	if (password) {
-		/* Write the login keyring password */
+	/*
+	 * We always pass in a --login argument, even when we have a NULL password
+	 * since this controls the startup behavior. When using --login daemon waits
+	 * for a password. Closing input signifies password is done.
+	 */
+
+	if (password)
 		write_string (inp[WRITE_END], password);
-		close (inp[WRITE_END]);
-	}
-	
+	close (inp[WRITE_END]);
+
 	/* 
 	 * Note that we're not using select() or any such. We know how the 
 	 * daemon sends its data.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]