]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/bconfig.c
ITS#5186 check for multiple suffixes at config time, not open time
[openldap] / servers / slapd / bconfig.c
index 3b651a680a67bd38ea21b1b127efa3595ee09d21..a0fa91525988b6a48573f802fe0097b4ee19c653 100644 (file)
@@ -77,6 +77,7 @@ typedef struct {
 static CfBackInfo cfBackInfo;
 
 static char    *passwd_salt;
+static FILE *logfile;
 static char    *logfileName;
 #ifdef SLAP_AUTH_REWRITE
 static BerVarray authz_rewrites;
@@ -177,6 +178,7 @@ enum {
        CFG_HIDDEN,
        CFG_MONITORING,
        CFG_SERVERID,
+       CFG_SORTVALS,
 
        CFG_LAST
 };
@@ -193,11 +195,13 @@ static OidRec OidMacros[] = {
        { "OLcfgBkAt", "OLcfgAt:1" },
        { "OLcfgDbAt", "OLcfgAt:2" },
        { "OLcfgOvAt", "OLcfgAt:3" },
+       { "OLcfgCtAt", "OLcfgAt:4" },   /* contrib modules */
        { "OLcfgOc", "OLcfg:4" },
        { "OLcfgGlOc", "OLcfgOc:0" },
        { "OLcfgBkOc", "OLcfgOc:1" },
        { "OLcfgDbOc", "OLcfgOc:2" },
        { "OLcfgOvOc", "OLcfgOc:3" },
+       { "OLcfgCtOc", "OLcfgOc:4" },   /* contrib modules */
 
        /* Syntaxes. We should just start using the standard names and
         * document that they are predefined and available for users
@@ -208,6 +212,7 @@ static OidRec OidMacros[] = {
        { "OMsBoolean", "OMsyn:7" },
        { "OMsDN", "OMsyn:12" },
        { "OMsDirectoryString", "OMsyn:15" },
+       { "OMsIA5String", "OMsyn:26" },
        { "OMsInteger", "OMsyn:27" },
        { "OMsOID", "OMsyn:38" },
        { "OMsOctetString", "OMsyn:40" },
@@ -234,8 +239,6 @@ static OidRec OidMacros[] = {
  * OLcfgOv{Oc|At}:3                    -> chain
  * OLcfgOv{Oc|At}:4                    -> accesslog
  * OLcfgOv{Oc|At}:5                    -> valsort
- * (FIXME: separate arc for contribware?)
- * OLcfgOv{Oc|At}:6                    -> smbk5pwd
  * OLcfgOv{Oc|At}:7                    -> distproc
  * OLcfgOv{Oc|At}:8                    -> dynlist
  * OLcfgOv{Oc|At}:9                    -> dds
@@ -248,6 +251,7 @@ static OidRec OidMacros[] = {
  * OLcfgOv{Oc|At}:16                   -> rwm
  * OLcfgOv{Oc|At}:17                   -> dyngroup
  * OLcfgOv{Oc|At}:18                   -> memberof
+ * OLcfgOv{Oc|At}:19                   -> collect
  */
 
 /* alphabetical ordering */
@@ -354,7 +358,8 @@ static ConfigTable config_back_cf_table[] = {
                &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
                        "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
        { "include", "file", 2, 2, 0, ARG_MAGIC,
-               &config_include, NULL, NULL, NULL },
+               &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
+                       "SUP labeledURI )", NULL, NULL },
        { "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
                &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
                        "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
@@ -503,7 +508,7 @@ static ConfigTable config_back_cf_table[] = {
                &config_generic, NULL, NULL, NULL },
        { "sasl-host", "host", 2, 2, 0,
 #ifdef HAVE_CYRUS_SASL
-               ARG_STRING|ARG_UNIQUE, &global_host,
+               ARG_STRING|ARG_UNIQUE, &sasl_host,
 #else
                ARG_IGNORED, NULL,
 #endif
@@ -549,6 +554,11 @@ static ConfigTable config_back_cf_table[] = {
        { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
                &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
                        "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
+       { "sortvals", "attr", 2, 0, 0, ARG_MAGIC|CFG_SORTVALS,
+               &config_generic, "( OLcfgGlAt:83 NAME 'olcSortVals' "
+                       "DESC 'Attributes whose values will always be sorted' "
+                       "EQUALITY caseIgnoreMatch "
+                       "SYNTAX OMsDirectoryString )", NULL, NULL },
        { "subordinate", "[advertise]", 1, 2, 0, ARG_DB|ARG_MAGIC,
                &config_subordinate, "( OLcfgDbAt:0.15 NAME 'olcSubordinate' "
                        "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
@@ -668,7 +678,7 @@ static ConfigTable config_back_cf_table[] = {
 };
 
 /* Routines to check if a child can be added to this type */
-static ConfigLDAPadd cfAddSchema, cfAddDatabase,
+static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
        cfAddBackend, cfAddModule, cfAddOverlay;
 
 /* NOTE: be careful when defining array members
@@ -678,9 +688,10 @@ static ConfigLDAPadd cfAddSchema, cfAddDatabase,
 #define CFOC_BACKEND   cf_ocs[3]
 #define CFOC_DATABASE  cf_ocs[4]
 #define CFOC_OVERLAY   cf_ocs[5]
-#define CFOC_FRONTEND  cf_ocs[6]
+#define CFOC_INCLUDE   cf_ocs[6]
+#define CFOC_FRONTEND  cf_ocs[7]
 #ifdef SLAPD_MODULES
-#define CFOC_MODULE    cf_ocs[7]
+#define CFOC_MODULE    cf_ocs[8]
 #endif /* SLAPD_MODULES */
 
 static ConfigOCs cf_ocs[] = {
@@ -700,7 +711,7 @@ static ConfigOCs cf_ocs[] = {
                 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
                 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcLocalSSF $ "
                 "olcLogLevel $ "
-                "olcPasswordCryptSaltFormat $ olcPidFile $ "
+                "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
                 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
                 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
                 "olcRootDSE $ "
@@ -745,6 +756,14 @@ static ConfigOCs cf_ocs[] = {
                "DESC 'OpenLDAP Overlay-specific options' "
                "SUP olcConfig STRUCTURAL "
                "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
+       { "( OLcfgGlOc:6 "
+               "NAME 'olcIncludeFile' "
+               "DESC 'OpenLDAP configuration include file' "
+               "SUP olcConfig STRUCTURAL "
+               "MUST olcInclude "
+               "MAY ( cn $ olcRootDSE ) )",
+               /* Used to be Cft_Include, that def has been removed */
+               Cft_Abstract, NULL, cfAddInclude },
        /* This should be STRUCTURAL like all the other database classes, but
         * that would mean inheriting all of the olcDatabaseConfig attributes,
         * which causes them to be merged twice in config_build_entry.
@@ -753,7 +772,7 @@ static ConfigOCs cf_ocs[] = {
                "NAME 'olcFrontendConfig' "
                "DESC 'OpenLDAP frontend configuration' "
                "AUXILIARY "
-               "MAY ( olcDefaultSearchBase $ olcPasswordHash ) )",
+               "MAY ( olcDefaultSearchBase $ olcPasswordHash $ olcSortVals ) )",
                Cft_Database, NULL, NULL },
 #ifdef SLAPD_MODULES
        { "( OLcfgGlOc:8 "
@@ -774,6 +793,13 @@ typedef struct ServerID {
 
 static ServerID *sid_list;
 
+typedef struct ADlist {
+       struct ADlist *al_next;
+       AttributeDescription *al_desc;
+} ADlist;
+
+static ADlist *sortVals;
+
 static int
 config_generic(ConfigArgs *c) {
        int i;
@@ -988,6 +1014,14 @@ config_generic(ConfigArgs *c) {
                case CFG_SSTR_IF_MIN:
                        c->value_int = index_substr_if_minlen;
                        break;
+               case CFG_SORTVALS: {
+                       ADlist *sv;
+                       rc = 1;
+                       for ( sv = sortVals; sv; sv = sv->al_next ) {
+                               value_add_one( &c->rvalue_vals, &sv->al_desc->ad_cname );
+                               rc = 0;
+                       }
+                       } break;
 #ifdef SLAPD_MODULES
                case CFG_MODLOAD: {
                        ModPaths *mp = c->private;
@@ -1091,6 +1125,10 @@ config_generic(ConfigArgs *c) {
                case CFG_LOGFILE:
                        ch_free( logfileName );
                        logfileName = NULL;
+                       if ( logfile ) {
+                               fclose( logfile );
+                               logfile = NULL;
+                       }
                        break;
 
                case CFG_SERVERID: {
@@ -1138,10 +1176,14 @@ config_generic(ConfigArgs *c) {
                        break;
 
                case CFG_OC: {
-                       CfEntryInfo *ce = c->ca_entry->e_private;
-                       /* can't modify the hardcoded schema */
-                       if ( ce->ce_parent->ce_type == Cft_Global )
-                               return 1;
+                       CfEntryInfo *ce;
+                       /* Can be NULL when undoing a failed add */
+                       if ( c->ca_entry ) {
+                               ce = c->ca_entry->e_private;
+                               /* can't modify the hardcoded schema */
+                               if ( ce->ce_parent->ce_type == Cft_Global )
+                                       return 1;
+                               }
                        }
                        cfn = c->private;
                        if ( c->valx < 0 ) {
@@ -1172,10 +1214,14 @@ config_generic(ConfigArgs *c) {
                        break;
 
                case CFG_ATTR: {
-                       CfEntryInfo *ce = c->ca_entry->e_private;
-                       /* can't modify the hardcoded schema */
-                       if ( ce->ce_parent->ce_type == Cft_Global )
-                               return 1;
+                       CfEntryInfo *ce;
+                       /* Can be NULL when undoing a failed add */
+                       if ( c->ca_entry ) {
+                               ce = c->ca_entry->e_private;
+                               /* can't modify the hardcoded schema */
+                               if ( ce->ce_parent->ce_type == Cft_Global )
+                                       return 1;
+                               }
                        }
                        cfn = c->private;
                        if ( c->valx < 0 ) {
@@ -1204,6 +1250,27 @@ config_generic(ConfigArgs *c) {
                                }
                        }
                        break;
+               case CFG_SORTVALS:
+                       if ( c->valx < 0 ) {
+                               ADlist *sv;
+                               for ( sv = sortVals; sv; sv = sortVals ) {
+                                       sortVals = sv->al_next;
+                                       sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
+                                       ch_free( sv );
+                               }
+                       } else {
+                               ADlist *sv, **prev;
+                               int i = 0;
+
+                               for ( prev = &sortVals, sv = sortVals; i < c->valx; i++ ) {
+                                       prev = &sv->al_next;
+                                       sv = sv->al_next;
+                               }
+                               sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
+                               *prev = sv->al_next;
+                               ch_free( sv );
+                       }
+                       break;
 
                case CFG_LIMITS:
                        /* FIXME: there is no limits_free function */
@@ -1427,6 +1494,53 @@ config_generic(ConfigArgs *c) {
                                        return(1);
                        break;
 
+               case CFG_SORTVALS: {
+                       ADlist *svnew = NULL, *svtail, *sv;
+
+                       for ( i = 1; i < c->argc; i++ ) {
+                               AttributeDescription *ad = NULL;
+                               const char *text;
+                               int rc;
+
+                               rc = slap_str2ad( c->argv[i], &ad, &text );
+                               if ( rc ) {
+                                       snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown attribute type #%d",
+                                               c->argv[0], i );
+sortval_reject:
+                                       Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
+                                               c->log, c->cr_msg, c->argv[i] );
+                                       for ( sv = svnew; sv; sv = svnew ) {
+                                               svnew = sv->al_next;
+                                               ch_free( sv );
+                                       }
+                                       return 1;
+                               }
+                               if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) ||
+                                       ad->ad_type->sat_single_value ) {
+                                       snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> inappropriate attribute type #%d",
+                                               c->argv[0], i );
+                                       goto sortval_reject;
+                               }
+                               sv = ch_malloc( sizeof( ADlist ));
+                               sv->al_desc = ad;
+                               if ( !svnew ) {
+                                       svnew = sv;
+                               } else {
+                                       svtail->al_next = sv;
+                               }
+                               svtail = sv;
+                       }
+                       sv->al_next = NULL;
+                       for ( sv = svnew; sv; sv = sv->al_next )
+                               sv->al_desc->ad_type->sat_flags |= SLAP_AT_SORTED_VAL;
+                       for ( sv = sortVals; sv && sv->al_next; sv = sv->al_next );
+                       if ( sv )
+                               sv->al_next = svnew;
+                       else
+                               sortVals = svnew;
+                       }
+                       break;
+
                case CFG_ACL:
                        /* Don't append to the global ACL if we're on a specific DB */
                        i = c->valx;
@@ -1507,6 +1621,9 @@ config_generic(ConfigArgs *c) {
                                        si = ch_malloc( sizeof(ServerID) );
                                        BER_BVZERO( &si->si_url );
                                        slap_serverID = num;
+                                       Debug( LDAP_DEBUG_CONFIG,
+                                               "%s: SID=%d\n",
+                                               c->log, slap_serverID, 0 );
                                }
                                si->si_next = NULL;
                                si->si_num = num;
@@ -1557,6 +1674,10 @@ config_generic(ConfigArgs *c) {
                                                        ldap_free_urldesc( lu2 );
                                                        if ( isMe ) {
                                                                slap_serverID = si->si_num;
+                                                               Debug( LDAP_DEBUG_CONFIG,
+                                                                       "%s: SID=%d (listener=%s)\n",
+                                                                       c->log, slap_serverID,
+                                                                       l[i]->sl_url.bv_val );
                                                                break;
                                                        }
                                                }
@@ -1567,7 +1688,6 @@ config_generic(ConfigArgs *c) {
                        }
                        break;
                case CFG_LOGFILE: {
-                               FILE *logfile;
                                if ( logfileName ) ch_free( logfileName );
                                logfileName = c->value_string;
                                logfile = fopen(logfileName, "w");
@@ -1806,17 +1926,27 @@ config_search_base(ConfigArgs *c) {
        return(0);
 }
 
+/* For RE23 compatibility we allow this in the global entry
+ * but we now defer it to the frontend entry to allow modules
+ * to load new hash types.
+ */
 static int
 config_passwd_hash(ConfigArgs *c) {
        int i;
        if (c->op == SLAP_CONFIG_EMIT) {
                struct berval bv;
+               /* Don't generate it in the global entry */
+               if ( c->table == Cft_Global )
+                       return 1;
                for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
                        ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
                        value_add_one(&c->rvalue_vals, &bv);
                }
                return i ? 0 : 1;
        } else if ( c->op == LDAP_MOD_DELETE ) {
+               /* Deleting from global is a no-op, only the frontendDB entry matters */
+               if ( c->table == Cft_Global )
+                       return 0;
                if ( c->valx < 0 ) {
                        ldap_charray_free( default_passwd_hash );
                        default_passwd_hash = NULL;
@@ -1828,12 +1958,6 @@ config_passwd_hash(ConfigArgs *c) {
                }
                return 0;
        }
-       if(default_passwd_hash) {
-               Debug(LDAP_DEBUG_ANY, "%s: "
-                       "already set default password_hash\n",
-                       c->log, 0, 0);
-               return(1);
-       }
        for(i = 1; i < c->argc; i++) {
                if(!lutil_passwd_scheme(c->argv[i])) {
                        snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> scheme not available", c->argv[0] );
@@ -1842,12 +1966,12 @@ config_passwd_hash(ConfigArgs *c) {
                } else {
                        ldap_charray_add(&default_passwd_hash, c->argv[i]);
                }
-               if(!default_passwd_hash) {
-                       snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> no valid hashes found", c->argv[0] );
-                       Debug(LDAP_DEBUG_ANY, "%s: %s\n",
-                               c->log, c->cr_msg, 0 );
-                       return(1);
-               }
+       }
+       if(!default_passwd_hash) {
+               snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> no valid hashes found", c->argv[0] );
+               Debug(LDAP_DEBUG_ANY, "%s: %s\n",
+                       c->log, c->cr_msg, 0 );
+               return(1);
        }
        return(0);
 }
@@ -2120,8 +2244,17 @@ config_suffix(ConfigArgs *c)
        }
 #endif
 
+       if (SLAP_DB_ONE_SUFFIX( c->be ) && c->be->be_suffix ) {
+               snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> Only one suffix is allowed on this %s backend",
+                       c->argv[0], c->be->bd_info->bi_type );
+               Debug(LDAP_DEBUG_ANY, "%s: %s\n",
+                       c->log, c->cr_msg, 0);
+               return(1);
+       }
+
        pdn = c->value_dn;
        ndn = c->value_ndn;
+
        if (SLAP_DBHIDDEN( c->be ))
                tbe = NULL;
        else
@@ -2856,7 +2989,10 @@ config_include(ConfigArgs *c) {
        ConfigFile *cfsave = cfn;
        ConfigFile *cf2 = NULL;
 
-       /* No dynamic config for include files */
+       /* Leftover from RE23. No dynamic config for include files */
+       if ( c->op == SLAP_CONFIG_EMIT || c->op == LDAP_MOD_DELETE )
+               return 1;
+
        cf = ch_calloc( 1, sizeof(ConfigFile));
        if ( cfn->c_kids ) {
                for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
@@ -3785,6 +3921,13 @@ count_ocs( Attribute *oc_at, int *nocs )
        return colst;
 }
 
+static int
+cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
+{
+       /* Leftover from RE23. Never parse this entry */
+       return LDAP_COMPARE_TRUE;
+}
+
 static int
 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
 {
@@ -4057,11 +4200,26 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
                rc = LDAP_SUCCESS;
        }
 
+       colst = count_ocs( oc_at, &nocs );
+
        /* Check whether the Add is allowed by its parent, and do
         * any necessary arg setup
         */
        if ( last ) {
                rc = config_add_oc( &coptr, last, e, ca );
+               if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
+                       for ( i = 0; i<nocs; i++ ) {
+                               /* Already checked these */
+                               if ( colst[i]->co_oc->soc_kind == LDAP_SCHEMA_STRUCTURAL )
+                                       continue;
+                               if ( colst[i]->co_ldadd &&
+                                       ( rc = colst[i]->co_ldadd( last, e, ca ))
+                                               != LDAP_CONSTRAINT_VIOLATION ) {
+                                       coptr = colst[i];
+                                       break;
+                               }
+                       }
+               }
                if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
                        Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
                                "DN=\"%s\" no structural objectClass add function\n",
@@ -4070,8 +4228,6 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
                }
        }
 
-       colst = count_ocs( oc_at, &nocs );
-
        /* Add the entry but don't parse it, we already have its contents */
        if ( rc == LDAP_COMPARE_TRUE ) {
                rc = LDAP_SUCCESS;
@@ -4170,6 +4326,8 @@ ok:
                                rc = ca->bi->bi_db_open( ca->be, &ca->reply );
                                ca->be->bd_info = bi_orig;
                        }
+               } else if ( ca->cleanup ) {
+                       rc = ca->cleanup( ca );
                }
                if ( rc ) {
                        if (ca->cr_msg[0] == '\0')
@@ -4503,7 +4661,7 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
                         */
                        if ( ct && ml->sml_values ) {
                                delrec *d;
-                               for (i=0; ml->sml_values[i].bv_val; i++);
+                               i = ml->sml_numvals;
                                d = ch_malloc( sizeof(delrec) + (i - 1)* sizeof(int));
                                d->nidx = i;
                                d->next = NULL;
@@ -4536,8 +4694,7 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
                                if ( ct->arg_type & ARG_NO_INSERT ) {
                                        Attribute *a = attr_find( e->e_attrs, ml->sml_desc );
                                        if ( a ) {
-                                               for (i = 0; a->a_vals[i].bv_val; i++ );
-                                               navals = i;
+                                               navals = a->a_numvals;
                                        }
                                }
                                for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
@@ -4682,6 +4839,7 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
 out:
        /* Undo for a failed operation */
        if ( rc != LDAP_SUCCESS ) {
+               ConfigReply msg = ca->reply;
                for ( s = save_attrs; s; s = s->a_next ) {
                        if ( s->a_flags & SLAP_ATTR_IXDEL ) {
                                s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
@@ -4718,6 +4876,7 @@ out:
                                }
                        }
                }
+               ca->reply = msg;
        }
 
        if ( ca->cleanup )
@@ -4784,8 +4943,7 @@ config_back_modify( Operation *op, SlapReply *rs )
 
        slap_mods_opattrs( op, &op->orm_modlist, 1 );
 
-       if ( !slapd_shutdown )
-               ldap_pvt_thread_pool_pause( &connection_pool );
+       ldap_pvt_thread_pool_pause( &connection_pool );
 
        /* Strategy:
         * 1) perform the Modify on the cached Entry.
@@ -4817,8 +4975,7 @@ config_back_modify( Operation *op, SlapReply *rs )
                op->o_ndn = ndn;
        }
 
-       if ( !slapd_shutdown )
-               ldap_pvt_thread_pool_resume( &connection_pool );
+       ldap_pvt_thread_pool_resume( &connection_pool );
 out:
        send_ldap_result( op, rs );
        slap_graduate_commit_csn( op );
@@ -5343,6 +5500,7 @@ config_check_schema(Operation *op, CfBackInfo *cfb)
                                ber_bvarray_free( a->a_vals );
                                a->a_vals = NULL;
                                a->a_nvals = NULL;
+                               a->a_numvals = 0;
                        }
                        oidm_unparse( &bv, NULL, NULL, 1 );
                        attr_merge_normalize( e, cfAd_om, bv, NULL );
@@ -5357,6 +5515,7 @@ config_check_schema(Operation *op, CfBackInfo *cfb)
                                ber_bvarray_free( a->a_vals );
                                a->a_vals = NULL;
                                a->a_nvals = NULL;
+                               a->a_numvals = 0;
                        }
                        at_unparse( &bv, NULL, NULL, 1 );
                        attr_merge_normalize( e, cfAd_attr, bv, NULL );
@@ -5371,6 +5530,7 @@ config_check_schema(Operation *op, CfBackInfo *cfb)
                                ber_bvarray_free( a->a_vals );
                                a->a_vals = NULL;
                                a->a_nvals = NULL;
+                               a->a_numvals = 0;
                        }
                        oc_unparse( &bv, NULL, NULL, 1 );
                        attr_merge_normalize( e, cfAd_oc, bv, NULL );