]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/config.c
Reverse last commit. Wrong tree.
[openldap] / servers / slapd / back-ldap / config.c
index 07221bdfbd85c1c2230fe11d866ece1cd7bc9a69..38c9a95296473d0a1e571c003b54144226b71ef7 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2005 The OpenLDAP Foundation.
+ * Copyright 2003-2006 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -61,6 +61,7 @@ enum {
        LDAP_BACK_CFG_WHOAMI,
        LDAP_BACK_CFG_TIMEOUT,
        LDAP_BACK_CFG_IDLE_TIMEOUT,
+       LDAP_BACK_CFG_CONN_TTL,
        LDAP_BACK_CFG_REWRITE,
 
        LDAP_BACK_CFG_LAST
@@ -223,6 +224,14 @@ static ConfigTable ldapcfg[] = {
                        "SYNTAX OMsDirectoryString "
                        "SINGLE-VALUE )",
                NULL, NULL },
+       { "conn-ttl", "ttl", 2, 0, 0,
+               ARG_MAGIC|LDAP_BACK_CFG_CONN_TTL,
+               ldap_back_cf_gen, "( OLcfgDbAt:3.16 "
+                       "NAME 'olcDbConnTtl' "
+                       "DESC 'connection ttl' "
+                       "SYNTAX OMsDirectoryString "
+                       "SINGLE-VALUE )",
+               NULL, NULL },
        { "suffixmassage", "[virtual]> <real", 2, 3, 0,
                ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_REWRITE,
                ldap_back_cf_gen, NULL, NULL, NULL },
@@ -305,6 +314,10 @@ ldap_back_cf_gen( ConfigArgs *c )
                struct berval   bv = BER_BVNULL;
                rc = 0;
 
+               if ( li == NULL ) {
+                       return 1;
+               }
+
                switch( c->type ) {
                case LDAP_BACK_CFG_URI:
                        if ( li->li_uri != NULL ) {
@@ -340,7 +353,7 @@ ldap_back_cf_gen( ConfigArgs *c )
 
                        bindconf_unparse( &li->li_acl, &bv );
 
-                       for ( i = 0; isspace( bv.bv_val[ i ] ); i++ )
+                       for ( i = 0; isspace( (unsigned char) bv.bv_val[ i ] ); i++ )
                                /* count spaces */ ;
 
                        if ( i ) {
@@ -475,7 +488,7 @@ ldap_back_cf_gen( ConfigArgs *c )
                                bv.bv_len = ptr - bv.bv_val;
 
                        } else {
-                               for ( i = 0; isspace( bc.bv_val[ i ] ); i++ )
+                               for ( i = 0; isspace( (unsigned char) bc.bv_val[ i ] ); i++ )
                                        /* count spaces */ ;
 
                                if ( i ) {
@@ -534,7 +547,7 @@ ldap_back_cf_gen( ConfigArgs *c )
                                return 1;
                        }
 
-                       for ( i = 0; isspace( bv.bv_val[ i ] ); i++ )
+                       for ( i = 0; isspace( (unsigned char) bv.bv_val[ i ] ); i++ )
                                /* count spaces */ ;
 
                        if ( i ) {
@@ -558,6 +571,18 @@ ldap_back_cf_gen( ConfigArgs *c )
                        value_add_one( &c->rvalue_vals, &bv );
                        } break;
 
+               case LDAP_BACK_CFG_CONN_TTL: {
+                       char    buf[ SLAP_TEXT_BUFLEN ];
+
+                       if ( li->li_conn_ttl == 0 ) {
+                               return 1;
+                       }
+
+                       lutil_unparse_time( buf, sizeof( buf ), li->li_conn_ttl );
+                       ber_str2bv( buf, 0, 0, &bv );
+                       value_add_one( &c->rvalue_vals, &bv );
+                       } break;
+
                default:
                        /* FIXME: we need to handle all... */
                        assert( 0 );
@@ -639,6 +664,10 @@ ldap_back_cf_gen( ConfigArgs *c )
                        li->li_idle_timeout = 0;
                        break;
 
+               case LDAP_BACK_CFG_CONN_TTL:
+                       li->li_conn_ttl = 0;
+                       break;
+
                default:
                        /* FIXME: we need to handle all... */
                        assert( 0 );
@@ -1074,8 +1103,9 @@ done_url:;
                                                snprintf( c->msg, sizeof( c->msg ),
                                                        "\"idassert-bind <args>\": "
                                                        "unknown flag \"%s\"",
-                                                       c->fname, c->lineno, flags[ j ] );
+                                                       flags[ j ] );
                                                Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
+                                               ldap_charray_free( flags );
                                                return 1;
                                        }
                                }
@@ -1128,7 +1158,7 @@ done_url:;
 
        case LDAP_BACK_CFG_TIMEOUT:
                for ( i = 1; i < c->argc; i++ ) {
-                       if ( isdigit( c->argv[ i ][ 0 ] ) ) {
+                       if ( isdigit( (unsigned char) c->argv[ i ][ 0 ] ) ) {
                                int             j;
                                unsigned        u;
 
@@ -1162,6 +1192,19 @@ done_url:;
                li->li_idle_timeout = (time_t)t;
                } break;
 
+       case LDAP_BACK_CFG_CONN_TTL: {
+               unsigned long   t;
+
+               if ( lutil_parse_time( c->argv[ 1 ], &t ) != 0 ) {
+                       snprintf( c->msg, sizeof( c->msg),
+                               "unable to parse conn ttl\"%s\"",
+                               c->argv[ 1 ] );
+                       Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
+                       return 1;
+               }
+               li->li_conn_ttl = (time_t)t;
+               } break;
+
        case LDAP_BACK_CFG_REWRITE:
                snprintf( c->msg, sizeof( c->msg ),
                        "rewrite/remap capabilities have been moved "
@@ -1280,7 +1323,7 @@ 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, 1, NULL, &res ) == -1 ) {
+                       if ( ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, NULL, &res ) == -1 ) {
                                ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER,
                                        &rs->sr_err );
                                if ( rs->sr_err == LDAP_SERVER_DOWN && doretry ) {