gnome-keyring r1310 - in trunk: . daemon/keyrings daemon/pk daemon/pkcs11



Author: nnielsen
Date: Tue Sep  9 02:50:12 2008
New Revision: 1310
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1310&view=rev

Log:
	* daemon/keyrings/gkr-keyring-item.c:
	* daemon/keyrings/gkr-keyring-item.h: 
	* daemon/keyrings/gkr-pk-index.c: Cover corner cases when 
	an indexed object is copy between indexes using the same keyring
	or to a keyring where it already exists.
	
	* daemon/pkcs11/gkr-pkcs11-daemon-session.c: Load all objects 
	when a session is opened, regardless of whether a C_FindObjects
	is run or not.


Modified:
   trunk/ChangeLog
   trunk/daemon/keyrings/gkr-keyring-item.c
   trunk/daemon/keyrings/gkr-keyring-item.h
   trunk/daemon/keyrings/gkr-keyrings.c
   trunk/daemon/pk/gkr-pk-index.c
   trunk/daemon/pkcs11/gkr-pkcs11-daemon-session.c

Modified: trunk/daemon/keyrings/gkr-keyring-item.c
==============================================================================
--- trunk/daemon/keyrings/gkr-keyring-item.c	(original)
+++ trunk/daemon/keyrings/gkr-keyring-item.c	Tue Sep  9 02:50:12 2008
@@ -223,6 +223,20 @@
 	return item;
 }
 
+void
+gkr_keyring_item_merge (GkrKeyringItem* merged, GkrKeyringItem* item)
+{
+	GnomeKeyringAttributeList *attributes;
+	GnomeKeyringAttribute *attribute;
+	gint i;
+	
+	attributes = item->attributes;
+	for (i = 0; i < attributes->len; i++) {
+		attribute = &gnome_keyring_attribute_list_index (attributes, i);
+		gkr_attribute_list_set (merged->attributes, attribute);
+	}
+}
+
 gboolean
 gkr_keyring_item_match (GkrKeyringItem *item, GnomeKeyringItemType type, 
                         GnomeKeyringAttributeList *attributes, gboolean match_all)

Modified: trunk/daemon/keyrings/gkr-keyring-item.h
==============================================================================
--- trunk/daemon/keyrings/gkr-keyring-item.h	(original)
+++ trunk/daemon/keyrings/gkr-keyring-item.h	Tue Sep  9 02:50:12 2008
@@ -86,6 +86,9 @@
 GkrKeyringItem*    gkr_keyring_item_clone       (GkrKeyring* new_keyring, 
                                                  GkrKeyringItem *item);
 
+void               gkr_keyring_item_merge       (GkrKeyringItem* merged,
+                                                 GkrKeyringItem* item);
+
 gboolean           gkr_keyring_item_match       (GkrKeyringItem *item, 
                                                  GnomeKeyringItemType type, 
                                                  GnomeKeyringAttributeList *attributes, 

Modified: trunk/daemon/keyrings/gkr-keyrings.c
==============================================================================
--- trunk/daemon/keyrings/gkr-keyrings.c	(original)
+++ trunk/daemon/keyrings/gkr-keyrings.c	Tue Sep  9 02:50:12 2008
@@ -280,6 +280,8 @@
 void 
 gkr_keyrings_add (GkrKeyring *keyring)
 {
+	GList *l;
+	
 	keyrings_init ();
 	
 	g_assert (GKR_IS_KEYRING (keyring));
@@ -287,6 +289,14 @@
 	/* Can't add the same keyring twice */
 	g_assert (g_list_find (keyrings, keyring) == NULL);
 	
+	/* Can't add two keyrings for the same location */
+	for (l = keyrings; l; l = g_list_next (l)) { 
+		if (((GkrKeyring*)l->data)->location == keyring->location) {
+			g_warning ("two keyrings added for the same location: %s",
+			           gkr_location_to_string (keyring->location));
+		}
+	}
+	
 	keyrings = g_list_prepend (keyrings, keyring);
 	g_object_ref (keyring);
 }

Modified: trunk/daemon/pk/gkr-pk-index.c
==============================================================================
--- trunk/daemon/pk/gkr-pk-index.c	(original)
+++ trunk/daemon/pk/gkr-pk-index.c	Tue Sep  9 02:50:12 2008
@@ -883,6 +883,7 @@
 gkr_pk_index_copy (GkrPkIndex *old_index, GkrPkIndex *new_index, gkrconstid digest)
 {
 	GkrKeyringItem *item;
+	GkrKeyringItem *copy;
 	
 	if (!old_index)
 		old_index = gkr_pk_index_default ();
@@ -896,12 +897,22 @@
 	if (old_index == new_index)
 		return FALSE;
 	
+	if (old_index->keyring == new_index->keyring)
+		return FALSE;
+	
 	item = find_item_for_digest (old_index, digest, FALSE);
 	if (!item)
 		return FALSE;
 	
-	item = gkr_keyring_item_clone (new_index->keyring, item);
-	gkr_keyring_add_item (new_index->keyring, item);
+	copy = find_item_for_digest (new_index, digest, FALSE);
+	if (copy) {
+		/* Just merge the attributes from the old_index into new item */ 
+		gkr_keyring_item_merge (copy, item);
+	} else {
+		/* Create a new item and add it to the keyring */
+		copy = gkr_keyring_item_clone (new_index->keyring, item);
+		gkr_keyring_add_item (new_index->keyring, copy);
+	}
 	
 	if (!gkr_keyring_save_to_disk (new_index->keyring))
 		g_warning ("copying item: couldn't write index keyring to disk");

Modified: trunk/daemon/pkcs11/gkr-pkcs11-daemon-session.c
==============================================================================
--- trunk/daemon/pkcs11/gkr-pkcs11-daemon-session.c	(original)
+++ trunk/daemon/pkcs11/gkr-pkcs11-daemon-session.c	Tue Sep  9 02:50:12 2008
@@ -303,6 +303,8 @@
 	sinfo->pid = pid;
 	sinfo->session = gkr_pk_session_new_for_client (pid);
 	
+	gkr_pk_storage_refresh_all ();
+	
 	return CKR_OK;
 }
 



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