]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/config.c
Partially revert prev commit, leave rs->sr_err == SLAPD_ABANDON
[openldap] / servers / slapd / config.c
index 8c2e633bf3b76915cf3e75d4eed8d96ab3c6c836..c9763bf8be0a853e261675708f1cc6cbce97457e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -62,7 +62,9 @@ slap_mask_t           global_allows = 0;
 slap_mask_t            global_disallows = 0;
 int            global_gentlehup = 0;
 int            global_idletimeout = 0;
+int            global_writetimeout = 0;
 char   *global_host = NULL;
+struct berval global_host_bv = BER_BVNULL;
 char   *global_realm = NULL;
 char   *sasl_host = NULL;
 char           **default_passwd_hash = NULL;
@@ -86,7 +88,6 @@ int slapi_plugins_used = 0;
 
 static int fp_getline(FILE *fp, ConfigArgs *c);
 static void fp_getline_init(ConfigArgs *c);
-static int fp_parse_line(ConfigArgs *c);
 
 static char    *strtok_quote(char *line, char *sep, char **quote_ptr);
 static char *strtok_quote_ldif(char **line);
@@ -215,6 +216,16 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
                        ch_free( c->value_ndn.bv_val );
                        ch_free( c->value_dn.bv_val );
                }
+       } else if(arg_type == ARG_ATDESC) {
+               const char *text = NULL;
+               c->value_ad = NULL;
+               rc = slap_str2ad( c->argv[1], &c->value_ad, &text );
+               if ( rc != LDAP_SUCCESS ) {
+                       snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid AttributeDescription %d (%s)",
+                               c->argv[0], rc, text );
+                       Debug(LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, "%s: %s\n" , c->log, c->cr_msg, 0);
+                       return(ARG_BAD_CONF);
+               }
        } else {        /* all numeric */
                int j;
                iarg = 0; larg = 0; barg = 0;
@@ -365,6 +376,9 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
                        case ARG_BERVAL:
                                *(struct berval *)ptr = c->value_bv;
                                break;
+                       case ARG_ATDESC:
+                               *(AttributeDescription **)ptr = c->value_ad;
+                               break;
                }
        return(0);
 }
@@ -442,6 +456,8 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
                        break;
                case ARG_BERVAL:
                        ber_dupbv( &c->value_bv, (struct berval *)ptr ); break;
+               case ARG_ATDESC:
+                       c->value_ad = *(AttributeDescription **)ptr; break;
                }
        }
        if ( cf->arg_type & ARGS_TYPES) {
@@ -468,6 +484,13 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
                                return 1;
                        }
                        break;
+               case ARG_ATDESC:
+                       if ( c->value_ad ) {
+                               bv = c->value_ad->ad_cname;
+                       } else {
+                               return 1;
+                       }
+                       break;
                default:
                        bv.bv_val = NULL;
                        break;
@@ -496,9 +519,6 @@ init_config_attrs(ConfigTable *ct) {
                        fprintf( stderr, "init_config_attrs: register_at failed\n" );
                        return code;
                }
-#ifndef LDAP_DEVEL
-               ct[i].ad->ad_type->sat_flags |= SLAP_AT_HIDE;
-#endif
        }
 
        return 0;
@@ -514,9 +534,6 @@ init_config_ocs( ConfigOCs *ocs ) {
                        fprintf( stderr, "init_config_ocs: register_oc failed\n" );
                        return code;
                }
-#ifndef LDAP_DEVEL
-               ocs[i].co_oc->soc_flags |= SLAP_OC_HIDE;
-#endif
        }
        return 0;
 }
@@ -722,7 +739,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
 
                c->argc = 0;
                ch_free( c->tline );
