gnome-keyring r1232 - in trunk: . common daemon/pk



Author: nnielsen
Date: Sun Aug 10 16:40:28 2008
New Revision: 1232
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1232&view=rev

Log:
	* common/gkr-location.c: Automatically create non-existing directories
	when we're trying to store a file.
	
	* daemon/pk/gkr-pk-import.c: Don't offer to store password for 
	stuff we're unlocking while importing.
	
	* daemon/pk/gkr-pk-object-storage.c: Create stored files in proper
	directories. 

	* daemon/pk/gkr-pk-object-storage.c: Don't try to store certificates
	encrypted on the disk.

Modified:
   trunk/ChangeLog
   trunk/common/gkr-location.c
   trunk/daemon/pk/gkr-pk-import.c
   trunk/daemon/pk/gkr-pk-object-storage.c

Modified: trunk/common/gkr-location.c
==============================================================================
--- trunk/common/gkr-location.c	(original)
+++ trunk/common/gkr-location.c	Sun Aug 10 16:40:28 2008
@@ -1114,7 +1114,8 @@
 gboolean
 gkr_location_write_file (GQuark loc, const guchar *data, gssize len, GError **err)
 {
-	gboolean ret;
+	gboolean ret = TRUE;
+	gchar *dirname;
 	gchar *path;
 	
 	g_return_val_if_fail (loc != 0, FALSE);
@@ -1127,9 +1128,21 @@
 		             _("The disk or drive this file is located on is not present"));
 		return FALSE;
 	}
+	
+	dirname = g_dirname (path);
+	if (dirname && dirname[0]) {
+		if (g_mkdir_with_parents (dirname, 0700) < 0) {
+			g_set_error (err, G_FILE_ERROR, g_file_error_from_errno (errno),
+			             _("Couldn't create directory: %s"), dirname);
+			ret = FALSE;
+		}
+	}
 
-	ret = g_file_set_contents (path, (const gchar*)data, len, err);
+	if (ret)
+		ret = g_file_set_contents (path, (const gchar*)data, len, err);
+	
 	g_free (path);
+	g_free (dirname);
 	
 	return ret;
 }

Modified: trunk/daemon/pk/gkr-pk-import.c
==============================================================================
--- trunk/daemon/pk/gkr-pk-import.c	(original)
+++ trunk/daemon/pk/gkr-pk-import.c	Sun Aug 10 16:40:28 2008
@@ -107,23 +107,6 @@
 		return _("Enter password to unlock");
 }
 
-static const gchar*
-prepare_ask_check (GQuark type)
-{
-	/*
-	 * Yes this is unmaintainable and stupid, but is required 
-	 * for translations to work properly.
-	 */
-	if (type == GKR_PKIX_PRIVATE_KEY)
-		return _("Automatically unlock this private key when I log in.");
-	else if (type == GKR_PKIX_CERTIFICATE)
-		return _("Automatically unlock this certificate when I log in.");
-	else if (type == GKR_PKIX_PUBLIC_KEY)
-		return _("Automatically unlock this public key when I log in.");
-	else 
-		return _("Automatically unlock this when I log in");
-}
-
 static gchar*
 prepare_ask_secondary (GQuark type, const gchar *label)
 {
@@ -186,8 +169,6 @@
 	 */
 		
 	index = gkr_pk_storage_index (import->import_storage, loc);
-	if (gkr_pk_index_allows_secrets (index))
-		gkr_ask_request_set_check_option (ask, prepare_ask_check (type));
 		
 	/* Prompt the user */
 	gkr_ask_daemon_process (ask);
@@ -205,8 +186,6 @@
 		*result = gkr_secure_strdup (ask->typed_password);
 		if (*result && strlen (*result) == 0)
 			*state = LAST_WAS_BLANK;
-		if (ask->checked) 
-			gkr_pk_index_set_secret (index, digest, ask->typed_password);
 	}
 	
 	g_object_unref (ask);
@@ -576,12 +555,8 @@
 
 	/* Check for import errors */
 	if (pv->error) {
-		if (*err) {
-			*err = pv->error;
-			pv->error = NULL;
-		}
-		
-		g_clear_error (&pv->error);
+		g_propagate_error (err, pv->error);
+		pv->error = NULL;
 		return FALSE;
 	}
 	

Modified: trunk/daemon/pk/gkr-pk-object-storage.c
==============================================================================
--- trunk/daemon/pk/gkr-pk-object-storage.c	(original)
+++ trunk/daemon/pk/gkr-pk-object-storage.c	Sun Aug 10 16:40:28 2008
@@ -75,7 +75,7 @@
 static GQuark
 location_for_storing (GkrPkObjectStorage *storage, GkrPkObject *obj, GQuark type)
 {
-	const gchar *label;
+	gchar *label;
 	const gchar *ext;
 	gchar *filename;
 	GQuark loc;
@@ -86,12 +86,13 @@
 		ext = "pk";
 	
 	/* Come up with a good relative name for the object */
-	label = gkr_pk_object_get_label (obj);
+	label = g_strdup (gkr_pk_object_get_label (obj));
+	g_strdelimit (label, UNWANTED_FILENAME_CHARS, '_');
 	filename = g_strconcat (RELATIVE_DIRECTORY, G_DIR_SEPARATOR_S, label, ".", ext, NULL);
-	g_strdelimit (filename, UNWANTED_FILENAME_CHARS, '_');
 	
 	loc = gkr_location_from_child (GKR_LOCATION_VOLUME_LOCAL, filename);
 	g_free (filename);
+	g_free (label);
 	
 	return loc;
 }
@@ -346,10 +347,11 @@
 gkr_pk_object_storage_store (GkrPkStorage *stor, GkrPkObject *obj, GError **err)
 {
 	GkrPkObjectStorage *storage;
+	gchar *password = NULL;
 	gpointer what;
-	gchar *password;
 	gkrid digest;
 	gboolean ret;
+	gboolean is_private;
 	GQuark loc, type;
 	GType gtype;
 	guchar *data;
@@ -361,11 +363,13 @@
 	g_return_val_if_fail (obj->location == 0, FALSE);
 
 	storage = GKR_PK_OBJECT_STORAGE (stor);
-
+	is_private = FALSE;
+	
 	/* What are we dealing with? */
 	gtype = G_OBJECT_TYPE (obj);
 	if (gtype == GKR_TYPE_PK_PRIVKEY) {
 		type = GKR_PKIX_PRIVATE_KEY;
+		is_private = TRUE;
 		g_object_get (obj, "gcrypt-sexp", &what, NULL);
 	} else if (gtype == GKR_TYPE_PK_PUBKEY) {
 		type = GKR_PKIX_PUBLIC_KEY;
@@ -383,14 +387,16 @@
 	loc = location_for_storing (storage, obj, type);
 	g_return_val_if_fail (loc, FALSE);
 	
-	/* Get a password for this key, determines whether encrypted or not */
-	ret = gkr_pk_storage_get_store_password (stor, loc, obj->digest, type, 
-	                                         gkr_pk_object_get_label (obj), 
-	                                         &password);
-	
-	/* Prompt for a password was denied */
-	if (!ret)
-		return TRUE;
+	if(is_private) {
+		/* Get a password for this key, determines whether encrypted or not */
+		ret = gkr_pk_storage_get_store_password (stor, loc, obj->digest, type, 
+		                                         gkr_pk_object_get_label (obj), 
+		                                         &password);
+	
+		/* Prompt for a password was denied */
+		if (!ret)
+			return FALSE;
+	}
 
 	/* Store the object into memory */
 	data = gkr_pkix_serialize_to_data (type, what, password, &n_data);



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