[Commits] [SCM] claws branch, master, updated. 3.13.2-42-g07c4154
Colin
colin at claws-mail.org
Thu Feb 11 14:32:47 CET 2016
The branch, master has been updated
via 07c41544264fbc6779d654372acca453d243d68a (commit)
from e727be6329c2589a739f2260bbf164c43701ba77 (commit)
Summary of changes:
src/common/plugin.c | 18 ++++++++++++++++++
src/common/plugin.h | 2 ++
src/password.c | 6 ++++++
src/plugins/gdata/cm_gdata_prefs.c | 13 +++++++++++++
src/plugins/gdata/cm_gdata_prefs.h | 1 +
src/plugins/gdata/gdata_plugin.c | 5 +++++
src/plugins/spam_report/plugin.def | 2 +-
src/plugins/spam_report/spam_report.c | 5 +++++
src/plugins/spam_report/spam_report_prefs.c | 15 +++++++++++++++
src/plugins/spam_report/spam_report_prefs.h | 1 +
src/plugins/vcalendar/plugin.c | 5 +++++
src/plugins/vcalendar/plugin.def | 1 +
src/plugins/vcalendar/vcal_prefs.c | 18 ++++++++++++++++++
src/plugins/vcalendar/vcal_prefs.h | 2 ++
14 files changed, 93 insertions(+), 1 deletion(-)
- Log -----------------------------------------------------------------
commit 07c41544264fbc6779d654372acca453d243d68a
Author: Colin Leroy <colin at colino.net>
Date: Thu Feb 11 14:32:44 2016 +0100
Add a plugin method to allow updating stored passwords on master password change.
GData is still untested.
diff --git a/src/common/plugin.c b/src/common/plugin.c
index ad3d27f..b7282b8 100644
--- a/src/common/plugin.c
+++ b/src/common/plugin.c
@@ -51,6 +51,7 @@ struct _Plugin
const gchar *(*version) (void);
const gchar *(*type) (void);
const gchar *(*licence) (void);
+ void (*master_password_change) (const gchar *oldp, const gchar *newp);
struct PluginFeature *(*provides) (void);
GSList *rdeps;
@@ -419,6 +420,8 @@ Plugin *plugin_load(const gchar *filename, gchar **error)
const gchar *(*plugin_type)(void);
const gchar *(*plugin_licence)(void);
struct PluginFeature *(*plugin_provides)(void);
+ void (*plugin_master_password_change) (const gchar *oldp, const gchar *newp) = NULL;
+
gint ok;
START_TIMING((filename?filename:"NULL plugin"));
cm_return_val_if_fail(filename != NULL, NULL);
@@ -474,6 +477,9 @@ init_plugin:
g_free(plugin);
return NULL;
}
+
+ /* Optional methods */
+ g_module_symbol(plugin->module, "plugin_master_password_change", (gpointer)&plugin_master_password_change);
if (plugin_licence_check(plugin_licence()) != TRUE) {
*error = g_strdup(_("This module is not licensed under a GPL v3 or later compatible license."));
@@ -506,6 +512,7 @@ init_plugin:
plugin->type = plugin_type;
plugin->licence = plugin_licence;
plugin->provides = plugin_provides;
+ plugin->master_password_change = plugin_master_password_change;
plugin->filename = g_strdup(filename);
plugin->error = NULL;
@@ -745,6 +752,17 @@ const gchar *plugin_get_error(Plugin *plugin)
return plugin->error;
}
+void plugins_master_password_change(const gchar *oldp, const gchar *newp) {
+ Plugin *plugin = NULL;
+ GSList *cur;
+ for (cur = plugin_get_list(); cur; cur = g_slist_next(cur)) {
+ plugin = (Plugin *)cur->data;
+ if (plugin->master_password_change != NULL) {
+ plugin->master_password_change(oldp, newp);
+ }
+ }
+}
+
/* Generally called in plugin_init() function of each plugin. It check the
* minimal and compiled version of claws binary required by the plugin.
* If (@minimum_claws_version == 0 || @compiled_claws_version == 0), don't
diff --git a/src/common/plugin.h b/src/common/plugin.h
index cc72746..446df5e 100644
--- a/src/common/plugin.h
+++ b/src/common/plugin.h
@@ -59,6 +59,8 @@ void plugin_unload_all (const gchar *type);
void plugin_save_list (void);
void plugin_load_standard_plugins (void);
+void plugins_master_password_change(const gchar *oldp, const gchar *newp);
+
GSList *plugin_get_list (void);
GSList *plugin_get_unloaded_list(void);
const gchar *plugin_get_name (Plugin *plugin);
diff --git a/src/password.c b/src/password.c
index dba5ef2..4f9ee16 100644
--- a/src/password.c
+++ b/src/password.c
@@ -36,6 +36,7 @@
#endif
#include "common/passcrypt.h"
+#include "common/plugin.h"
#include "common/utils.h"
#include "account.h"
#include "alertpanel.h"
@@ -210,6 +211,11 @@ void master_password_change(const gchar *newp)
}
}
+ /* Now reencrypt all plugins passwords fields
+ * FIXME: Unloaded plugins won't be able to update their stored passwords
+ */
+ plugins_master_password_change(oldp, newp);
+
master_password_forget();
}
#endif
diff --git a/src/plugins/gdata/cm_gdata_prefs.c b/src/plugins/gdata/cm_gdata_prefs.c
index 1e06143..a24349e 100644
--- a/src/plugins/gdata/cm_gdata_prefs.c
+++ b/src/plugins/gdata/cm_gdata_prefs.c
@@ -151,3 +151,16 @@ void cm_gdata_prefs_done(void)
prefs_gtk_unregister_page((PrefsPage*) &gdata_page);
}
}
+
+void cm_gdata_master_password_change(const gchar *oldp, const gchar *newp) {
+ gchar *pass;
+ int i;
+
+ pass = password_decrypt(cm_gdata_config.oauth2_refresh_token, oldp);
+ if (pass != NULL) {
+ g_free(cm_gdata_config.oauth2_refresh_token);
+ cm_gdata_config.oauth2_refresh_token = password_encrypt(pass, newp);
+ memset(pass, 0, strlen(pass));
+ }
+ g_free(pass);
+}
diff --git a/src/plugins/gdata/cm_gdata_prefs.h b/src/plugins/gdata/cm_gdata_prefs.h
index adb7676..396d83f 100644
--- a/src/plugins/gdata/cm_gdata_prefs.h
+++ b/src/plugins/gdata/cm_gdata_prefs.h
@@ -33,5 +33,6 @@ extern PrefParam cm_gdata_param[];
void cm_gdata_prefs_init(void);
void cm_gdata_prefs_done(void);
+void cm_gdata_master_password_change(const gchar *oldp, const gchar *newp);
#endif /* CM_GDATA_PREFS_H_ */
diff --git a/src/plugins/gdata/gdata_plugin.c b/src/plugins/gdata/gdata_plugin.c
index 3f0b4c3..b383770 100644
--- a/src/plugins/gdata/gdata_plugin.c
+++ b/src/plugins/gdata/gdata_plugin.c
@@ -181,6 +181,11 @@ const gchar *plugin_version(void)
return VERSION;
}
+void plugin_master_password_change (const gchar *oldp, const gchar *newp)
+{
+ cm_gdata_prefs_master_password_change(oldp, newp);
+}
+
struct PluginFeature *plugin_provides(void)
{
static struct PluginFeature features[] =
diff --git a/src/plugins/spam_report/plugin.def b/src/plugins/spam_report/plugin.def
index 8916a5d..47b05d7 100644
--- a/src/plugins/spam_report/plugin.def
+++ b/src/plugins/spam_report/plugin.def
@@ -7,4 +7,4 @@ EXPORTS
plugin_type
plugin_provides
plugin_version
-
+ plugin_master_password_change
diff --git a/src/plugins/spam_report/spam_report.c b/src/plugins/spam_report/spam_report.c
index 701ffb0..0d2e22c 100644
--- a/src/plugins/spam_report/spam_report.c
+++ b/src/plugins/spam_report/spam_report.c
@@ -407,6 +407,11 @@ const gchar *plugin_version(void)
return VERSION;
}
+void plugin_master_password_change (const gchar *oldp, const gchar *newp)
+{
+ spamreport_master_password_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 7d0e88d..ec7ae8b 100644
--- a/src/plugins/spam_report/spam_report_prefs.c
+++ b/src/plugins/spam_report/spam_report_prefs.c
@@ -232,3 +232,18 @@ static void save_spamreport_prefs(PrefsPage *page)
} else
prefs_file_close(pref_file);
}
+
+void spamreport_master_password_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 08027f4..2667a3c 100644
--- a/src/plugins/spam_report/spam_report_prefs.h
+++ b/src/plugins/spam_report/spam_report_prefs.h
@@ -65,5 +65,6 @@ extern SpamReportPrefs spamreport_prefs;
void spamreport_prefs_init(void);
void spamreport_prefs_done(void);
+void spamreport_master_password_change(const gchar *oldp, const gchar *newp);
#endif
diff --git a/src/plugins/vcalendar/plugin.c b/src/plugins/vcalendar/plugin.c
index 575181d..8c1e4e5 100644
--- a/src/plugins/vcalendar/plugin.c
+++ b/src/plugins/vcalendar/plugin.c
@@ -99,6 +99,11 @@ const gchar *plugin_version(void)
return VERSION;
}
+void plugin_master_password_change (const gchar *oldp, const gchar *newp)
+{
+ vcal_prefs_master_password_change(oldp, newp);
+}
+
struct PluginFeature *plugin_provides(void)
{
static struct PluginFeature features[] =
diff --git a/src/plugins/vcalendar/plugin.def b/src/plugins/vcalendar/plugin.def
index 8916a5d..17417b2 100644
--- a/src/plugins/vcalendar/plugin.def
+++ b/src/plugins/vcalendar/plugin.def
@@ -7,4 +7,5 @@ EXPORTS
plugin_type
plugin_provides
plugin_version
+ plugin_master_password_change
diff --git a/src/plugins/vcalendar/vcal_prefs.c b/src/plugins/vcalendar/vcal_prefs.c
index a039d3f..680e807 100644
--- a/src/plugins/vcalendar/vcal_prefs.c
+++ b/src/plugins/vcalendar/vcal_prefs.c
@@ -723,6 +723,24 @@ static void vcal_prefs_save_func(PrefsPage * _page)
vcal_folder_export(NULL);
}
+void vcal_prefs_master_password_change(const gchar *oldp, const gchar *newp) {
+ gchar *pass;
+ pass = password_decrypt(vcalprefs.export_pass, oldp);
+ if (pass != NULL) {
+ g_free(vcalprefs.export_pass);
+ vcalprefs.export_pass = password_encrypt(pass, newp);
+ memset(pass, 0, strlen(pass));
+ }
+ g_free(pass);
+ pass = password_decrypt(vcalprefs.export_freebusy_pass, oldp);
+ if (pass != NULL) {
+ g_free(vcalprefs.export_freebusy_pass);
+ vcalprefs.export_freebusy_pass = password_encrypt(pass, newp);
+ memset(pass, 0, strlen(pass));
+ }
+ g_free(pass);
+}
+
void vcal_prefs_init(void)
{
static gchar *path[3];
diff --git a/src/plugins/vcalendar/vcal_prefs.h b/src/plugins/vcalendar/vcal_prefs.h
index 11475fa..9fcb96d 100644
--- a/src/plugins/vcalendar/vcal_prefs.h
+++ b/src/plugins/vcalendar/vcal_prefs.h
@@ -51,4 +51,6 @@ extern VcalendarPrefs vcalprefs;
void vcal_prefs_init (void);
void vcal_prefs_done (void);
void vcal_prefs_save (void);
+void vcal_prefs_master_password_change(const gchar *oldp, const gchar *newp);
+
#endif
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list