]> git.sur5r.net Git - openldap/commitdiff
first part of fix to ITS#4262
authorPierangelo Masarati <ando@openldap.org>
Thu, 15 Dec 2005 23:46:23 +0000 (23:46 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 15 Dec 2005 23:46:23 +0000 (23:46 +0000)
servers/slapd/back-bdb/config.c
servers/slapd/config.c

index 75b24f7da2280159c94ede6adcfaaf16f6347edf..309346bf75717acfd78933b0e06582695f8ba977 100644 (file)
@@ -464,26 +464,52 @@ bdb_cf_gen(ConfigArgs *c)
                case BDB_NOSYNC:
                        bdb->bi_dbenv->set_flags( bdb->bi_dbenv, DB_TXN_NOSYNC, 0 );
                        break;
-               case BDB_INDEX: {
-                       AttributeDescription *ad = NULL;
-                       struct berval bv, def = BER_BVC("default");
-                       char *ptr;
-                       const char *text;
-                       for (ptr = c->line; !isspace( *ptr ); ptr++);
-                       bv.bv_val = c->line;
-                       bv.bv_len = ptr - bv.bv_val;
-                       if ( bvmatch( &bv, &def )) {
-                               bdb->bi_defaultmask = 0;
+               case BDB_INDEX:
+                       if ( c->valx == -1 ) {
+                               /* delete all (FIXME) */
+
                        } else {
-                               slap_bv2ad( &bv, &ad, &text );
-                               if ( ad ) {
-                                       AttrInfo *ai = bdb_attr_mask( bdb, ad );
-                                       ai->ai_indexmask |= BDB_INDEX_DELETING;
-                                       bdb->bi_flags |= BDB_DEL_INDEX;
-                                       c->cleanup = bdb_cf_cleanup;
+                               struct berval bv, def = BER_BVC("default");
+                               char *ptr;
+
+                               for (ptr = c->line; !isspace( *ptr ); ptr++);
+
+                               bv.bv_val = c->line;
+                               bv.bv_len = ptr - bv.bv_val;
+                               if ( bvmatch( &bv, &def )) {
+                                       bdb->bi_defaultmask = 0;
+
+                               } else {
+                                       int i;
+                                       char **attrs;
+                                       char sep;
+
+                                       sep = bv.bv_val[ bv.bv_len ];
+                                       bv.bv_val[ bv.bv_len ] = '\0';
+                                       attrs = ldap_str2charray( bv.bv_val, "," );
+
+                                       for ( i = 0; attrs[ i ]; i++ ) {
+                                               AttributeDescription *ad = NULL;
+                                               const char *text;
+                                               AttrInfo *ai;
+
+                                               slap_str2ad( attrs[ i ], &ad, &text );
+                                               /* if we got here... */
+                                               assert( ad != NULL );
+
+                                               ai = bdb_attr_mask( bdb, ad );
+                                               /* if we got here... */
+                                               assert( ai != NULL );
+
+                                               ai->ai_indexmask |= BDB_INDEX_DELETING;
+                                               bdb->bi_flags |= BDB_DEL_INDEX;
+                                               c->cleanup = bdb_cf_cleanup;
+                                       }
+
+                                       bv.bv_val[ bv.bv_len ] = sep;
+                                       ldap_charray_free( attrs );
                                }
                        }
-                       }
                        break;
                }
                return rc;
index 13cf3f619e18d51087c3fff187b29f54e34d3b9d..2f8cd60f4c7b86240245f0e59b8ad26c7ba49bf4 100644 (file)
@@ -628,6 +628,7 @@ config_parse_vals(ConfigTable *ct, ConfigArgs *c, int valx)
        }
        rc = config_check_vals( ct, c, 1 );
        ch_free( c->tline );
+       c->tline = NULL;
 
        if ( rc )
                rc = LDAP_CONSTRAINT_VIOLATION;