diff options
author | Chris Toshok <toshok@helixcode.com> | 2000-10-05 04:36:10 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-10-05 04:36:10 +0800 |
commit | aedfd03572bcbb2183b6bac4b429cc245aea45f1 (patch) | |
tree | ba0573dd720e5992a8486fe30893083ebf8a08c1 /camel/providers/nntp/camel-nntp-auth.c | |
parent | 032dceebc5eb1bb8ca07141a54d83c765f28d3b6 (diff) | |
download | gsoc2013-evolution-aedfd03572bcbb2183b6bac4b429cc245aea45f1.tar gsoc2013-evolution-aedfd03572bcbb2183b6bac4b429cc245aea45f1.tar.gz gsoc2013-evolution-aedfd03572bcbb2183b6bac4b429cc245aea45f1.tar.bz2 gsoc2013-evolution-aedfd03572bcbb2183b6bac4b429cc245aea45f1.tar.lz gsoc2013-evolution-aedfd03572bcbb2183b6bac4b429cc245aea45f1.tar.xz gsoc2013-evolution-aedfd03572bcbb2183b6bac4b429cc245aea45f1.tar.zst gsoc2013-evolution-aedfd03572bcbb2183b6bac4b429cc245aea45f1.zip |
borrow some code from the imap provider to query the user for their
2000-10-04 Chris Toshok <toshok@helixcode.com>
* providers/nntp/camel-nntp-auth.c (camel_nntp_auth_authenticate):
borrow some code from the imap provider to query the user for
their password, and pass the user/passwd to nntp. be extra
paranoid and zero out the password before freeing it.
* providers/nntp/camel-nntp-store.c (camel_nntp_store_init): add
ALLOW_USER/ALLOW_PASSWORD/ALLOW_AUTH to the url flags.
(nntp_store_query_auth_types_generic): return our list of
auth_types.
(nntp_store_query_auth_types_connected): broken, return same as in
query_auth_types_generic.
svn path=/trunk/; revision=5716
Diffstat (limited to 'camel/providers/nntp/camel-nntp-auth.c')
-rw-r--r-- | camel/providers/nntp/camel-nntp-auth.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/camel/providers/nntp/camel-nntp-auth.c b/camel/providers/nntp/camel-nntp-auth.c index 2490329b81..1a7402a339 100644 --- a/camel/providers/nntp/camel-nntp-auth.c +++ b/camel/providers/nntp/camel-nntp-auth.c @@ -26,33 +26,65 @@ #include <camel-nntp-store.h> #include <camel-nntp-resp-codes.h> #include <camel-exception.h> +#include <camel-session.h> int camel_nntp_auth_authenticate (CamelNNTPStore *store, CamelException *ex) { + CamelService *service = CAMEL_SERVICE (store); + CamelSession *session = camel_service_get_session (service); int resp; + if (!service->url->authmech && !service->url->passwd) { + gchar *prompt; + + prompt = g_strdup_printf ("Please enter the NNTP password for %s@%s", + service->url->user, service->url->host); + service->url->passwd = + camel_session_query_authenticator (session, + CAMEL_AUTHENTICATOR_ASK, prompt, + TRUE, service, "password", ex); + g_free (prompt); + + if (!service->url->passwd) { + camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, + "You didn\'t enter a password."); + resp = 666; + goto done; + } + } + /* first send username */ - resp = camel_nntp_command (store, ex, NULL, "AUTHINFO USER %s", "username"); /* XXX */ + resp = camel_nntp_command (store, ex, NULL, "AUTHINFO USER %s", service->url->user); if (resp == NNTP_AUTH_REJECTED) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, "Server rejected username"); - return resp; + goto done; + } else if (resp != NNTP_AUTH_CONTINUE) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, "Failed to send username to server"); - return resp; + goto done; } /* then send the username if the server asks for it */ - resp = camel_nntp_command (store, ex, NULL, "AUTHINFO PASS %s", "password"); /* XXX */ + resp = camel_nntp_command (store, ex, NULL, "AUTHINFO PASS %s", service->url->passwd); + if (resp == NNTP_AUTH_REJECTED) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, "Server rejected username/password"); - return resp; + goto done; } + done: + + if (service->url->passwd) { + /* let's be paranoid */ + memset (service->url->passwd, 0, strlen (service->url->passwd)); + g_free (service->url->passwd); + service->url->passwd = NULL; + } return resp; } |