]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/config.c
ConnTTL, NetworkTimeout, and ProtocolVersion were missing from the
[openldap] / servers / slapd / back-ldap / config.c
index ca89cf97f082a46f48b48f01f1148c2bb5a05384..c741a39ba776318c162cc0d9235446924b2a0137 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2008 The OpenLDAP Foundation.
+ * Copyright 2003-2009 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -359,6 +359,9 @@ static ConfigOCs ldapocs[] = {
                        "$ olcDbProxyWhoAmI "
                        "$ olcDbTimeout "
                        "$ olcDbIdleTimeout "
+                       "$ olcDbConnTtl "
+                       "$ olcDbNetworkTimeout "
+                       "$ olcDbProtocolVersion "
                        "$ olcDbSingleConn "
                        "$ olcDbCancel "
                        "$ olcDbQuarantine "
@@ -510,53 +513,51 @@ slap_retry_info_unparse(
        slap_retry_info_t       *ri,
        struct berval           *bvout )
 {
-       int             i;
        char            buf[ BUFSIZ * 2 ],
                        *ptr = buf;
-       struct berval   bv = BER_BVNULL;
+       int             i, len, restlen = (int) sizeof( buf );
+       struct berval   bv;
 
        assert( ri != NULL );
        assert( bvout != NULL );
 
        BER_BVZERO( bvout );
 
-#define WHATSLEFT      ( sizeof( buf ) - ( ptr - buf ) )
-
        for ( i = 0; ri->ri_num[ i ] != SLAP_RETRYNUM_TAIL; i++ ) {
                if ( i > 0 ) {
-                       if ( WHATSLEFT <= 1 ) {
+                       if ( --restlen <= 0 ) {
                                return 1;
                        }
                        *ptr++ = ';';
                }
 
-               if ( lutil_unparse_time( ptr, WHATSLEFT, (long)ri->ri_interval[i] ) ) {
+               if ( lutil_unparse_time( ptr, restlen, ri->ri_interval[i] ) < 0 ) {
                        return 1;
                }
-               ptr += strlen( ptr );
-
-               if ( WHATSLEFT <= 1 ) {
+               len = (int) strlen( ptr );
+               if ( (restlen -= len + 1) <= 0 ) {
                        return 1;
                }
+               ptr += len;
                *ptr++ = ',';
 
                if ( ri->ri_num[i] == SLAP_RETRYNUM_FOREVER ) {
-                       if ( WHATSLEFT <= 1 ) {
+                       if ( --restlen <= 0 ) {
                                return 1;
                        }
                        *ptr++ = '+';
 
                } else {
-                       ptr += snprintf( ptr, WHATSLEFT, "%d", ri->ri_num[i] );
-                       if ( WHATSLEFT <= 0 ) {
+                       len = snprintf( ptr, restlen, "%d", ri->ri_num[i] );
+                       if ( (restlen -= len) <= 0 || len < 0 ) {
                                return 1;
                        }
+                       ptr += len;
                }
        }
 
        bv.bv_val = buf;
        bv.bv_len = ptr - buf;
-
        ber_dupbv( bvout, &bv );
 
        return 0;
@@ -742,9 +743,27 @@ slap_idassert_parse( ConfigArgs *c, slap_idassert_t *si )
                        }
 
                } else if ( bindconf_parse( c->argv[ i ], &si->si_bc ) ) {
+                       snprintf( c->cr_msg, sizeof( c->cr_msg ),
+                               "\"idassert-bind <args>\": "
+                               "unable to parse field \"%s\"",
+                               c->argv[ i ] );
+                       Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg, 0 );
                        return 1;
                }
        }
+
+       if ( si->si_bc.sb_method == LDAP_AUTH_SIMPLE ) {
+               if ( BER_BVISNULL( &si->si_bc.sb_binddn )
+                       || BER_BVISNULL( &si->si_bc.sb_cred ) )
+               {
+                       snprintf( c->cr_msg, sizeof( c->cr_msg ),
+                               "\"idassert-bind <args>\": "
+                               "SIMPLE needs \"binddn\" and \"credentials\"" );
+                       Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg, 0 );
+                       return 1;
+               }
+       }
+
        bindconf_tls_defaults( &si->si_bc );
 
        return 0;
@@ -2075,7 +2094,10 @@ ldap_back_exop_whoami(
 retry:
                rs->sr_err = ldap_whoami( lc->lc_ld, ctrls, NULL, &msgid );
                if ( rs->sr_err == LDAP_SUCCESS ) {
-                       if ( ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, NULL, &res ) == -1 ) {
+                       /* by now, make sure no timeout is used (ITS#6282) */
+                       struct timeval tv;
+                       tv.tv_sec = -1;
+                       if ( ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, &tv, &res ) == -1 ) {
                                ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER,
                                        &rs->sr_err );
                                if ( rs->sr_err == LDAP_SERVER_DOWN && doretry ) {