From 0a708b4e41e80263f8c8e4a5a399c69cec1608c6 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Sun, 18 Mar 2018 17:07:51 +0100 Subject: Use the mpes1: - tag for passwords encrypted with master password --- libsylph/prefs_account.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'libsylph/prefs_account.c') diff --git a/libsylph/prefs_account.c b/libsylph/prefs_account.c index 1aecba9..fc4d8f1 100644 --- a/libsylph/prefs_account.c +++ b/libsylph/prefs_account.c @@ -34,6 +34,7 @@ #include "customheader.h" #include "account.h" #include "utils.h" +#include "masterpassword.h" static PrefsAccount tmp_ac_prefs; @@ -205,7 +206,7 @@ PrefsAccount *prefs_account_new(void) void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label) { const gchar *p = label; - gchar *rcpath; + gchar *rcpath, *tmp_str; gint id; g_return_if_fail(ac_prefs != NULL); @@ -229,6 +230,32 @@ void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label) ac_prefs->use_apop_auth = TRUE; } + if (master_password_active()) { + if ((ac_prefs->passwd != NULL) && + !mpes_string_prefix(ac_prefs->passwd)) { + /* TODO: Perhaps some prompt? */ + debug_print( + "%s -> converting passwd cleartext to encrypted\n", + label); + tmp_str = ac_prefs->passwd; + ac_prefs->passwd = encrypt_with_master_password(ac_prefs->passwd); + g_free(tmp_str); + } + + if ((ac_prefs->smtp_passwd != NULL) && + !mpes_string_prefix(ac_prefs->smtp_passwd)) { + /* TODO: Perhaps some prompt? */ + debug_print( + "%s -> converting smtp_passwd from cleartext to encrypted\n", + label); + tmp_str = ac_prefs->smtp_passwd; + ac_prefs->smtp_passwd = encrypt_with_master_password( + ac_prefs->smtp_passwd); + g_free(tmp_str); + } + + } + custom_header_read_config(ac_prefs); } -- cgit v1.3