changeset 187:166008a80f03 noffle

[svn] src/client.c,src/protocol.h: perform authentication at connect time, accept new and deprecated authentication status codes.
author enz
date Sat, 01 Sep 2001 16:57:45 +0100
parents 7d1f26e7c728
children f1bacee93ca6
files ChangeLog src/client.c src/protocol.h
diffstat 3 files changed, 32 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Aug 05 09:27:17 2001 +0100
+++ b/ChangeLog	Sat Sep 01 16:57:45 2001 +0100
@@ -1,3 +1,8 @@
+Sat Sep 01 2001 Markus Enzenberger <me@markus-enzenberger.de>
+
+* src/client.c,src/protocol.h: perform authentication at connect time,
+  accept new and deprecated authentication status codes.
+
 Sun Aug  5 2001 Jim Hague <jim.hague@acm.org>
 
 * src/client.c: Change variable only used on constant to 'const'.
--- a/src/client.c	Sun Aug 05 09:27:17 2001 +0100
+++ b/src/client.c	Sat Sep 01 16:57:45 2001 +0100
@@ -1,7 +1,7 @@
 /*
   client.c
 
-  $Id: client.c 300 2001-08-05 08:24:22Z bears $
+  $Id: client.c 306 2001-09-01 15:57:45Z enz $
 */
 
 #if HAVE_CONFIG_H
@@ -180,9 +180,11 @@
     }    
     putCmd( "AUTHINFO USER %s", user );
     stat = getStat();
-    if ( stat == STAT_AUTH_ACCEPTED )
+    if ( stat == STAT_AUTH_ACCEPTED
+         || stat == STAT_AUTH_ACCEPTED_DEPREC )
         return stat;
-    else if ( stat != STAT_MORE_AUTH_REQUIRED )
+    else if ( stat != STAT_MORE_AUTH_REQUIRED_DEPREC
+              && stat != STAT_AUTH_REQUIRED )
     {
         Log_err( "Username rejected. Server stat: %s", client.lastStat );
         return stat;
@@ -194,7 +196,8 @@
     }
     putCmd( "AUTHINFO PASS %s", pass );
     stat = getStat();
-    if ( stat != STAT_AUTH_ACCEPTED )
+    if ( stat != STAT_AUTH_ACCEPTED
+         && stat != STAT_AUTH_ACCEPTED_DEPREC)
         Log_err( "Password rejected. Server status: %s", client.lastStat );
     return stat;    
 }
@@ -212,12 +215,15 @@
         Log_err( "Invalid server status: %s", client.lastStat );
         result = STAT_PROGRAM_FAULT;
     }
-    if ( result == STAT_AUTH_REQUIRED && ! client.auth )
+    if ( ( result == STAT_AUTH_REQUIRED
+           || result == STAT_AUTH_REQUIRED_DEPREC )
+         && ! client.auth )
     {
         client.auth = TRUE;
         strcpy( lastCmd, client.lastCmd );
 	result = performAuth();
-        if ( result == STAT_AUTH_ACCEPTED )
+        if ( result == STAT_AUTH_ACCEPTED
+             || result == STAT_AUTH_ACCEPTED_DEPREC )
         {
             putCmd( lastCmd );
             return getStat();
@@ -288,6 +294,7 @@
     struct hostent *hp;
     char *pStart, *pColon;
     Str host, s;
+    Str user, pass;
     struct sockaddr_in sIn;
 
     ASSERT( client.in == NULL && client.out == NULL );
@@ -344,18 +351,17 @@
             }
             Utl_cpyStr( client.serv, serv );
             stat = getStat();
-	    if ( stat == STAT_READY_POST_ALLOW ||
-		 stat == STAT_READY_NO_POST_ALLOW )
-	    {
-		/* INN needs a MODE READER before it will permit POST. */
-		putCmd( "MODE READER" );
-		stat = getStat();
-	    }
             switch( stat ) {
             case STAT_READY_POST_ALLOW:
             case STAT_READY_NO_POST_ALLOW: 
                 Log_inf( "Connected to %s:%d",
                          inet_ntoa( sIn.sin_addr ), port );
+		/* INN needs a MODE READER before it will permit POST. */
+		putCmd( "MODE READER" );
+		getStat();
+                Cfg_authInfo( client.serv, user, pass );
+                if ( strcmp( user, "" ) != 0 )
+                    performAuth();
                 return TRUE;
             default:
                 Log_err( "Bad server stat %d", stat ); 
--- a/src/protocol.h	Sun Aug 05 09:27:17 2001 +0100
+++ b/src/protocol.h	Sat Sep 01 16:57:45 2001 +0100
@@ -4,7 +4,7 @@
   Functions related with the NNTP protocol which are useful for both
   the server and the client.
 
-  $Id: protocol.h 227 2000-10-26 21:21:13Z bears $
+  $Id: protocol.h 306 2001-09-01 15:57:45Z enz $
 */
 
 #ifndef PRT_H
@@ -33,10 +33,11 @@
 #define STAT_OVERS_FOLLOW        224
 #define STAT_NEW_GRP_FOLLOW      231
 #define STAT_POST_OK             240
-#define STAT_AUTH_ACCEPTED       281
+#define STAT_AUTH_ACCEPTED       250
+#define STAT_AUTH_ACCEPTED_DEPREC 281
 
 #define STAT_SEND_ART            340
-#define STAT_MORE_AUTH_REQUIRED  381
+#define STAT_MORE_AUTH_REQUIRED_DEPREC 381
 
 #define STAT_NO_SUCH_GRP         411
 #define STAT_NO_GRP_SELECTED     412
@@ -47,8 +48,10 @@
 #define STAT_NO_SUCH_ID          430
 #define STAT_ART_REJECTED        437
 #define STAT_POST_FAILED         441
-#define STAT_AUTH_REQUIRED       480
-#define STAT_AUTH_REJECTED       482
+#define STAT_AUTH_REQUIRED       450
+#define STAT_AUTH_REJECTED       452
+#define STAT_AUTH_REQUIRED_DEPREC 480
+#define STAT_AUTH_REJECTED_DEPREC 482
 
 #define STAT_NO_SUCH_CMD         500
 #define STAT_SYNTAX_ERR          501