aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-02-15 04:11:53 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-02-15 04:11:53 +0800
commit6545e80191916bea8705e0d4feb0e00192b36905 (patch)
tree51179e91f5a910f964e8db861e626d76e1bb2c5d /camel
parent4d98f14113b8cdf72226361d6904a6829a15f0e7 (diff)
downloadgsoc2013-evolution-6545e80191916bea8705e0d4feb0e00192b36905.tar.gz
gsoc2013-evolution-6545e80191916bea8705e0d4feb0e00192b36905.tar.zst
gsoc2013-evolution-6545e80191916bea8705e0d4feb0e00192b36905.zip
Same as the gpg and pkcs7 contexts.
2003-02-14 Jeffrey Stedfast <fejj@ximian.com> * camel-smime-context.c (smime_get_password): Same as the gpg and pkcs7 contexts. * camel-sasl-popb4smtp.c (popb4smtp_challenge): Updated for camel_session_get_password(). * camel-pkcs7-context.c (get_password): Same as the gpg code. * camel-gpg-context.c (gpg_ctx_parse_status): Updated for camel_session_get_password(). * providers/smtp/camel-smtp-transport.c (smtp_connect): No need to set USER_CANCEL exception here as it is done by camel_session_get_password(). Also updated for the new get_password() API change. * providers/imap/camel-imap-store.c (imap_auth_loop): Updated for camel_session_get_password() changes. We don't need to play the "bad passwd" game here too, do we? Bah, probably should but I don't feel like it for now. Maybe when we rewrite the IMAP provider. * camel-session.c (camel_session_get_password): Now takes a 'reprompt' argument that will force user-input to be given even if we have the passwd cached. * providers/pop3/camel-pop3-store.c (pop3_connect): Instead of uncaching the passwd after we receive a -ERR from the POP server, set 'reprompt' to TRUE to force user-input for the next password prompt (ie, make sure the front-end knows not to just return the cached value). The front-end can then decide to fill-in the user-input field with the last passwd that the user supplied. (pop3_try_authenticate): Now takes a reprompt argument which we pass into camel_session_get_password(). svn path=/trunk/; revision=19912
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog37
-rw-r--r--camel/camel-gpg-context.c2
-rw-r--r--camel/camel-pkcs7-context.c2
-rw-r--r--camel/camel-sasl-popb4smtp.c4
-rw-r--r--camel/camel-session.c10
-rw-r--r--camel/camel-session.h2
-rw-r--r--camel/camel-smime-context.c2
-rw-r--r--camel/providers/imap/camel-imap-store.c8
-rw-r--r--camel/providers/pop3/camel-pop3-store.c38
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c6
10 files changed, 74 insertions, 37 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 0051ebffb4..fb47bd7a1d 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,40 @@
+2003-02-14 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-smime-context.c (smime_get_password): Same as the gpg and
+ pkcs7 contexts.
+
+ * camel-sasl-popb4smtp.c (popb4smtp_challenge): Updated for
+ camel_session_get_password().
+
+ * camel-pkcs7-context.c (get_password): Same as the gpg code.
+
+ * camel-gpg-context.c (gpg_ctx_parse_status): Updated for
+ camel_session_get_password().
+
+ * providers/smtp/camel-smtp-transport.c (smtp_connect): No need to
+ set USER_CANCEL exception here as it is done by
+ camel_session_get_password(). Also updated for the new
+ get_password() API change.
+
+ * providers/imap/camel-imap-store.c (imap_auth_loop): Updated for
+ camel_session_get_password() changes. We don't need to play the
+ "bad passwd" game here too, do we? Bah, probably should but I
+ don't feel like it for now. Maybe when we rewrite the IMAP
+ provider.
+
+ * camel-session.c (camel_session_get_password): Now takes a
+ 'reprompt' argument that will force user-input to be given even if
+ we have the passwd cached.
+
+ * providers/pop3/camel-pop3-store.c (pop3_connect): Instead of
+ uncaching the passwd after we receive a -ERR from the POP server,
+ set 'reprompt' to TRUE to force user-input for the next password
+ prompt (ie, make sure the front-end knows not to just return the
+ cached value). The front-end can then decide to fill-in the
+ user-input field with the last passwd that the user supplied.
+ (pop3_try_authenticate): Now takes a reprompt argument which we
+ pass into camel_session_get_password().
+
2003-02-05 Dan Winship <danw@ximian.com>
* Makefile.am (libcamelincludedir): Define in terms of
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index 72bda72990..ce16e9b574 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -769,7 +769,7 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
prompt = g_strdup_printf (_("You need a passphrase to unlock the key for\n"
"user: \"%s\""), name);
- passwd = camel_session_get_password (gpg->session, prompt, TRUE, NULL, userid, ex);
+ passwd = camel_session_get_password (gpg->session, prompt, FALSE, TRUE, NULL, userid, ex);
g_free (prompt);
g_free (gpg->userid);
diff --git a/camel/camel-pkcs7-context.c b/camel/camel-pkcs7-context.c
index c70a8fa96b..17a52b5de6 100644
--- a/camel/camel-pkcs7-context.c
+++ b/camel/camel-pkcs7-context.c
@@ -195,7 +195,7 @@ get_password (void *arg, SECKEYKeyDBHandle *handle)
return pwitem;
prompt = g_strdup_printf (_("Please enter your password for %s"), userid);
- passwd = camel_session_get_password (session, prompt, TRUE,
+ passwd = camel_session_get_password (session, prompt, FALSE, TRUE,
NULL, userid, NULL);
g_free (prompt);
diff --git a/camel/camel-sasl-popb4smtp.c b/camel/camel-sasl-popb4smtp.c
index 7e1b6baaf0..1bc91e1402 100644
--- a/camel/camel-sasl-popb4smtp.c
+++ b/camel/camel-sasl-popb4smtp.c
@@ -104,8 +104,8 @@ popb4smtp_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex)
sasl->authenticated = FALSE;
- popuri = camel_session_get_password(session, _("POP Source URI"), FALSE,
- sasl->service, "popb4smtp_uri", ex);
+ popuri = camel_session_get_password (session, _("POP Source URI"), FALSE, FALSE,
+ sasl->service, "popb4smtp_uri", ex);
if (popuri == NULL) {
camel_exception_setv(ex, 1, _("POP Before SMTP auth using an unknown transport"));
diff --git a/camel/camel-session.c b/camel/camel-session.c
index c4634b45dd..1d45e9661b 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -584,6 +584,7 @@ camel_session_get_storage_path (CamelSession *session, CamelService *service,
* camel_session_get_password:
* @session: session object
* @prompt: prompt to provide to user
+ * @reprompt: TRUE if the prompt should force a reprompt
* @secret: whether or not the data is secret (eg, a password, as opposed
* to a smartcard response)
* @service: the service this query is being made by
@@ -607,14 +608,15 @@ camel_session_get_storage_path (CamelSession *session, CamelService *service,
**/
char *
camel_session_get_password (CamelSession *session, const char *prompt,
- gboolean secret, CamelService *service,
- const char *item, CamelException *ex)
+ gboolean reprompt, gboolean secret,
+ CamelService *service, const char *item,
+ CamelException *ex)
{
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
g_return_val_if_fail (prompt != NULL, NULL);
g_return_val_if_fail (item != NULL, NULL);
-
- return CS_CLASS (session)->get_password (session, prompt, secret, service, item, ex);
+
+ return CS_CLASS (session)->get_password (session, prompt, reprompt, secret, service, item, ex);
}
diff --git a/camel/camel-session.h b/camel/camel-session.h
index 0105f2ce8b..8dbdfb9d3f 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -87,6 +87,7 @@ typedef struct {
char * (*get_password) (CamelSession *session,
const char *prompt,
+ gboolean reprompt,
gboolean secret,
CamelService *service,
const char *item,
@@ -152,6 +153,7 @@ char * camel_session_get_storage_path (CamelSession *session,
char * camel_session_get_password (CamelSession *session,
const char *prompt,
+ gboolean reprompt,
gboolean secret,
CamelService *service,
const char *item,
diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c
index 6324bea2ee..9ba1d2be74 100644
--- a/camel/camel-smime-context.c
+++ b/camel/camel-smime-context.c
@@ -169,7 +169,7 @@ smime_get_password (PK11SlotInfo *info, PRBool retry, void *arg)
char *prompt, *passwd, *ret;
prompt = g_strdup_printf (_("Please enter your password for %s"), userid);
- passwd = camel_session_get_password (session, prompt, TRUE,
+ passwd = camel_session_get_password (session, prompt, FALSE, TRUE,
NULL, userid, ex);
g_free (prompt);
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 0107356427..0537eaf0d9 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -1094,8 +1094,7 @@ imap_auth_loop (CamelService *service, CamelException *ex)
while (!authenticated) {
if (errbuf) {
/* We need to un-cache the password before prompting again */
- camel_session_forget_password (
- session, service, "password", ex);
+ camel_session_forget_password (session, service, "password", ex);
g_free (service->url->passwd);
service->url->passwd = NULL;
}
@@ -1109,9 +1108,8 @@ imap_auth_loop (CamelService *service, CamelException *ex)
service->url->user,
service->url->host);
service->url->passwd =
- camel_session_get_password (
- session, prompt, TRUE,
- service, "password", ex);
+ camel_session_get_password (session, prompt, FALSE, TRUE,
+ service, "password", ex);
g_free (prompt);
g_free (errbuf);
errbuf = NULL;
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 6452cb6a47..566d57c9ba 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -445,8 +445,7 @@ try_sasl(CamelPOP3Store *store, const char *mech, CamelException *ex)
}
static int
-pop3_try_authenticate (CamelService *service, const char *errmsg,
- CamelException *ex)
+pop3_try_authenticate (CamelService *service, gboolean reprompt, const char *errmsg, CamelException *ex)
{
CamelPOP3Store *store = (CamelPOP3Store *)service;
CamelPOP3Command *pcu = NULL, *pcp = NULL;
@@ -455,7 +454,7 @@ pop3_try_authenticate (CamelService *service, const char *errmsg,
/* override, testing only */
/*printf("Forcing authmech to 'login'\n");
service->url->authmech = g_strdup("LOGIN");*/
-
+
if (!service->url->passwd) {
char *prompt;
@@ -464,7 +463,7 @@ pop3_try_authenticate (CamelService *service, const char *errmsg,
service->url->user,
service->url->host);
service->url->passwd = camel_session_get_password (camel_service_get_session (service),
- prompt, TRUE, service, "password", ex);
+ prompt, reprompt, TRUE, service, "password", ex);
g_free (prompt);
if (!service->url->passwd)
return FALSE;
@@ -478,7 +477,7 @@ pop3_try_authenticate (CamelService *service, const char *errmsg,
char *secret, md5asc[33], *d;
unsigned char md5sum[16], *s;
- secret = alloca(strlen(store->engine->apop)+strlen(service->url->passwd)+1);
+ secret = g_alloca(strlen(store->engine->apop)+strlen(service->url->passwd)+1);
sprintf(secret, "%s%s", store->engine->apop, service->url->passwd);
md5_get_digest(secret, strlen (secret), md5sum);
@@ -534,14 +533,18 @@ pop3_try_authenticate (CamelService *service, const char *errmsg,
static gboolean
pop3_connect (CamelService *service, CamelException *ex)
{
+ CamelPOP3Store *store = (CamelPOP3Store *)service;
+ gboolean reprompt = FALSE;
+ CamelSession *session;
char *errbuf = NULL;
int status;
- CamelPOP3Store *store = (CamelPOP3Store *)service;
+
+ session = camel_service_get_session (service);
if (store->cache == NULL) {
char *root;
- root = camel_session_get_storage_path(service->session, service, ex);
+ root = camel_session_get_storage_path (session, service, ex);
if (root) {
store->cache = camel_data_cache_new(root, 0, ex);
g_free(root);
@@ -557,24 +560,21 @@ pop3_connect (CamelService *service, CamelException *ex)
return FALSE;
do {
- camel_exception_clear(ex);
- status = pop3_try_authenticate(service, errbuf, ex);
- g_free(errbuf);
+ camel_exception_clear (ex);
+ status = pop3_try_authenticate (service, reprompt, errbuf, ex);
+ g_free (errbuf);
errbuf = NULL;
/* we only re-prompt if we failed to authenticate, any other error and we just abort */
if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE) {
- errbuf = g_strdup_printf("%s\n\n", camel_exception_get_description(ex));
-
- /* Uncache the password before prompting again. */
- camel_session_forget_password(camel_service_get_session (service),
- service, "password", NULL);
- g_free(service->url->passwd);
+ errbuf = g_strdup_printf ("%s\n\n", camel_exception_get_description (ex));
+ g_free (service->url->passwd);
service->url->passwd = NULL;
+ reprompt = TRUE;
}
- } while(status != -1 && ex->id == CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE);
-
- g_free(errbuf);
+ } while (status != -1 && ex->id == CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE);
+
+ g_free (errbuf);
if (status == -1 || camel_exception_is_set(ex)) {
camel_service_disconnect(service, TRUE, ex);
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index bb27c632bc..6361dcd7a8 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -499,7 +499,7 @@ smtp_connect (CamelService *service, CamelException *ex)
while (!authenticated) {
if (errbuf) {
/* We need to un-cache the password before prompting again */
- camel_session_forget_password (session, service, "password", ex);
+ camel_session_forget_password (session, service, "password", NULL);
g_free (service->url->passwd);
service->url->passwd = NULL;
}
@@ -511,7 +511,7 @@ smtp_connect (CamelService *service, CamelException *ex)
errbuf ? errbuf : "", service->url->user,
service->url->host);
- service->url->passwd = camel_session_get_password (session, prompt, TRUE,
+ service->url->passwd = camel_session_get_password (session, prompt, FALSE, TRUE,
service, "password", ex);
g_free (prompt);
@@ -519,8 +519,6 @@ smtp_connect (CamelService *service, CamelException *ex)
errbuf = NULL;
if (!service->url->passwd) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("You didn't enter a password."));
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}