Fixed a problem with NNTP authentication failure handling (need to

fail the MODE READER command to force reconnection with password
prompt).
This commit is contained in:
Sergey Vlasov 2001-04-30 16:55:45 +00:00
parent 06c7982810
commit 5cda5e2d12
4 changed files with 28 additions and 3 deletions

View file

@ -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.

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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);