From 78df6042057e6aaa1bf825cb9cab47fb14fb98ff Mon Sep 17 00:00:00 2001 From: Lukasz Janyst Date: Tue, 14 May 2013 16:17:13 +0200 Subject: [PATCH] [XrdCl] Make sure to try all available authentication options before failing --- src/XrdCl/XrdClXRootDTransport.cc | 55 +++++++++++++++++++------------ 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/src/XrdCl/XrdClXRootDTransport.cc b/src/XrdCl/XrdClXRootDTransport.cc index 3da967dc1d3..57ffc0d8005 100644 --- a/src/XrdCl/XrdClXRootDTransport.cc +++ b/src/XrdCl/XrdClXRootDTransport.cc @@ -1209,40 +1209,53 @@ namespace XrdCl } //------------------------------------------------------------------------ - // We have either succeeded or failed, in either case we need to clean up + // We have succeeded //------------------------------------------------------------------------ - else + else if( rsp->hdr.status == kXR_ok ) { info->authProtocolName = info->authProtocol->Entity.prot; CleanUpAuthentication( info ); - //---------------------------------------------------------------------- - // Success - //---------------------------------------------------------------------- - if( rsp->hdr.status == kXR_ok ) + log->Debug( XRootDTransportMsg, + "[%s] Authenticated with %s.", hsData->streamName.c_str(), + protocolName.c_str() ); + return Status(); + } + //------------------------------------------------------------------------ + // Failure + //------------------------------------------------------------------------ + else if( rsp->hdr.status == kXR_error ) + { + log->Error( XRootDTransportMsg, + "[%s] Authentication with %s failed: %s", + hsData->streamName.c_str(), protocolName.c_str(), + rsp->body.error.errmsg ); + + if( info->authProtocol ) { - log->Debug( XRootDTransportMsg, - "[%s] Authenticated with %s.", hsData->streamName.c_str(), - protocolName.c_str() ); - return Status(); + info->authProtocol->Delete(); + info->authProtocol = 0; } //---------------------------------------------------------------------- - // Failure + // Find another protocol that gives us valid credentials //---------------------------------------------------------------------- - else if( rsp->hdr.status == kXR_error ) + Status st = GetCredentials( credentials, hsData, info ); + if( !st.IsOK() ) { - log->Error( XRootDTransportMsg, - "[%s] Authentication with %s failed: %s", - hsData->streamName.c_str(), protocolName.c_str(), - rsp->body.error.errmsg ); - - return Status( stFatal, errAuthFailed ); + CleanUpAuthentication( info ); + return st; } + protocolName = info->authProtocol->Entity.prot; + } + //------------------------------------------------------------------------ + // God knows what + //------------------------------------------------------------------------ + else + { + info->authProtocolName = info->authProtocol->Entity.prot; + CleanUpAuthentication( info ); - //---------------------------------------------------------------------- - // God knows what - //---------------------------------------------------------------------- log->Error( XRootDTransportMsg, "[%s] Authentication with %s failed: unexpected answer", hsData->streamName.c_str(), protocolName.c_str() );