Diff for /libraries/libldap/sasl.c between versions 1.64.2.11 and 1.64.2.12

version 1.64.2.11, 2011/01/04 23:50:04 version 1.64.2.12, 2011/01/06 18:18:17
Line 1 Line 1
 /* $OpenLDAP: pkg/ldap/libraries/libldap/sasl.c,v 1.64.2.10 2011/01/03 22:00:15 quanah Exp $ */  /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.  /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *   *
  * Copyright 1998-2011 The OpenLDAP Foundation.   * Copyright 1998-2011 The OpenLDAP Foundation.
Line 401  ldap_pvt_sasl_getmechs ( LDAP *ld, char Line 401  ldap_pvt_sasl_getmechs ( LDAP *ld, char
 }  }
   
 /*  /*
  * ldap_sasl_interactive_bind_s - interactive SASL authentication   * ldap_sasl_interactive_bind - interactive SASL authentication
  *   *
  * This routine uses interactive callbacks.   * This routine uses interactive callbacks.
  *   *
  * LDAP_SUCCESS is returned upon success, the ldap error code   * LDAP_SUCCESS is returned upon success, the ldap error code
  * otherwise.   * otherwise. LDAP_SASL_BIND_IN_PROGRESS is returned if further
    * calls are needed.
  */   */
 int  int
 ldap_sasl_interactive_bind_s(  ldap_sasl_interactive_bind(
         LDAP *ld,          LDAP *ld,
         LDAP_CONST char *dn, /* usually NULL */          LDAP_CONST char *dn, /* usually NULL */
         LDAP_CONST char *mechs,          LDAP_CONST char *mechs,
Line 417  ldap_sasl_interactive_bind_s( Line 418  ldap_sasl_interactive_bind_s(
         LDAPControl **clientControls,          LDAPControl **clientControls,
         unsigned flags,          unsigned flags,
         LDAP_SASL_INTERACT_PROC *interact,          LDAP_SASL_INTERACT_PROC *interact,
         void *defaults )          void *defaults,
           LDAPMessage *result,
           const char **rmech,
           int *msgid )
 {  {
         int rc;  
         char *smechs = NULL;          char *smechs = NULL;
           int rc;
   
 #if defined( HAVE_CYRUS_SASL )  #if defined( HAVE_CYRUS_SASL )
         LDAP_MUTEX_LOCK( &ldap_int_sasl_mutex );          LDAP_MUTEX_LOCK( &ldap_int_sasl_mutex );
Line 437  ldap_sasl_interactive_bind_s( Line 441  ldap_sasl_interactive_bind_s(
         } else          } else
 #endif  #endif
   
           /* First time */
           if ( !result ) {
   
 #ifdef HAVE_CYRUS_SASL  #ifdef HAVE_CYRUS_SASL
         if( mechs == NULL || *mechs == '\0' ) {          if( mechs == NULL || *mechs == '\0' ) {
                 mechs = ld->ld_options.ldo_def_sasl_mech;                  mechs = ld->ld_options.ldo_def_sasl_mech;
Line 444  ldap_sasl_interactive_bind_s( Line 451  ldap_sasl_interactive_bind_s(
 #endif  #endif
                                   
         if( mechs == NULL || *mechs == '\0' ) {          if( mechs == NULL || *mechs == '\0' ) {
                   /* FIXME: this needs to be asynchronous too;
                    * perhaps NULL should be disallowed for async usage?
                    */
                 rc = ldap_pvt_sasl_getmechs( ld, &smechs );                  rc = ldap_pvt_sasl_getmechs( ld, &smechs );
                 if( rc != LDAP_SUCCESS ) {                  if( rc != LDAP_SUCCESS ) {
                         goto done;                          goto done;
                 }                  }
   
                 Debug( LDAP_DEBUG_TRACE,                  Debug( LDAP_DEBUG_TRACE,
                         "ldap_sasl_interactive_bind_s: server supports: %s\n",                          "ldap_sasl_interactive_bind: server supports: %s\n",
                         smechs, 0, 0 );                          smechs, 0, 0 );
   
                 mechs = smechs;                  mechs = smechs;
   
         } else {          } else {
                 Debug( LDAP_DEBUG_TRACE,                  Debug( LDAP_DEBUG_TRACE,
                         "ldap_sasl_interactive_bind_s: user selected: %s\n",                          "ldap_sasl_interactive_bind: user selected: %s\n",
                         mechs, 0, 0 );                          mechs, 0, 0 );
         }          }
           }
         rc = ldap_int_sasl_bind( ld, dn, mechs,          rc = ldap_int_sasl_bind( ld, dn, mechs,
                 serverControls, clientControls,                  serverControls, clientControls,
                 flags, interact, defaults );                  flags, interact, defaults, result, rmech, msgid );
   
 done:  done:
 #if defined( HAVE_CYRUS_SASL )  #if defined( HAVE_CYRUS_SASL )
Line 473  done: Line 483  done:
   
         return rc;          return rc;
 }  }
   
   /*
    * ldap_sasl_interactive_bind_s - interactive SASL authentication
    *
    * This routine uses interactive callbacks.
    *
    * LDAP_SUCCESS is returned upon success, the ldap error code
    * otherwise.
    */
   int
   ldap_sasl_interactive_bind_s(
           LDAP *ld,
           LDAP_CONST char *dn, /* usually NULL */
           LDAP_CONST char *mechs,
           LDAPControl **serverControls,
           LDAPControl **clientControls,
           unsigned flags,
           LDAP_SASL_INTERACT_PROC *interact,
           void *defaults )
   {
           const char *rmech = NULL;
           LDAPMessage *result = NULL;
           int rc, msgid;
   
           do {
                   rc = ldap_sasl_interactive_bind( ld, dn, mechs,
                           serverControls, clientControls,
                           flags, interact, defaults, result, &rmech, &msgid );
   
                   ldap_msgfree( result );
   
                   if ( rc != LDAP_SASL_BIND_IN_PROGRESS )
                           break;
   
   #ifdef LDAP_CONNECTIONLESS
                   if (LDAP_IS_UDP(ld)) {
                           break;
                   }
   #endif
   
                   if ( ldap_result( ld, msgid, LDAP_MSG_ALL, NULL, &result ) == -1 || !result ) {
                           return( ld->ld_errno ); /* ldap_result sets ld_errno */
                   }
           } while ( rc == LDAP_SASL_BIND_IN_PROGRESS );
   
           return rc;
   }
   
 #ifdef HAVE_CYRUS_SASL  #ifdef HAVE_CYRUS_SASL
   

Removed from v.1.64.2.11  
changed lines
  Added in v.1.64.2.12


______________
© Copyright 1998-2020, OpenLDAP Foundation, info@OpenLDAP.org