From: Sergey Vlasov Date: Mon, 30 Apr 2001 16:55:45 +0000 (+0000) Subject: Fixed a problem with NNTP authentication failure handling (need to X-Git-Tag: disposition-notification~11 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=5cda5e2d12fd8603d5021bf0f2b6d5135e29c232 Fixed a problem with NNTP authentication failure handling (need to fail the MODE READER command to force reconnection with password prompt). --- diff --git a/ChangeLog.claws b/ChangeLog.claws index 2616eb759..652196528 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,15 @@ +2001-04-30 [sergey] + + * src/nntp.h (NNTPSockInfo): new field auth_failed. + + * src/nntp.c (nntp_mode): return NN_AUTHREQ if sock->auth_failed + is set to force reconnection after authentication failure. + (nntp_gen_command): set sock->auth_failed on authentication + failure, or if sock->userid and sock->passwd are not set. + + * src/news.c (news_session_new_for_folder): set userid=NULL if + password dialog is cancelled. + 2001-04-30 [sergey] * src/nntp.h (NNTPSockInfo): new type. diff --git a/src/news.c b/src/news.c index 60f4a54e8..c76781e27 100644 --- a/src/news.c +++ b/src/news.c @@ -137,8 +137,11 @@ static Session *news_session_new_for_folder(Folder *folder) userid = ac->userid; if (ac->passwd && ac->passwd[0]) passwd = g_strdup(ac->passwd); - else + else { passwd = news_query_password(ac->nntp_server, userid); + if (!passwd) + userid = NULL; + } } else { userid = passwd = NULL; } diff --git a/src/nntp.c b/src/nntp.c index c1b5162a1..1bf593197 100644 --- a/src/nntp.c +++ b/src/nntp.c @@ -232,6 +232,9 @@ gint nntp_mode(NNTPSockInfo *sock, gboolean stream) { gint ok; + if (sock->auth_failed) + return NN_AUTHREQ; /* force reconnection */ + ok = nntp_gen_command(sock, NULL, "MODE %s", stream ? "STREAM" : "READER"); @@ -310,15 +313,21 @@ static gint nntp_gen_command(NNTPSockInfo *sock, gchar *argbuf, nntp_gen_send(sock, "%s", buf); ok = nntp_ok(sock, argbuf); - if (ok == NN_AUTHREQ && sock->userid && sock->passwd) { + if (ok == NN_AUTHREQ) { + if (!sock->userid || !sock->passwd) { + sock->auth_failed = TRUE; + return ok; + } nntp_gen_send(sock, "AUTHINFO USER %s", sock->userid); ok = nntp_ok(sock, NULL); if (ok == NN_AUTHCONT) { nntp_gen_send(sock, "AUTHINFO PASS %s", sock->passwd); ok = nntp_ok(sock, NULL); } - if (ok != NN_SUCCESS) + if (ok != NN_SUCCESS) { + sock->auth_failed = TRUE; return ok; + } nntp_gen_send(sock, "%s", buf); ok = nntp_ok(sock, argbuf); } diff --git a/src/nntp.h b/src/nntp.h index db05a2273..890c05e14 100644 --- a/src/nntp.h +++ b/src/nntp.h @@ -41,6 +41,7 @@ struct _NNTPSockInfo SockInfo *sock; gchar *userid; gchar *passwd; + gboolean auth_failed; }; NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf);