]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/config.c
Plug leaks
[openldap] / servers / slapd / config.c
index f4fb95618cfb60b7ca7bdebb0b8e458e44b60fe2..54dcf2d571eb86deeb9a8709c9d3cb26dff9ebde 100644 (file)
@@ -68,7 +68,6 @@ int           global_gentlehup = 0;
 int            global_idletimeout = 0;
 char   *global_host = NULL;
 char   *global_realm = NULL;
-char           *ldap_srvtab = "";
 char           **default_passwd_hash = NULL;
 struct berval default_search_base = BER_BVNULL;
 struct berval default_search_nbase = BER_BVNULL;
@@ -1034,6 +1033,8 @@ static slap_cf_aux_table bindkey[] = {
        { BER_BVC("uri="), offsetof(slap_bindconf, sb_uri), 'b', 1, NULL },
        { BER_BVC("version="), offsetof(slap_bindconf, sb_version), 'i', 0, versionkey },
        { BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 'i', 0, methkey },
+       { BER_BVC("timeout="), offsetof(slap_bindconf, sb_timeout_api), 'i', 0, NULL },
+       { BER_BVC("network-timeout="), offsetof(slap_bindconf, sb_timeout_net), 'i', 0, NULL },
        { BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 'b', 1, (slap_verbmasks *)dnNormalize },
        { BER_BVC("credentials="), offsetof(slap_bindconf, sb_cred), 'b', 1, NULL },
        { BER_BVC("saslmech="), offsetof(slap_bindconf, sb_saslmech), 'b', 0, NULL },
@@ -1044,9 +1045,9 @@ static slap_cf_aux_table bindkey[] = {
 #ifdef HAVE_TLS
        { BER_BVC("starttls="), offsetof(slap_bindconf, sb_tls), 'i', 0, tlskey },
 
-       /* NOTE: replace "11" with the actual index
+       /* NOTE: replace "13" with the actual index
         * of the first TLS-related line */
-#define aux_TLS (bindkey+11)   /* beginning of TLS keywords */
+#define aux_TLS (bindkey+13)   /* beginning of TLS keywords */
 
        { BER_BVC("tls_cert="), offsetof(slap_bindconf, sb_tls_cert), 's', 1, NULL },
        { BER_BVC("tls_key="), offsetof(slap_bindconf, sb_tls_key), 's', 1, NULL },
@@ -1255,12 +1256,14 @@ slap_tls_get_config( LDAP *ld, int opt, char **val )
 
        *val = NULL;
        switch( opt ) {
+#ifdef HAVE_TLS
        case LDAP_OPT_X_TLS_CRLCHECK:
                keys = crlkeys;
                break;
        case LDAP_OPT_X_TLS_REQUIRE_CERT:
                keys = vfykeys;
                break;
+#endif
        default:
                return -1;
        }
@@ -1275,14 +1278,34 @@ slap_tls_get_config( LDAP *ld, int opt, char **val )
 }
 
 int
-bindconf_parse( const char *word, slap_bindconf *bc )
+bindconf_tls_parse( const char *word, slap_bindconf *bc )
 {
 #ifdef HAVE_TLS
-       /* Detect TLS config changes explicitly */
        if ( slap_cf_aux_table_parse( word, bc, aux_TLS, "tls config" ) == 0 ) {
                bc->sb_tls_do_init = 1;
                return 0;
        }
+#endif
+       return -1;
+}
+
+int
+bindconf_tls_unparse( slap_bindconf *bc, struct berval *bv )
+{
+#ifdef HAVE_TLS
+       return slap_cf_aux_table_unparse( bc, bv, aux_TLS );
+#endif
+       return -1;
+}
+
+int
+bindconf_parse( const char *word, slap_bindconf *bc )
+{
+#ifdef HAVE_TLS
+       /* Detect TLS config changes explicitly */
+       if ( bindconf_tls_parse( word, bc ) == 0 ) {
+               return 0;
+       }
 #endif
        return slap_cf_aux_table_parse( word, bc, bindkey, "bind config" );
 }
@@ -1482,6 +1505,7 @@ slap_client_connect( LDAP **ldp, slap_bindconf *sb )
 {
        LDAP            *ld = NULL;
        int             rc;
+       struct timeval tv;
 
        /* Init connection to master */
        rc = ldap_initialize( &ld, sb->sb_uri.bv_val );
@@ -1498,6 +1522,18 @@ slap_client_connect( LDAP **ldp, slap_bindconf *sb )
                        (const void *)&sb->sb_version );
        }
 
+       if ( sb->sb_timeout_api ) {
+               tv.tv_sec = sb->sb_timeout_api;
+               tv.tv_usec = 0;
+               ldap_set_option( ld, LDAP_OPT_TIMEOUT, &tv );
+       }
+
+       if ( sb->sb_timeout_net ) {
+               tv.tv_sec = sb->sb_timeout_net;
+               tv.tv_usec = 0;
+               ldap_set_option( ld, LDAP_OPT_NETWORK_TIMEOUT, &tv );
+       }
+
 #ifdef HAVE_TLS
        if ( sb->sb_tls_do_init ) {
                rc = bindconf_tls_set( sb, ld );