[gnome-system-tools] Fix hang when changing empty password to something else.



commit 7a26a79553bffbb66967d9313adf561f90e0d5cf
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Sun Mar 14 12:07:54 2010 +0100

    Fix hang when changing empty password to something else.
    
    If user has an empty password, authentication phase is skipped. In that case, calling io_queue_pop() will print current password when 'passwd' is waiting for the new one. This is due to the asynchrous behavior, which means that io_watch_stdout() is only called after this mistake is done. So we just wait for io_watch_stdout() to be run and print the new password from there. This is just one more hack into this very tricky code.

 src/users/run-passwd.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/users/run-passwd.c b/src/users/run-passwd.c
index b55b4b6..11a63be 100644
--- a/src/users/run-passwd.c
+++ b/src/users/run-passwd.c
@@ -557,6 +557,9 @@ io_watch_stdout (GIOChannel *source, GIOCondition condition, PasswdHandler *pass
 					 * in this case, simply remove it from the queue */
 					pw = g_queue_pop_head (passwd_handler->backend_stdin_queue);
 					g_free (pw);
+
+					/* Pop the IO queue, i.e. send new password */
+					io_queue_pop (passwd_handler->backend_stdin_queue, passwd_handler->backend_stdin);
 				} else {
 
 					passwd_handler->backend_state = PASSWD_STATE_AUTH;
@@ -731,8 +734,12 @@ passwd_change_password (PasswdHandler *passwd_handler,
 		update_password (passwd_handler);
 	}
 
-	/* Pop new password through the backend */
-	io_queue_pop (passwd_handler->backend_stdin_queue, passwd_handler->backend_stdin);
+	/* Pop new password through the backend. If user has no password, popping the queue
+	   would output current password, while 'passwd' is waiting for the new one. So wait
+	   for io_watch_stdout() to remove current password from the queue, and output
+	   the new one for us.*/
+	if (passwd_handler->current_password)
+		io_queue_pop (passwd_handler->backend_stdin_queue, passwd_handler->backend_stdin);
 
 	/* Our IO watcher should now handle the rest */
 



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