Mercurial > noffle
diff src/client.c @ 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 | fed1334d766b |
children | f1bacee93ca6 |
line wrap: on
line diff
--- 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 );