[Commits] [SCM] claws branch, master, updated. 3.16.0-228-ge595b5c

ticho at claws-mail.org ticho at claws-mail.org
Sun Jul 1 22:15:52 CEST 2018


The branch, master has been updated
       via  e595b5c0e978afa29983bfd79ce65668137879c2 (commit)
      from  fa7bec8685ac1b2dfda2c113ed5a876f33c506a7 (commit)

Summary of changes:
 src/plugins/managesieve/sieve_prefs.c |   34 +++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit e595b5c0e978afa29983bfd79ce65668137879c2
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Jul 1 22:07:17 2018 +0200

    Cleanup after moving Managesieve passwords to password store.
    
    Since the password was moved to password store, there is one
    less element in accounts' Managesieve config string. The
    "failed reading Sieve config elements" warning should not be
    printed if it's just password that's missing.

diff --git a/src/plugins/managesieve/sieve_prefs.c b/src/plugins/managesieve/sieve_prefs.c
index bbacb31..63e5dbd 100644
--- a/src/plugins/managesieve/sieve_prefs.c
+++ b/src/plugins/managesieve/sieve_prefs.c
@@ -480,8 +480,9 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
 	gchar enable, use_host, use_port;
 	guchar tls_type, auth, auth_type;
 	gsize len;
+	gint num;
 #if defined(G_OS_WIN32) || defined(__OpenBSD__) || defined(__FreeBSD__)
-	/* Windows sscanf() does not understand the %ms format yet, so we
+	/* Non-GNU sscanf() does not understand the %ms format, so we
 	 * have to do the allocation of target buffer ourselves before
 	 * calling sscanf(), and copy the host string to config->host.
 	 */
@@ -507,9 +508,9 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
 	enc_userid[0] = '\0';
 	enc_passwd[0] = '\0';
 #if defined(G_OS_WIN32) || defined(__OpenBSD__) || defined(__FreeBSD__)
-	if (sscanf(confstr, "%c%c %255s %c%hu %hhu %hhu %hhu %255s %255s",
+	if ((num = sscanf(confstr, "%c%c %255s %c%hu %hhu %hhu %hhu %255s %255s",
 #else
-	if (sscanf(confstr, "%c%c %ms %c%hu %hhu %hhu %hhu %255s %255s",
+	if ((num = sscanf(confstr, "%c%c %ms %c%hu %hhu %hhu %hhu %255s %255s",
 #endif
 			&enable, &use_host,
 #if defined(G_OS_WIN32) || defined(__OpenBSD__) || defined(__FreeBSD__)
@@ -522,8 +523,19 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
 			&auth,
 			&auth_type,
 			enc_userid,
-			enc_passwd) != 10)
-		g_warning("failed reading Sieve config elements");
+			enc_passwd)) != 10) {
+			/* This (10th element missing) will happen on any recent
+			 * configuration, where the password is already in
+			 * passwordstore, and not in this config string. We have
+			 * to read the 10th element in order not to break older
+			 * configurations, and to move the password to password
+			 * store.
+			 * If there are not 10 nor 9 elements, something is wrong. */
+		if (num != 9) {
+			g_warning("failed reading Sieve config elements");
+		}
+	}
+	debug_print("Read %d Sieve config elements\n", num);
 
 	/* Scan enums separately, for endian purposes */
 	config->tls_type = tls_type;
@@ -544,8 +556,11 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
 	}
 
 	config->userid = g_base64_decode(enc_userid, &len);
-	if (enc_passwd[0]) {
-		// migrate password from passcrypt to passwordstore
+
+	/* migrate password from passcrypt to passwordstore, if
+	 * it's not there yet */
+	if (enc_passwd[0] != '\0' &&
+			!passwd_store_has_password_account(account->account_id, "sieve")) {
 		gchar *pass = g_base64_decode(enc_passwd, &len);
 		passcrypt_decrypt(pass, len);
 		passwd_store_set_account(account->account_id, "sieve",
@@ -568,7 +583,7 @@ void sieve_prefs_account_set_config(
 		enc_userid = g_base64_encode(config->userid, len);
 	}
 
-	confstr = g_strdup_printf("%c%c %s %c%hu %hhu %hhu %hhu %s %s",
+	confstr = g_strdup_printf("%c%c %s %c%hu %hhu %hhu %hhu %s",
 			config->enable ? 'y' : 'n',
 			config->use_host ? 'y' : 'n',
 			config->host && config->host[0] ? config->host : "!",
@@ -577,8 +592,7 @@ void sieve_prefs_account_set_config(
 			config->tls_type,
 			config->auth,
 			config->auth_type,
-			enc_userid ? enc_userid : "",
-			"");
+			enc_userid ? enc_userid : "");
 
 	if (enc_userid)
 		g_free(enc_userid);

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list