]> git.sur5r.net Git - openldap/commitdiff
Lots of fixes from HEAD
authorKurt Zeilenga <kurt@openldap.org>
Mon, 24 Mar 2003 04:54:12 +0000 (04:54 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 24 Mar 2003 04:54:12 +0000 (04:54 +0000)
14 files changed:
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/dbcache.c
servers/slapd/back-bdb/id2entry.c
servers/slapd/back-bdb/index.c
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/passwd.c
servers/slapd/back-bdb/proto-bdb.h
servers/slapd/back-bdb/search.c
servers/slapd/back-ldbm/passwd.c
servers/slapd/dn.c
servers/slapd/entry.c
servers/slapd/sasl.c
servers/slapd/schema_check.c
servers/slapd/slapd.conf

index f3df2ae08260b3dbd32ffc0f861d77072877f766..50f400688b750fb23f6e9c4d0f0fb490b077622c 100644 (file)
@@ -160,7 +160,7 @@ struct bdb_op_info {
        int             boi_acl_cache;
 };
 
-#define        DB_OPEN(db, file, name, type, flags, mode) \
+#define        DB_OPEN(db, txn, file, name, type, flags, mode) \
        (db)->open(db, file, name, type, flags, mode)
 
 #if DB_VERSION_MAJOR < 4
@@ -191,8 +191,8 @@ struct bdb_op_info {
 /* BDB 4.1.17 adds txn arg to db->open */
 #if DB_VERSION_MINOR > 1 || DB_VERSION_PATCH >= 17
 #undef DB_OPEN
-#define        DB_OPEN(db, file, name, type, flags, mode) \
-       (db)->open(db, NULL, file, name, type, (flags)|DB_AUTO_COMMIT, mode)
+#define        DB_OPEN(db, txn, file, name, type, flags, mode) \
+       (db)->open(db, txn, file, name, type, flags, mode)
 #endif
 
 #define BDB_REUSE_LOCKERS
index 7f5d6718d09a5509be18638cc28058b5f23d933d..5a07911d6d45a8369354008d7513c188464056bc 100644 (file)
@@ -46,11 +46,13 @@ bdb_db_hash(
 int
 bdb_db_cache(
        Backend *be,
+       DB_TXN *tid,
        const char *name,
        DB **dbout )
 {
        int i;
        int rc;
+       int flags;
        struct bdb_info *bdb = (struct bdb_info *) be->be_private;
        struct bdb_db_info *db;
        char *file;
@@ -110,9 +112,11 @@ bdb_db_cache(
 #ifdef HAVE_EBCDIC
        __atoe( file );
 #endif
-       rc = DB_OPEN( db->bdi_db,
+       flags = bdb->bi_db_opflags | DB_CREATE | DB_THREAD;
+       if ( !tid ) flags |= DB_AUTO_COMMIT;
+       rc = DB_OPEN( db->bdi_db, tid,
                file, name,
-               DB_HASH, bdb->bi_db_opflags | DB_CREATE | DB_THREAD,
+               DB_HASH, flags,
                bdb->bi_dbenv_mode );
 
        ch_free( file );
index 5e4ef60df488d9d6ac345c49336b95af563828fa..578e5ed435f703734c06798e51cdf8b8e6307735 100644 (file)
@@ -24,13 +24,14 @@ int bdb_id2entry_put(
        struct berval bv;
        int rc;
 #ifdef BDB_HIER
-       char *odn, *ondn;
+       struct berval odn, ondn;
 
        /* We only store rdns, and they go in the id2parent database. */
 
-       odn = e->e_dn; ondn = e->e_ndn;
+       odn = e->e_name; ondn = e->e_nname;
 
-       e->e_dn = ""; e->e_ndn = "";
+       e->e_name = slap_empty_bv;
+       e->e_nname = slap_empty_bv;
 #endif
        DBTzero( &key );
        key.data = (char *) &e->e_id;
@@ -38,7 +39,7 @@ int bdb_id2entry_put(
 
        rc = entry_encode( e, &bv );
 #ifdef BDB_HIER
-       e->e_dn = odn; e->e_ndn = ondn;
+       e->e_name = odn; e->e_nname = ondn;
 #endif
        if( rc != LDAP_SUCCESS ) {
                return -1;
index dd695783df4706b21da174eaaa3087e693f7bb5a..1ea5ad73f1233e93c6654ea9f68a6f5030d6b675 100644 (file)
@@ -103,7 +103,7 @@ int bdb_index_param(
                return LDAP_INAPPROPRIATE_MATCHING;
        }
 
-       rc = bdb_db_cache( be, dbname, &db );
+       rc = bdb_db_cache( be, NULL, dbname, &db );
 
        if( rc != LDAP_SUCCESS ) {
                return rc;
@@ -165,7 +165,7 @@ static int indexer(
 
        assert( mask );
 
-       rc = bdb_db_cache( be, dbname, &db );
+       rc = bdb_db_cache( be, txn, dbname, &db );
        
        if ( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
index 7d6dae13f02988c420ab3b3c08d0cb7192dd8132..039934c474f5f1e9ae015add97a882a53fb202ad 100644 (file)
@@ -380,18 +380,18 @@ bdb_db_open( BackendDB *be )
 #ifdef HAVE_EBCDIC
                strcpy( path, bdbi_databases[i].file );
                __atoe( path );
-               rc = DB_OPEN( db->bdi_db, 
+               rc = DB_OPEN( db->bdi_db, NULL,
                        path,
                /*      bdbi_databases[i].name, */ NULL,
                        bdbi_databases[i].type,
-                       bdbi_databases[i].flags | flags,
+                       bdbi_databases[i].flags | flags | DB_AUTO_COMMIT,
                        bdb->bi_dbenv_mode );
 #else
-               rc = DB_OPEN( db->bdi_db, 
+               rc = DB_OPEN( db->bdi_db, NULL,
                        bdbi_databases[i].file,
                /*      bdbi_databases[i].name, */ NULL,
                        bdbi_databases[i].type,
-                       bdbi_databases[i].flags | flags,
+                       bdbi_databases[i].flags | flags | DB_AUTO_COMMIT,
                        bdb->bi_dbenv_mode );
 #endif
 
index 33803ff633ce0684c92523c6e236fbc42953caf1..9848173cd66993bcbc2a8dcdc7c0a9376c7335c1 100644 (file)
@@ -38,8 +38,8 @@ bdb_exop_passwd(
        struct berval id = { 0, NULL };
        struct berval new = { 0, NULL };
 
-       struct berval dn;
-       struct berval ndn;
+       struct berval dn = { 0, NULL };
+       struct berval ndn = { 0, NULL };
 
        u_int32_t       locker = 0;
        DB_LOCK         lock;
@@ -276,6 +276,10 @@ done:
                free( hash.bv_val );
        }
 
+       if( ndn.bv_val != NULL ) {
+               free( ndn.bv_val );
+       }
+
        if( ltid != NULL ) {
                TXN_ABORT( ltid );
                op->o_private = NULL;
index 01103d1585597e3bff6ea8be5ddb4694ef420296..8cb1ed580892a01d3cc4b1da07e3e72628cda732 100644 (file)
@@ -51,6 +51,7 @@ BI_acl_attribute bdb_attribute;
 int
 bdb_db_cache(
     Backend    *be,
+    DB_TXN *tid,
     const char *name,
        DB **db );
 
index 9aea71c614649a27009cb2c45cfeb31e1e5fb604..69f37d5f96a0f2a414fb3def5033e3ee15b1118c 100644 (file)
@@ -343,13 +343,13 @@ dn2entry_retry:
                        scope, deref, candidates );
        }
 
-       /* need normalized dn below */
-       ber_dupbv( &realbase, &e->e_nname );
-
        /* start cursor at beginning of candidates.
         */
        cursor = 0;
 
+       /* need normalized dn below */
+       ber_dupbv( &realbase, &e->e_nname );
+
        if ( e != &slap_entry_root ) {
                bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
        }
index 3aed5c4df32f02077146fcee61529041bd478917..cd6a4a14a6778728b752ced5ccb6b4eb11cc98a2 100644 (file)
@@ -38,8 +38,8 @@ ldbm_back_exop_passwd(
        struct berval id = { 0, NULL };
        struct berval new = { 0, NULL };
 
-       struct berval dn;
-       struct berval ndn;
+       struct berval dn = { 0, NULL };
+       struct berval ndn = { 0, NULL };
 
        assert( reqoid != NULL );
        assert( strcmp( LDAP_EXOP_MODIFY_PASSWD, reqoid ) == 0 );
index 148d8155e9756adda8cd41f9053395a96af96769..af455b9dce88d5e89cfbc1495569bccc29f631ef 100644 (file)
@@ -266,6 +266,11 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
                        ava->la_attr = ad->ad_cname;
 
                        if( ava->la_flags & LDAP_AVA_BINARY ) {
+                               if( ava->la_value.bv_len == 0 ) {
+                                       /* BER encoding is empty */
+                                       return LDAP_INVALID_SYNTAX;
+                               }
+
                                /* AVA is binary encoded, don't muck with it */
                                validf = NULL;
                                transf = NULL;
index 8f3fa9ad0284d2c27de4e48b939460b96d4dbb8b..efff35b379d05110081a83b2bc284c699e322393 100644 (file)
@@ -524,7 +524,7 @@ int entry_encode(Entry *e, struct berval *bv)
                    entry_putlen(&ptr, i);
                    for (i=0; a->a_vals[i].bv_val; i++) {
                        entry_putlen(&ptr, a->a_vals[i].bv_len);
-                       memcpy(ptr, a->a_vals[i].bv_val,
+                       AC_MEMCPY(ptr, a->a_vals[i].bv_val,
                                a->a_vals[i].bv_len);
                        ptr += a->a_vals[i].bv_len;
                        *ptr++ = '\0';
@@ -537,7 +537,7 @@ int entry_encode(Entry *e, struct berval *bv)
 
 /* Retrieve an Entry that was stored using entry_encode above.
  * We malloc a single block with the size stored above for the Entry
- * and all if its Attributes. We also must lookup the stored
+ * and all of its Attributes. We also must lookup the stored
  * attribute names to get AttributeDescriptions. To detect if the
  * attributes of an Entry are later modified, we note that e->e_attr
  * is always a constant offset from (e).
index 257689a1ef507829058d56b3f8f3470375f51be4..df435683aec43d4a3eee2df44d7213af3d2b1be9 100644 (file)
@@ -349,13 +349,16 @@ sasl_ap_lookup(
                }
                a = attr_find( e->e_attrs, ad );
                if ( !a ) continue;
-               if ( ! access_allowed( be, conn, op, e, ad, NULL, ACL_AUTH, NULL ) )
+               if ( ! access_allowed( be, conn, op, e, ad, NULL, ACL_AUTH, NULL ) ) {
                        continue;
-               if ( sl->list[i].values && ( sl->flags & SASL_AUXPROP_OVERRIDE ) )
-                       sl->sparams->utils->prop_erase( sl->sparams->propctx, sl->list[i].name );
+               }
+               if ( sl->list[i].values && ( sl->flags & SASL_AUXPROP_OVERRIDE ) ) {
+                       sl->sparams->utils->prop_erase( sl->sparams->propctx,
+                       sl->list[i].name );
+               }
                for ( bv = a->a_vals; bv->bv_val; bv++ ) {
-                       sl->sparams->utils->prop_set( sl->sparams->propctx, sl->list[i].name,
-                               bv->bv_val, bv->bv_len );
+                       sl->sparams->utils->prop_set( sl->sparams->propctx,
+                               sl->list[i].name, bv->bv_val, bv->bv_len );
                }
        }
        return LDAP_SUCCESS;
index 6125db68117076cc346cbdaf406dfca06a70013a..a7b83d163768f84480512b22627232103bba2e3d 100644 (file)
@@ -845,15 +845,23 @@ entry_naming_check(
                        snprintf( textbuf, textlen, 
                                "naming attribute '%s' is not present in entry",
                                ava->la_attr.bv_val );
-                       rc = LDAP_NO_SUCH_ATTRIBUTE;
+                       rc = LDAP_NAMING_VIOLATION;
                        break;
                }
 
+               if( ava->la_flags & LDAP_AVA_BINARY ) {
+                       snprintf( textbuf, textlen, 
+                               "value of naming attribute '%s' in unsupported BER form",
+                               ava->la_attr.bv_val );
+                       rc = LDAP_NAMING_VIOLATION;
+               }
+
                if ( value_find( desc, attr->a_vals, &ava->la_value ) != 0 ) {
                        snprintf( textbuf, textlen, 
                                "value of naming attribute '%s' is not present in entry",
                                ava->la_attr.bv_val );
-                       rc = LDAP_NO_SUCH_ATTRIBUTE;
+                       rc = LDAP_NAMING_VIOLATION;
                        break;
                }
        }
index 679cbbf9366317e96f83bdd09e7396427af2c91d..5fcca2c1dbe617423ad8c033806b692e0fbbe4d2 100644 (file)
@@ -64,7 +64,8 @@ rootdn                "cn=Manager,dc=my-domain,dc=com"
 # Use of strong authentication encouraged.
 rootpw         secret
 # The database directory MUST exist prior to running slapd AND 
-# should only be accessible by the slapd/tools. Mode 700 recommended.
+# should only be accessible by the slapd and slap tools.
+# Mode 700 recommended.
 directory      %LOCALSTATEDIR%/openldap-data
 # Indices to maintain
 index  objectClass     eq