[Commits] [SCM] claws branch, master, updated. 3.13.2-70-ge66c916
charles at claws-mail.org
charles at claws-mail.org
Mon Mar 14 05:59:53 CET 2016
The branch, master has been updated
via e66c916e5661be4fd7024801f73f1f83d747a521 (commit)
from 499c9fec4dda5f698378c506af1001cdcb41b04e (commit)
Summary of changes:
src/plugins/managesieve/managesieve.c | 9 ++++---
src/plugins/managesieve/sieve_prefs.c | 44 ++++++++++++++++++---------------
src/plugins/managesieve/sieve_prefs.h | 1 -
3 files changed, 29 insertions(+), 25 deletions(-)
- Log -----------------------------------------------------------------
commit e66c916e5661be4fd7024801f73f1f83d747a521
Author: Charles Lehner <charles at claws-mail.org>
Date: Mon Mar 14 00:55:49 2016 -0400
Migrate managesieve to passwordstore
diff --git a/src/plugins/managesieve/managesieve.c b/src/plugins/managesieve/managesieve.c
index 9739a0e..1311172 100644
--- a/src/plugins/managesieve/managesieve.c
+++ b/src/plugins/managesieve/managesieve.c
@@ -25,6 +25,7 @@
#include "claws.h"
#include "account.h"
+#include "passwordstore.h"
#include "gtk/inputdialog.h"
#include "md5.h"
#include "utils.h"
@@ -1055,10 +1056,10 @@ static void sieve_session_reset(SieveSession *session)
g_free(session->pass);
if (config->auth == SIEVEAUTH_NONE) {
session->pass = NULL;
- } else if (reuse_auth && account->passwd) {
- session->pass = g_strdup(account->passwd);
- } else if (config->passwd && config->passwd[0]) {
- session->pass = g_strdup(config->passwd);
+ } else if (reuse_auth && (session->pass = passwd_store_get(PWS_ACCOUNT,
+ account->account_name, PWS_ACCOUNT_RECV))) {
+ } else if ((session->pass = passwd_store_get(PWS_ACCOUNT,
+ account->account_name, "sieve"))) {
} else if (password_get(session->user, session->host, "sieve",
session->port, &session->pass)) {
} else {
diff --git a/src/plugins/managesieve/sieve_prefs.c b/src/plugins/managesieve/sieve_prefs.c
index 0d53762..9bc2a18 100644
--- a/src/plugins/managesieve/sieve_prefs.c
+++ b/src/plugins/managesieve/sieve_prefs.c
@@ -32,6 +32,8 @@
#include "gtk/combobox.h"
#include "alertpanel.h"
#include "passcrypt.h"
+#include "password.h"
+#include "passwordstore.h"
#include "utils.h"
#include "prefs.h"
#include "prefs_gtk.h"
@@ -113,6 +115,7 @@ static void sieve_prefs_account_create_widget_func(PrefsPage *_page,
struct SieveAccountPage *page = (struct SieveAccountPage *) _page;
PrefsAccount *account = (PrefsAccount *) data;
SieveAccountConfig *config;
+ gchar *pass;
GtkWidget *page_vbox, *sieve_vbox;
GtkWidget *hbox;
@@ -288,8 +291,12 @@ static void sieve_prefs_account_create_widget_func(PrefsPage *_page,
gtk_entry_set_text(GTK_ENTRY(host_entry), config->host);
if (config->userid != NULL)
gtk_entry_set_text(GTK_ENTRY(uid_entry), config->userid);
- if (config->passwd != NULL)
- gtk_entry_set_text(GTK_ENTRY(pass_entry), config->passwd);
+ if ((pass = passwd_store_get(PWS_ACCOUNT, account->account_name,
+ "sieve")) != NULL) {
+ gtk_entry_set_text(GTK_ENTRY(pass_entry), pass);
+ memset(pass, 0, strlen(pass));
+ g_free(pass);
+ }
combobox_select_by_data(GTK_COMBO_BOX(auth_menu), config->auth_type);
@@ -363,9 +370,14 @@ static gint sieve_prefs_account_apply(struct SieveAccountPage *page)
SIEVE_TLS_MAYBE :
SIEVE_TLS_YES;
+ g_free(config->host);
+ g_free(config->userid);
+
config->host = gtk_editable_get_chars(GTK_EDITABLE(page->host_entry), 0, -1);
config->userid = gtk_editable_get_chars(GTK_EDITABLE(page->uid_entry), 0, -1);
- config->passwd = gtk_editable_get_chars(GTK_EDITABLE(page->pass_entry), 0, -1);
+ passwd_store_set(PWS_ACCOUNT, page->account->account_name, "sieve",
+ gtk_editable_get_chars(GTK_EDITABLE(page->pass_entry), 0, -1),
+ FALSE);
config->auth_type = combobox_get_active_data(GTK_COMBO_BOX(page->auth_menu));
sieve_prefs_account_set_config(page->account, config);
@@ -484,7 +496,6 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
config->auth = SIEVEAUTH_REUSE;
config->auth_type = SIEVEAUTH_AUTO;
config->userid = NULL;
- config->passwd = NULL;
confstr = prefs_account_get_privacy_prefs(account, "sieve");
if (confstr == NULL)
@@ -527,8 +538,14 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
}
config->userid = g_base64_decode(enc_userid, &len);
- config->passwd = g_base64_decode(enc_passwd, &len);
- passcrypt_decrypt(config->passwd, len);
+ if (enc_passwd[0]) {
+ // migrate password from passcrypt to passwordstore
+ gchar *pass = g_base64_decode(enc_passwd, &len);
+ passcrypt_decrypt(pass, len);
+ passwd_store_set(PWS_ACCOUNT, account->account_name, "sieve",
+ pass, FALSE);
+ g_free(pass);
+ }
return config;
}
@@ -538,8 +555,6 @@ void sieve_prefs_account_set_config(
{
gchar *confstr = NULL;
gchar *enc_userid = NULL;
- gchar *enc_passwd = NULL;
- gchar *tmp;
gsize len;
if (config->userid) {
@@ -547,14 +562,6 @@ void sieve_prefs_account_set_config(
enc_userid = g_base64_encode(config->userid, len);
}
- if (config->passwd) {
- tmp = g_strdup(config->passwd);
- len = strlen(tmp);
- passcrypt_encrypt(tmp, len);
- enc_passwd = g_base64_encode(tmp, len);
- g_free(tmp);
- }
-
confstr = g_strdup_printf("%c%c %s %c%hu %hhu %hhu %hhu %s %s",
config->enable ? 'y' : 'n',
config->use_host ? 'y' : 'n',
@@ -565,12 +572,10 @@ void sieve_prefs_account_set_config(
config->auth,
config->auth_type,
enc_userid ? enc_userid : "",
- enc_passwd ? enc_passwd : "");
+ "");
if (enc_userid)
g_free(enc_userid);
- if (enc_passwd)
- g_free(enc_passwd);
prefs_account_set_privacy_prefs(account, "sieve", confstr);
@@ -583,7 +588,6 @@ void sieve_prefs_account_free_config(SieveAccountConfig *config)
{
g_free(config->host);
g_free(config->userid);
- g_free(config->passwd);
g_free(config);
}
diff --git a/src/plugins/managesieve/sieve_prefs.h b/src/plugins/managesieve/sieve_prefs.h
index c1d9f2d..e378d6a 100644
--- a/src/plugins/managesieve/sieve_prefs.h
+++ b/src/plugins/managesieve/sieve_prefs.h
@@ -44,7 +44,6 @@ struct SieveAccountConfig
SieveAuthType auth_type;
SieveTLSType tls_type;
gchar *userid;
- gchar *passwd;
};
extern SieveConfig sieve_config;
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list