[gnome-keyring/dbus-api] Perform PKCS#11 login to secret store token.



commit d22c92b6517d566e93c747d46eb392c54cc6d549
Author: Stef Walter <stef memberwebs com>
Date:   Fri Nov 6 02:50:31 2009 +0000

    Perform PKCS#11 login to secret store token.
    
     * This uses a blank login.
     * Doesn't actually unlock anything, but is necessary for
       PkCS#11 private object semantics.

 daemon/dbus/gkd-secrets-service.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/daemon/dbus/gkd-secrets-service.c b/daemon/dbus/gkd-secrets-service.c
index 59872cd..230535a 100644
--- a/daemon/dbus/gkd-secrets-service.c
+++ b/daemon/dbus/gkd-secrets-service.c
@@ -795,8 +795,10 @@ gkd_secrets_service_get_pkcs11_session (GkdSecretsService *self, const gchar *ca
 {
 	ServiceClient *client;
 	GError *error = NULL;
+	GP11TokenInfo *info;
 	GP11Slot *slot;
 	gulong flags;
+	gboolean login;
 
 	g_return_val_if_fail (GKD_SECRETS_IS_SERVICE (self), NULL);
 	g_return_val_if_fail (caller, NULL);
@@ -816,6 +818,19 @@ gkd_secrets_service_get_pkcs11_session (GkdSecretsService *self, const gchar *ca
 			g_clear_error (&error);
 			return NULL;
 		}
+
+		/* Perform the necessary 'user' login to secrets token. Doesn't unlock anything */
+		info = gp11_slot_get_token_info (slot);
+		login = info && (info->flags & CKF_LOGIN_REQUIRED);
+		gp11_token_info_free (info);
+		if (login && !gp11_session_login (client->pkcs11_session, CKU_USER, NULL, 0, &error)) {
+			g_warning ("couldn't log into pkcs11 session for secrets service: %s",
+			           error->message);
+			g_clear_error (&error);
+			g_object_unref (client->pkcs11_session);
+			client->pkcs11_session = NULL;
+			return NULL;
+		}
 	}
 
 	return client->pkcs11_session;



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