[gnome-keyring/gnome-2-32] [daemon] Check that daemon is initialized before changing password.



commit 9ed868758a071cd478ba2431949abf225f4f9426
Author: Stef Walter <stef memberwebs com>
Date:   Tue Oct 19 02:34:01 2010 +0000

    [daemon] Check that daemon is initialized before changing password.
    
    Before changing login keyring password or unlocking, check that daemon
    is initialized.
    
    Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=632352

 daemon/control/gkd-control-server.c |   16 ++++++++++++----
 daemon/gkd-main.c                   |    6 ++++++
 daemon/gkd-main.h                   |    2 ++
 3 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/daemon/control/gkd-control-server.c b/daemon/control/gkd-control-server.c
index 8ec34c5..4c6a66c 100644
--- a/daemon/control/gkd-control-server.c
+++ b/daemon/control/gkd-control-server.c
@@ -77,10 +77,14 @@ control_unlock_login (EggBuffer *buffer)
 	if (!egg_buffer_get_string (buffer, offset, &offset, &master, egg_secure_realloc))
 		return GKD_CONTROL_RESULT_FAILED;
 
-	if (gkd_login_unlock (master))
+	if (!gkd_main_is_initialized ()) {
+		g_message ("couldn't unlock login keyring: daemon has not yet been initialized");
+		res = GKD_CONTROL_RESULT_FAILED;
+	} else if (gkd_login_unlock (master)) {
 		res = GKD_CONTROL_RESULT_OK;
-	else
+	} else {
 		res = GKD_CONTROL_RESULT_DENIED;
+	}
 
 	egg_secure_strfree (master);
 	return res;
@@ -103,10 +107,14 @@ control_change_login (EggBuffer *buffer)
 		return GKD_CONTROL_RESULT_FAILED;
 	}
 
-	if (gkd_login_change_lock (original, master))
+	if (!gkd_main_is_initialized ()) {
+		g_message ("couldn't change login keyring: daemon has not yet been initialized");
+		res = GKD_CONTROL_RESULT_FAILED;
+	} else if (gkd_login_change_lock (original, master)) {
 		res = GKD_CONTROL_RESULT_OK;
-	else
+	} else {
 		res = GKD_CONTROL_RESULT_DENIED;
+	}
 
 	egg_secure_strfree (master);
 	egg_secure_strfree (original);
diff --git a/daemon/gkd-main.c b/daemon/gkd-main.c
index f78100c..3298e1e 100644
--- a/daemon/gkd-main.c
+++ b/daemon/gkd-main.c
@@ -720,6 +720,12 @@ gkr_daemon_initialize_steps (const gchar *components)
 	return TRUE;
 }
 
+gboolean
+gkd_main_is_initialized (void)
+{
+	return initialization_completed;
+}
+
 void
 gkd_main_complete_initialization (const gchar *components)
 {
diff --git a/daemon/gkd-main.h b/daemon/gkd-main.h
index d382755..d677b44 100644
--- a/daemon/gkd-main.h
+++ b/daemon/gkd-main.h
@@ -26,6 +26,8 @@
 
 void           gkd_main_quit                    (void);
 
+gboolean       gkd_main_is_initialized          (void);
+
 void           gkd_main_complete_initialization (const gchar *components);
 
 #endif /* GKD_MAIN_H_ */



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