-               if ( fp_parse_line( c ) ) {
+               if ( config_fp_parse_line( c ) ) {
                        rc = 1;
                        goto done;
                }
@@ -1206,6 +1223,7 @@ static slap_cf_aux_table bindkey[] = {
        { BER_BVC("tls_cacertdir="), offsetof(slap_bindconf, sb_tls_cacertdir), 's', 1, NULL },
        { BER_BVC("tls_reqcert="), offsetof(slap_bindconf, sb_tls_reqcert), 's', 1, NULL },
        { BER_BVC("tls_cipher_suite="), offsetof(slap_bindconf, sb_tls_cipher_suite), 's', 1, NULL },
+       { BER_BVC("tls_protocol_min="), offsetof(slap_bindconf, sb_tls_protocol_min), 's', 1, NULL },
 #ifdef HAVE_OPENSSL_CRL
        { BER_BVC("tls_crlcheck="), offsetof(slap_bindconf, sb_tls_crlcheck), 's', 1, NULL },
 #endif
@@ -1402,19 +1420,26 @@ slap_cf_aux_table_unparse( void *src, struct berval *bv, slap_cf_aux_table *tab0
 int
 slap_tls_get_config( LDAP *ld, int opt, char **val )
 {
+#ifdef HAVE_TLS
        slap_verbmasks *keys;
        int i, ival;
 
        *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
+       case LDAP_OPT_X_TLS_PROTOCOL_MIN: {
+               char buf[8];
+               ldap_pvt_tls_get_option( ld, opt, &ival );
+               snprintf( buf, sizeof( buf ), "%d.%d",
+                       ( ival >> 8 ) & 0xff, ival & 0xff );
+               *val = ch_strdup( buf );
+               return 0;
+               }
        default:
                return -1;
        }
@@ -1425,6 +1450,7 @@ slap_tls_get_config( LDAP *ld, int opt, char **val )
                        return 0;
                }
        }
+#endif
        return -1;
 }
 
@@ -1525,6 +1551,10 @@ void bindconf_free( slap_bindconf *bc ) {
                ch_free( bc->sb_tls_cipher_suite );
                bc->sb_tls_cipher_suite = NULL;
        }
+       if ( bc->sb_tls_protocol_min ) {
+               ch_free( bc->sb_tls_protocol_min );
+               bc->sb_tls_protocol_min = NULL;
+       }
 #ifdef HAVE_OPENSSL_CRL
        if ( bc->sb_tls_crlcheck ) {
                ch_free( bc->sb_tls_crlcheck );
@@ -1576,6 +1606,7 @@ static struct {
        { "tls_cacert", offsetof(slap_bindconf, sb_tls_cacert), LDAP_OPT_X_TLS_CACERTFILE },
        { "tls_cacertdir", offsetof(slap_bindconf, sb_tls_cacertdir), LDAP_OPT_X_TLS_CACERTDIR },
        { "tls_cipher_suite", offsetof(slap_bindconf, sb_tls_cipher_suite), LDAP_OPT_X_TLS_CIPHER_SUITE },
+       { "tls_protocol_min", offsetof(slap_bindconf, sb_tls_protocol_min), LDAP_OPT_X_TLS_PROTOCOL_MIN },
        {0, 0}
 };
 
@@ -1600,7 +1631,7 @@ int bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
                }
        }
        if ( bc->sb_tls_reqcert ) {
-               rc = ldap_int_tls_config( ld, LDAP_OPT_X_TLS_REQUIRE_CERT,
+               rc = ldap_pvt_tls_config( ld, LDAP_OPT_X_TLS_REQUIRE_CERT,
                        bc->sb_tls_reqcert );
                if ( rc ) {
                        Debug( LDAP_DEBUG_ANY,
@@ -1610,9 +1641,20 @@ int bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
                } else
                        newctx = 1;
        }
+       if ( bc->sb_tls_protocol_min ) {
+               rc = ldap_pvt_tls_config( ld, LDAP_OPT_X_TLS_PROTOCOL_MIN,
+                       bc->sb_tls_protocol_min );
+               if ( rc ) {
+                       Debug( LDAP_DEBUG_ANY,
+                               "bindconf_tls_set: failed to set tls_protocol_min to %s\n",
+                                       bc->sb_tls_protocol_min, 0, 0 );
+                       res = -1;
+               } else
+                       newctx = 1;
+       }
 #ifdef HAVE_OPENSSL_CRL
        if ( bc->sb_tls_crlcheck ) {
-               rc = ldap_int_tls_config( ld, LDAP_OPT_X_TLS_CRLCHECK,
+               rc = ldap_pvt_tls_config( ld, LDAP_OPT_X_TLS_CRLCHECK,
                        bc->sb_tls_crlcheck );
                if ( rc ) {
                        Debug( LDAP_DEBUG_ANY,
@@ -1936,8 +1978,8 @@ fp_getline( FILE *fp, ConfigArgs *c )
        return(line[0] ? 1 : 0);
 }
 
-static int
-fp_parse_line(ConfigArgs *c)
+int
+config_fp_parse_line(ConfigArgs *c)
 {
        char *token;
        static char *const hide[] = {
@@ -1990,7 +2032,7 @@ config_destroy( )
                if ( frontendDB->be_schemadn.bv_val )
                        free( frontendDB->be_schemadn.bv_val );
                if ( frontendDB->be_acl )
-                       acl_destroy( frontendDB->be_acl, NULL );
+                       acl_destroy( frontendDB->be_acl );
        }
        free( line );
        if ( slapd_args_file )