Fixed a problem with NNTP authentication failure handling (need to
authorSergey Vlasov <vsu@users.sourceforge.net>
Mon, 30 Apr 2001 16:55:45 +0000 (16:55 +0000)
committerSergey Vlasov <vsu@users.sourceforge.net>
Mon, 30 Apr 2001 16:55:45 +0000 (16:55 +0000)
fail the MODE READER command to force reconnection with password
prompt).

ChangeLog.claws
src/news.c
src/nntp.c
src/nntp.h

index 2616eb7597e46552d8c367bf775e497a8f7d3253..65219652826bd64b1b624721b3ae70727554c037 100644 (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.
 2001-04-30 [sergey]
 
        * src/nntp.h (NNTPSockInfo): new type.
index 60f4a54e864f7dbba4de8f850ddcc6f84152c44c..c76781e2783c7bcc01e0b96b875751372c73403e 100644 (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);
                userid = ac->userid;
                if (ac->passwd && ac->passwd[0])
                        passwd = g_strdup(ac->passwd);
-               else
+               else {
                        passwd = news_query_password(ac->nntp_server, userid);
                        passwd = news_query_password(ac->nntp_server, userid);
+                       if (!passwd)
+                               userid = NULL;
+               }
        } else {
                userid = passwd = NULL;
        }
        } else {
                userid = passwd = NULL;
        }
index c1b5162a18c2b45b7508adfbf88838f2f40e9253..1bf5931979c39b922632c519f09249e22f25a7c4 100644 (file)
@@ -232,6 +232,9 @@ gint nntp_mode(NNTPSockInfo *sock, gboolean stream)
 {
        gint ok;
 
 {
        gint ok;
 
+       if (sock->auth_failed)
+               return NN_AUTHREQ; /* force reconnection */
+
        ok = nntp_gen_command(sock, NULL, "MODE %s",
                              stream ? "STREAM" : "READER");
 
        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);
 
        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);
                }
                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;
                        return ok;
+               }
                nntp_gen_send(sock, "%s", buf);
                ok = nntp_ok(sock, argbuf);
        }
                nntp_gen_send(sock, "%s", buf);
                ok = nntp_ok(sock, argbuf);
        }
index db05a227380ed18352de9f004a8e0f4d0e7bcc46..890c05e145f83a4b776366e5b76481fb55430890 100644 (file)
@@ -41,6 +41,7 @@ struct _NNTPSockInfo
        SockInfo *sock;
        gchar *userid;
        gchar *passwd;
        SockInfo *sock;
        gchar *userid;
        gchar *passwd;
+       gboolean auth_failed;
 };
 
 NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf);
 };
 
 NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf);