[Commits] [SCM] claws branch, master, updated. 3.13.2-78-g125b181

ticho at claws-mail.org ticho at claws-mail.org
Sat Mar 19 20:44:44 CET 2016


The branch, master has been updated
       via  125b18131c0e9f3b1d71e56134380bdbc71e0820 (commit)
      from  a7a70c6aa50917670ea3897d040457609c4b0242 (commit)

Summary of changes:
 src/plugins/spam_report/claws.def           |    2 --
 src/plugins/spam_report/spam_report.c       |    7 +-----
 src/plugins/spam_report/spam_report_prefs.c |   35 ++++++++++++---------------
 src/plugins/spam_report/spam_report_prefs.h |    7 +++++-
 4 files changed, 23 insertions(+), 28 deletions(-)


- Log -----------------------------------------------------------------
commit 125b18131c0e9f3b1d71e56134380bdbc71e0820
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sat Mar 19 20:44:21 2016 +0100

    Make SpamReport plugin use the password store.

diff --git a/src/plugins/spam_report/claws.def b/src/plugins/spam_report/claws.def
index 0d5e81a..15f8289 100644
--- a/src/plugins/spam_report/claws.def
+++ b/src/plugins/spam_report/claws.def
@@ -33,8 +33,6 @@ matcherlist_free
 matcherlist_match
 matcherlist_new
 matcherprop_new
-password_decrypt
-password_encrypt
 pref_get_escaped_pref
 pref_get_unescaped_pref
 prefs_common
diff --git a/src/plugins/spam_report/spam_report.c b/src/plugins/spam_report/spam_report.c
index 177f279..e1987c5 100644
--- a/src/plugins/spam_report/spam_report.c
+++ b/src/plugins/spam_report/spam_report.c
@@ -222,7 +222,7 @@ static void report_spam(gint id, ReportInterface *intf, MsgInfo *msginfo, gchar
 	switch(intf->type) {
 	case INTF_HTTP_AUTH:
 		if (spamreport_prefs.user[id] && *(spamreport_prefs.user[id])) {
-			gchar *pass = password_decrypt(spamreport_prefs.pass[id], NULL);
+			gchar *pass = spamreport_passwd_get(spam_interfaces[id].name);
 			auth = g_strdup_printf("%s:%s", spamreport_prefs.user[id], (pass != NULL ? pass : ""));
 			if (pass != NULL) {
 				memset(pass, 0, strlen(pass));
@@ -407,11 +407,6 @@ const gchar *plugin_version(void)
 	return VERSION;
 }
 
-void plugin_master_passphrase_change (const gchar *oldp, const gchar *newp)
-{
-	spamreport_master_passphrase_change(oldp, newp);
-}
-
 struct PluginFeature *plugin_provides(void)
 {
 	static struct PluginFeature features[] = 
diff --git a/src/plugins/spam_report/spam_report_prefs.c b/src/plugins/spam_report/spam_report_prefs.c
index fe98d4f..617794a 100644
--- a/src/plugins/spam_report/spam_report_prefs.c
+++ b/src/plugins/spam_report/spam_report_prefs.c
@@ -76,6 +76,7 @@ void spamreport_prefs_init(void)
 {
 	static gchar *path[3];
 	gchar *rcpath;
+	guint i;
 
 	path[0] = _("Plugins");
 	path[1] = _("SpamReport");
@@ -85,7 +86,16 @@ void spamreport_prefs_init(void)
 	rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
         prefs_read_config(param, PREFS_BLOCK_NAME, rcpath, NULL);
 	g_free(rcpath);
-        
+
+	/* 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) {
+			spamreport_passwd_set(spam_interfaces[i].name,
+					spamreport_prefs.pass[i]);
+		}
+	}
+
         spamreport_prefs_page.page.path = path;
         spamreport_prefs_page.page.create_widget = create_spamreport_prefs_page;
         spamreport_prefs_page.page.destroy_widget = destroy_spamreport_prefs_page;
@@ -128,7 +138,7 @@ static void create_spamreport_prefs_page(PrefsPage *page,
 		gtk_entry_set_text(GTK_ENTRY(prefs_page->user_entry[i]),
 			spamreport_prefs.user[i] ? spamreport_prefs.user[i]:"");
 
-		pass = password_decrypt(spamreport_prefs.pass[i], NULL);
+		pass = spamreport_passwd_get(spam_interfaces[i].name);
 		gtk_entry_set_text(GTK_ENTRY(prefs_page->pass_entry[i]), pass ? pass:"");
 		if (pass != NULL) {
 			memset(pass, 0, strlen(pass));
@@ -209,8 +219,10 @@ 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);
-		spamreport_prefs.pass[i] = password_encrypt(pass, NULL);
-		memset(pass, 0, strlen(pass));
+		if (strlen(pass) > 0) {
+			spamreport_passwd_set(spam_interfaces[i].name, pass);
+			memset(pass, 0, strlen(pass));
+		}
 		g_free(pass);
 	}
 
@@ -232,18 +244,3 @@ static void save_spamreport_prefs(PrefsPage *page)
 	} else
 	        prefs_file_close(pref_file);
 }
-
-void spamreport_master_passphrase_change(const gchar *oldp, const gchar *newp) {
-	gchar *pass;
-	int i;
-
-	for (i = 0; i < INTF_LAST; i++) {
-		pass = password_decrypt(spamreport_prefs.pass[i], oldp);
-		if (pass != NULL) {
-			g_free(spamreport_prefs.pass[i]);
-			spamreport_prefs.pass[i] = password_encrypt(pass, newp);
-			memset(pass, 0, strlen(pass));
-		}
-		g_free(pass);
-	}
-}
diff --git a/src/plugins/spam_report/spam_report_prefs.h b/src/plugins/spam_report/spam_report_prefs.h
index 48c27e2..ed46b3a 100644
--- a/src/plugins/spam_report/spam_report_prefs.h
+++ b/src/plugins/spam_report/spam_report_prefs.h
@@ -24,6 +24,7 @@
 #include <glib.h>
 
 #include "procmsg.h"
+#include "passwordstore.h"
 
 #define SPAM_REPORT_USERAGENT "Claws Mail SpamReport plugin "
 
@@ -65,6 +66,10 @@ extern SpamReportPrefs spamreport_prefs;
 
 void spamreport_prefs_init(void);
 void spamreport_prefs_done(void);
-void spamreport_master_passphrase_change(const gchar *oldp, const gchar *newp);
+
+#define spamreport_passwd_set(id, pwd) \
+	passwd_store_set(PWS_PLUGIN, "SpamReport", id, pwd, FALSE)
+#define spamreport_passwd_get(id) \
+	passwd_store_get(PWS_PLUGIN, "SpamReport", id)
 
 #endif

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list