[gnome-keyring] [pkcs11] Store objects after any attribute change.



commit 79cb0fc9996958cc3b3d19183d2f8c1a8dc48fb1
Author: Stef Walter <stef memberwebs com>
Date:   Sun Jan 3 20:55:28 2010 +0000

    [pkcs11] Store objects after any attribute change.
    
    Previously most token objects did not have modifiable attributes, or at
    least not those stored on the token. This changed with the addition
    of secret objects.

 pkcs11/gck/gck-module.c                 |    8 +++++---
 pkcs11/gck/gck-session.c                |    4 ++++
 pkcs11/secret-store/gck-secret-module.c |    4 ++--
 pkcs11/user-store/gck-user-module.c     |    9 +++++++++
 4 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/pkcs11/gck/gck-module.c b/pkcs11/gck/gck-module.c
index 78ef5d6..3d68e4f 100644
--- a/pkcs11/gck/gck-module.c
+++ b/pkcs11/gck/gck-module.c
@@ -840,10 +840,12 @@ gck_module_store_token_object (GckModule *self, GckTransaction *transaction, Gck
 	g_return_if_fail (GCK_IS_OBJECT (object));
 	g_assert (GCK_MODULE_GET_CLASS (self)->store_token_object);
 
-	if (gck_object_is_transient (object))
-		add_transient_object (self, transaction, object);
-	else
+	if (gck_object_is_transient (object)) {
+		if (g_hash_table_lookup (self->pv->transient_objects, object) == NULL)
+			add_transient_object (self, transaction, object);
+	} else {
 		GCK_MODULE_GET_CLASS (self)->store_token_object (self, transaction, object);
+	}
 }
 
 void
diff --git a/pkcs11/gck/gck-session.c b/pkcs11/gck/gck-session.c
index 130d6d4..a61043a 100644
--- a/pkcs11/gck/gck-session.c
+++ b/pkcs11/gck/gck-session.c
@@ -1098,6 +1098,10 @@ gck_session_C_SetAttributeValue (GckSession* self, CK_OBJECT_HANDLE handle,
 	for (i = 0; i < count && !gck_transaction_get_failed (transaction); ++i) 
 		gck_object_set_attribute (object, self, transaction, &template[i]);
 
+	/* Store the object */
+	if (gck_object_is_token (object))
+		gck_module_store_token_object (self->pv->module, transaction, object);
+
 	gck_transaction_complete (transaction);
 	rv = gck_transaction_get_result (transaction);
 	g_object_unref (transaction);
diff --git a/pkcs11/secret-store/gck-secret-module.c b/pkcs11/secret-store/gck-secret-module.c
index c1a5a9a..0cd7f50 100644
--- a/pkcs11/secret-store/gck-secret-module.c
+++ b/pkcs11/secret-store/gck-secret-module.c
@@ -306,12 +306,12 @@ gck_secret_module_real_store_object (GckModule *module, GckTransaction *transact
 	const gchar *identifier;
 	gchar *filename;
 
-	/* Adding an item */
+	/* Storing an item */
 	if (GCK_IS_SECRET_ITEM (object)) {
 		collection = gck_secret_item_get_collection (GCK_SECRET_ITEM (object));
 		g_return_if_fail (GCK_IS_SECRET_COLLECTION (collection));
 
-	/* Adding a collection */
+	/* Storing a collection */
 	} else if (GCK_IS_SECRET_COLLECTION (object)) {
 		collection = GCK_SECRET_COLLECTION (object);
 	}
diff --git a/pkcs11/user-store/gck-user-module.c b/pkcs11/user-store/gck-user-module.c
index da6bfce..4915070 100644
--- a/pkcs11/user-store/gck-user-module.c
+++ b/pkcs11/user-store/gck-user-module.c
@@ -132,6 +132,15 @@ static void
 gck_user_module_real_store_token_object (GckModule *base, GckTransaction *transaction, GckObject *object)
 {
 	GckUserModule *self = GCK_USER_MODULE (base);
+	GckStore *store = NULL;
+
+	/* TODO: Need to support storing changes better */
+	g_object_get (object, "store", &store, NULL);
+	if (store != NULL) {
+		g_object_unref (store);
+		return;
+	}
+
 	gck_user_storage_create (self->storage, transaction, object);
 }
 



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