[Commits] [SCM] claws branch, master, updated. 3.13.2-80-g4865bee

ticho at claws-mail.org ticho at claws-mail.org
Sat Mar 19 21:09:12 CET 2016


The branch, master has been updated
       via  4865beea5cf0ccce4f709d9393e9e3076487063c (commit)
      from  a3c5626ea100e08d637d69a680003a5e4a03791b (commit)

Summary of changes:
 src/passwordstore.c                         |   15 ++++++++++-----
 src/plugins/gdata/cm_gdata_contacts.c       |    4 ++--
 src/plugins/spam_report/spam_report_prefs.c |    9 +++------
 3 files changed, 15 insertions(+), 13 deletions(-)


- Log -----------------------------------------------------------------
commit 4865beea5cf0ccce4f709d9393e9e3076487063c
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sat Mar 19 21:07:41 2016 +0100

    Treat storing empty password same as storing NULL password.
    
    (That means delete the password. This simplifies handling
    scenario where user had a password set, but wants to delete
    it by leaving corresponding GtkEntry empty.)

diff --git a/src/passwordstore.c b/src/passwordstore.c
index dfc96a0..4cdddd1 100644
--- a/src/passwordstore.c
+++ b/src/passwordstore.c
@@ -107,6 +107,7 @@ gboolean passwd_store_set(PasswordBlockType block_type,
 		const gchar *password,
 		gboolean encrypted)
 {
+	const gchar *p = password;
 	PasswordBlock *block;
 	gchar *encrypted_password;
 
@@ -115,8 +116,12 @@ gboolean passwd_store_set(PasswordBlockType block_type,
 	g_return_val_if_fail(block_name != NULL, FALSE);
 	g_return_val_if_fail(password_id != NULL, FALSE);
 
+	/* Empty password string equals null password for us. */
+	if (strlen(password) == 0)
+		p = NULL;
+
 	debug_print("%s password '%s' in block (%d/%s)%s\n",
-			(password == NULL ? "Deleting" : "Storing"),
+			(p == NULL ? "Deleting" : "Storing"),
 			password_id, block_type, block_name,
 			(encrypted ? ", already encrypted" : "") );
 
@@ -124,7 +129,7 @@ gboolean passwd_store_set(PasswordBlockType block_type,
 	if ((block = _get_block(block_type, block_name)) == NULL) {
 		/* If caller wants to delete a password, and even its block
 		 * doesn't exist, we're done. */
-		if (password == NULL)
+		if (p == NULL)
 			return TRUE;
 
 		if ((block = _new_block(block_type, block_name)) == NULL) {
@@ -134,7 +139,7 @@ gboolean passwd_store_set(PasswordBlockType block_type,
 		}
 	}
 
-	if (password == NULL) {
+	if (p == NULL) {
 		/* NULL password was passed to us, so delete the entry with
 		 * corresponding id */
 		g_hash_table_remove(block->entries, password_id);
@@ -142,14 +147,14 @@ gboolean passwd_store_set(PasswordBlockType block_type,
 		if (!encrypted) {
 			/* encrypt password before saving it */
 			if ((encrypted_password =
-						password_encrypt(password, NULL)) == NULL) {
+						password_encrypt(p, NULL)) == NULL) {
 				debug_print("Could not encrypt password '%s' for block (%d/%s).\n",
 						password_id, block_type, block_name);
 				return FALSE;
 			}
 		} else {
 			/* password is already in encrypted form already */
-			encrypted_password = g_strdup(password);
+			encrypted_password = g_strdup(p);
 		}
 
 		// add encrypted password to the block
diff --git a/src/plugins/gdata/cm_gdata_contacts.c b/src/plugins/gdata/cm_gdata_contacts.c
index 46c3385..a7c1e0f 100644
--- a/src/plugins/gdata/cm_gdata_contacts.c
+++ b/src/plugins/gdata/cm_gdata_contacts.c
@@ -638,9 +638,9 @@ void cm_gdata_contacts_done(void)
 #if GDATA_CHECK_VERSION(0,17,2)
     /* store refresh token */
     pass = gdata_oauth2_authorizer_dup_refresh_token(authorizer);
+		passwd_store_set(PWS_PLUGIN, "GData", GDATA_TOKEN_PWD_STRING,
+				pass, FALSE);
 		if (pass != NULL) {
-			passwd_store_set(PWS_PLUGIN, "GData", GDATA_TOKEN_PWD_STRING, pass,
-					FALSE);
 	    memset(pass, 0, strlen(pass));
 	    g_free(pass);
 		}
diff --git a/src/plugins/spam_report/spam_report_prefs.c b/src/plugins/spam_report/spam_report_prefs.c
index b8b17b9..1aaf293 100644
--- a/src/plugins/spam_report/spam_report_prefs.c
+++ b/src/plugins/spam_report/spam_report_prefs.c
@@ -90,8 +90,7 @@ void spamreport_prefs_init(void)
 
 	/* Move passwords that are still in main config to password store. */
 	for (i = 0; i < INTF_LAST; i++) {
-		if (spamreport_prefs.pass[i] != NULL &&
-				strlen(spamreport_prefs.pass[i]) > 0) {
+		if (spamreport_prefs.pass[i] != NULL) {
 			spamreport_passwd_set(spam_interfaces[i].name,
 					spamreport_prefs.pass[i]);
 			passwords_migrated = TRUE;
@@ -223,10 +222,8 @@ static void save_spamreport_prefs(PrefsPage *page)
 			GTK_EDITABLE(prefs_page->user_entry[i]), 0, -1);
 
 		pass = gtk_editable_get_chars(GTK_EDITABLE(prefs_page->pass_entry[i]), 0, -1);
-		if (strlen(pass) > 0) {
-			spamreport_passwd_set(spam_interfaces[i].name, pass);
-			memset(pass, 0, strlen(pass));
-		}
+		spamreport_passwd_set(spam_interfaces[i].name, pass);
+		memset(pass, 0, strlen(pass));
 		g_free(pass);
 	}
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list