[gnome-keyring] Use GNOME_KEYRING_TEST_PROMPTER to specify prompter name



commit 7643d9fd1ca726a2465833295df7f0504221e713
Author: Stef Walter <stefw gnome org>
Date:   Wed Jun 27 11:21:28 2012 +0200

    Use GNOME_KEYRING_TEST_PROMPTER to specify prompter name
    
     * Testing code can set GNOME_KEYRING_TEST_PROMPTER environment
       variable to change the prompter that is used for various prompts.

 daemon/dbus/gkd-secret-change.c     |    4 ++++
 daemon/dbus/gkd-secret-create.c     |    4 ++++
 pkcs11/wrap-layer/gkm-wrap-prompt.c |   25 ++++++++++++++++++++-----
 pkcs11/wrap-layer/gkm-wrap-prompt.h |    2 ++
 4 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/daemon/dbus/gkd-secret-change.c b/daemon/dbus/gkd-secret-change.c
index 54ec4c5..06fa1b8 100644
--- a/daemon/dbus/gkd-secret-change.c
+++ b/daemon/dbus/gkd-secret-change.c
@@ -427,14 +427,18 @@ GkdSecretChange*
 gkd_secret_change_new (GkdSecretService *service, const gchar *caller,
                        const gchar *path)
 {
+	const gchar *prompter_name;
+
 	g_return_val_if_fail (GKD_SECRET_IS_SERVICE (service), NULL);
 	g_return_val_if_fail (caller, NULL);
 	g_return_val_if_fail (path, NULL);
 
+	prompter_name = g_getenv ("GNOME_KEYRING_TEST_PROMPTER");
 	return g_object_new (GKD_SECRET_TYPE_CHANGE,
 	                     "service", service,
 	                     "caller", caller,
 	                     "collection-path", path,
+	                     "bus-name", prompter_name,
 	                     NULL);
 }
 
diff --git a/daemon/dbus/gkd-secret-create.c b/daemon/dbus/gkd-secret-create.c
index 5b49c9f..d59b319 100644
--- a/daemon/dbus/gkd-secret-create.c
+++ b/daemon/dbus/gkd-secret-create.c
@@ -392,11 +392,15 @@ GkdSecretCreate*
 gkd_secret_create_new (GkdSecretService *service, const gchar *caller,
                        GckAttributes *attrs, const gchar *alias)
 {
+	const gchar *prompter_name;
+
+	prompter_name = g_getenv ("GNOME_KEYRING_TEST_PROMPTER");
 	return g_object_new (GKD_SECRET_TYPE_CREATE,
 	                     "service", service,
 	                     "caller", caller,
 	                     "pkcs11-attributes", attrs,
 	                     "alias", alias,
+	                     "bus-name", prompter_name,
 	                     NULL);
 }
 
diff --git a/pkcs11/wrap-layer/gkm-wrap-prompt.c b/pkcs11/wrap-layer/gkm-wrap-prompt.c
index 62a3c46..d6e5a17 100644
--- a/pkcs11/wrap-layer/gkm-wrap-prompt.c
+++ b/pkcs11/wrap-layer/gkm-wrap-prompt.c
@@ -974,7 +974,7 @@ gkm_wrap_prompt_for_credential (CK_FUNCTION_LIST_PTR module, CK_SESSION_HANDLE s
 
 	self = g_object_new (GKM_TYPE_WRAP_PROMPT,
 	                     "timeout-seconds", -1,
-	                     "bus-name", the_prompter_name,
+	                     "bus-name", gkm_wrap_prompt_get_prompter_name (),
 	                     NULL);
 
 	/* Build up the prompt */
@@ -1159,7 +1159,7 @@ gkm_wrap_prompt_for_init_pin (CK_FUNCTION_LIST_PTR module, CK_SESSION_HANDLE ses
 
 	self = g_object_new (GKM_TYPE_WRAP_PROMPT,
 	                     "timeout-seconds", -1,
-	                     "bus-name", the_prompter_name,
+	                     "bus-name", gkm_wrap_prompt_get_prompter_name (),
 	                     NULL);
 
 	/* Build up the prompt */
@@ -1309,7 +1309,7 @@ gkm_wrap_prompt_for_set_pin (CK_FUNCTION_LIST_PTR module, CK_SESSION_HANDLE sess
 
 	self = g_object_new (GKM_TYPE_WRAP_PROMPT,
 	                     "timeout-seconds", -1,
-	                     "bus-name", the_prompter_name,
+	                     "bus-name", gkm_wrap_prompt_get_prompter_name (),
 	                     NULL);
 
 	/* Build up the prompt */
@@ -1424,7 +1424,7 @@ login_prompt_for_specific (CK_FUNCTION_LIST_PTR module, CK_SESSION_HANDLE sessio
 
 	self = g_object_new (GKM_TYPE_WRAP_PROMPT,
 	                     "timeout-seconds", -1,
-	                     "bus-name", the_prompter_name,
+	                     "bus-name", gkm_wrap_prompt_get_prompter_name (),
 	                     NULL);
 
 	/* Build up the prompt */
@@ -1496,7 +1496,7 @@ login_prompt_for_user (CK_FUNCTION_LIST_PTR module, CK_SESSION_HANDLE session)
 
 	self = g_object_new (GKM_TYPE_WRAP_PROMPT,
 	                     "timeout-seconds", -1,
-	                     "bus-name", the_prompter_name,
+	                     "bus-name", gkm_wrap_prompt_get_prompter_name (),
 	                     NULL);
 
 	/* Build up the prompt */
@@ -1612,6 +1612,21 @@ gkm_wrap_prompt_done_login (GkmWrapPrompt *self, CK_USER_TYPE user_type, CK_RV c
 	}
 }
 
+const gchar *
+gkm_wrap_prompt_get_prompter_name (void)
+{
+	const gchar *prompter_name;
+
+	if (the_prompter_name)
+		return the_prompter_name;
+
+	prompter_name = g_getenv ("GNOME_KEYRING_TEST_PROMPTER");
+	if (prompter_name)
+		return prompter_name;
+
+	return NULL;
+}
+
 void
 gkm_wrap_prompt_set_prompter_name (const gchar *prompter_name)
 {
diff --git a/pkcs11/wrap-layer/gkm-wrap-prompt.h b/pkcs11/wrap-layer/gkm-wrap-prompt.h
index 47c419c..2668bd0 100644
--- a/pkcs11/wrap-layer/gkm-wrap-prompt.h
+++ b/pkcs11/wrap-layer/gkm-wrap-prompt.h
@@ -28,6 +28,8 @@
 
 typedef struct _GkmWrapPrompt GkmWrapPrompt;
 
+const gchar *       gkm_wrap_prompt_get_prompter_name       (void);
+
 void                gkm_wrap_prompt_set_prompter_name       (const gchar *prompter_name);
 
 GkmWrapPrompt*      gkm_wrap_prompt_for_credential          (CK_FUNCTION_LIST_PTR module,



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