From: Kurt Zeilenga Date: Wed, 26 Dec 2001 19:50:40 +0000 (+0000) Subject: Move search, modify, and modrdn APIs to struct berval DNs. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~486 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bd0135ccb43b3a9f5e104d718514de353b0b3fa5;p=openldap Move search, modify, and modrdn APIs to struct berval DNs. Much clean up is needed. --- diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index e4695f968d..d475840d56 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -156,8 +156,8 @@ bdb_modify( BackendDB *be, Connection *conn, Operation *op, - const char *dn, - const char *ndn, + struct berval *dn, + struct berval *ndn, Modifications *modlist ) { struct bdb_info *bdb = (struct bdb_info *) be->be_private; @@ -208,7 +208,7 @@ retry: /* transaction retry */ op->o_private = &opinfo; /* get entry */ - rc = bdb_dn2entry( be, ltid, ndn, &e, &matched, 0 ); + rc = bdb_dn2entry( be, ltid, ndn->bv_val, &e, &matched, 0 ); if ( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, @@ -236,14 +236,14 @@ retry: /* transaction retry */ matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) ? get_entry_referrals( be, conn, op, matched, - dn, LDAP_SCOPE_DEFAULT ) + dn->bv_val, LDAP_SCOPE_DEFAULT ) : NULL; bdb_entry_return( be, matched ); matched = NULL; } else { refs = referral_rewrite( default_referral, - NULL, dn, LDAP_SCOPE_DEFAULT ); + NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, rc = LDAP_REFERRAL, @@ -259,7 +259,7 @@ retry: /* transaction retry */ /* parent is a referral, don't allow add */ /* parent is an alias, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn, LDAP_SCOPE_DEFAULT ); + conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); Debug( LDAP_DEBUG_TRACE, "bdb_modify: entry is referral\n", diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index b92c60c7ed..a356ba437b 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -15,14 +15,16 @@ int bdb_modrdn( - Backend *be, - Connection *conn, - Operation *op, - const char *dn, - const char *ndn, - const char *newrdn, - int deleteoldrdn, - const char *newSuperior + Backend *be, + Connection *conn, + Operation *op, + struct berval *dn, + struct berval *ndn, + struct berval *newrdn, + struct berval *nnewrdn, + int deleteoldrdn, + struct berval *newSuperior, + struct berval *nnewSuperior ) { struct bdb_info *bdb = (struct bdb_info *) be->be_private; @@ -58,7 +60,8 @@ bdb_modrdn( int manageDSAit = get_manageDSAit( op ); Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn(%s,%s,%s)\n", - dn, newrdn, (newSuperior ? newSuperior : "NULL") ); + dn->bv_val, newrdn->bv_val, + newSuperior ? newSuperior->bv_val : "NULL" ); #if 0 if( newSuperior != NULL ) { @@ -102,7 +105,7 @@ retry: /* transaction retry */ op->o_private = &opinfo; /* get entry */ - rc = bdb_dn2entry( be, ltid, ndn, &e, &matched, 0 ); + rc = bdb_dn2entry( be, ltid, ndn->bv_val, &e, &matched, 0 ); switch( rc ) { case 0: @@ -125,14 +128,14 @@ retry: /* transaction retry */ matched_dn = strdup( matched->e_dn ); refs = is_entry_referral( matched ) ? get_entry_referrals( be, conn, op, matched, - dn, LDAP_SCOPE_DEFAULT ) + dn->bv_val, LDAP_SCOPE_DEFAULT ) : NULL; bdb_entry_return( be, matched ); matched = NULL; } else { refs = referral_rewrite( default_referral, - NULL, dn, LDAP_SCOPE_DEFAULT ); + NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, rc = LDAP_REFERRAL, @@ -148,7 +151,7 @@ retry: /* transaction retry */ /* parent is a referral, don't allow add */ /* parent is an alias, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn, LDAP_SCOPE_DEFAULT ); + conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n", e->e_dn, 0, 0 ); @@ -261,10 +264,10 @@ retry: /* transaction retry */ if ( newSuperior != NULL ) { Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new parent \"%s\" requested...\n", - newSuperior, 0, 0 ); + newSuperior->bv_val, 0, 0 ); - if ( newSuperior[ 0 ] != '\0' ) { - np_dn = ch_strdup( newSuperior ); + if ( newSuperior->bv_len ) { + np_dn = ch_strdup( newSuperior->bv_val ); np_ndn = ch_strdup( np_dn ); (void) dn_normalize( np_ndn ); @@ -382,9 +385,9 @@ retry: /* transaction retry */ } /* Build target dn and make sure target entry doesn't exist already. */ - build_new_dn( &new_dn, e->e_dn, new_parent_dn, newrdn ); + build_new_dn( &new_dn, e->e_dn, new_parent_dn, newrdn->bv_val ); - new_ndn = ch_strdup(new_dn); + new_ndn = ch_strdup( new_dn ); (void) dn_normalize( new_ndn ); Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new ndn=%s\n", @@ -414,7 +417,7 @@ retry: /* transaction retry */ * need to add that to our new entry */ - if ( rdn_attrs( newrdn, &new_rdn_types, &new_rdn_vals ) ) { + if ( rdn_attrs( newrdn->bv_val, &new_rdn_types, &new_rdn_vals ) ) { Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: can't figure out type(s)/values(s) " "of newrdn\n", 0, 0, 0 ); @@ -425,10 +428,10 @@ retry: /* transaction retry */ Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new_rdn_val=\"%s\", new_rdn_type=\"%s\"\n", - new_rdn_vals[ 0 ], new_rdn_types[ 0 ], 0 ); + new_rdn_vals[0], new_rdn_types[0], 0 ); /* Retrieve the old rdn from the entry's dn */ - if ( ( old_rdn = dn_rdn( be, dn ) ) == NULL ) { + if ( ( old_rdn = dn_rdn( be, dn->bv_val ) ) == NULL ) { Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: can't figure out old_rdn from dn\n", 0, 0, 0 ); diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index de33175dad..d3a5bb0213 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -32,8 +32,8 @@ bdb_search( BackendDB *be, Connection *conn, Operation *op, - const char *base, - const char *nbase, + struct berval *base, + struct berval *nbase, int scope, int deref, int slimit, @@ -65,7 +65,7 @@ bdb_search( manageDSAit = get_manageDSAit( op ); - if ( *nbase == '\0' ) { + if ( nbase->bv_len == 0 ) { /* DIT root special case */ e = (Entry *) &slap_entry_root; rc = 0; @@ -73,12 +73,12 @@ bdb_search( #ifdef BDB_ALIASES /* get entry with reader lock */ if ( deref & LDAP_DEREF_FINDING ) { - e = deref_dn_r( be, nbase, &err, &matched, &text ); + e = deref_dn_r( be, nbase->bv_val, &err, &matched, &text ); } else #endif { - rc = bdb_dn2entry( be, NULL, nbase, &e, &matched, 0 ); + rc = bdb_dn2entry( be, NULL, nbase->bv_val, &e, &matched, 0 ); } switch(rc) { @@ -101,7 +101,7 @@ bdb_search( erefs = is_entry_referral( matched ) ? get_entry_referrals( be, conn, op, matched, - base, scope ) + base->bv_val, scope ) : NULL; bdb_entry_return( be, matched ); @@ -109,13 +109,13 @@ bdb_search( if( erefs ) { refs = referral_rewrite( erefs, matched_dn, - base, scope ); + base->bv_val, scope ); ber_bvecfree( erefs ); } } else { refs = referral_rewrite( default_referral, - NULL, base, scope ); + NULL, base->bv_val, scope ); } send_ldap_result( conn, op, rc=LDAP_REFERRAL , @@ -131,7 +131,7 @@ bdb_search( /* entry is a referral, don't allow add */ char *matched_dn = ch_strdup( e->e_dn ); struct berval **erefs = get_entry_referrals( be, - conn, op, e, base, scope ); + conn, op, e, base->bv_val, scope ); struct berval **refs = NULL; bdb_entry_return( be, e ); @@ -139,7 +139,7 @@ bdb_search( if( erefs ) { refs = referral_rewrite( erefs, matched_dn, - base, scope ); + base->bv_val, scope ); ber_bvecfree( erefs ); } diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 7f2bbc7675..5cda33e37c 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -245,8 +245,8 @@ ldbm_back_modify( Backend *be, Connection *conn, Operation *op, - const char *dn, - const char *ndn, + struct berval *dn, + struct berval *ndn, Modifications *modlist ) { @@ -268,7 +268,7 @@ ldbm_back_modify( /* acquire and lock entry */ - if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) { + if ( (e = dn2entry_w( be, ndn->bv_val, &matched )) == NULL ) { char* matched_dn = NULL; struct berval **refs; @@ -276,12 +276,12 @@ ldbm_back_modify( matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) ? get_entry_referrals( be, conn, op, matched, - dn, LDAP_SCOPE_DEFAULT ) + dn->bv_val, LDAP_SCOPE_DEFAULT ) : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { refs = referral_rewrite( default_referral, - NULL, dn, LDAP_SCOPE_DEFAULT ); + NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, LDAP_REFERRAL, @@ -297,11 +297,11 @@ ldbm_back_modify( /* parent is a referral, don't allow add */ /* parent is an alias, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn, LDAP_SCOPE_DEFAULT ); + conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modify: entry (%s) is referral\n", ndn )); + "ldbm_back_modify: entry (%s) is referral\n", ndn->bv_val )); #else Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, 0, 0 ); @@ -317,7 +317,7 @@ ldbm_back_modify( } /* Modify the entry */ - rc = ldbm_modify_internal( be, conn, op, ndn, modlist, e, + rc = ldbm_modify_internal( be, conn, op, ndn->bv_val, modlist, e, &text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 151a032b4e..d7ab87d506 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -37,11 +37,13 @@ ldbm_back_modrdn( Backend *be, Connection *conn, Operation *op, - const char *dn, - const char *ndn, - const char *newrdn, + struct berval *dn, + struct berval *ndn, + struct berval *newrdn, + struct berval *nnewrdn, int deleteoldrdn, - const char *newSuperior + struct berval *newSuperior, + struct berval *nnewSuperior ) { AttributeDescription *children = slap_schema.si_ad_children; @@ -79,15 +81,17 @@ ldbm_back_modrdn( #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, "ldbm_back_modrdn: dn: %s newSuperior=%s\n", - dn ? dn : "NULL", newSuperior ? newSuperior : "NULL" )); + dn->bv_len ? dn->bv_val : "NULL", + newSuperior->bv_len ? newSuperior->bv_val : "NULL" )); #else - Debug( LDAP_DEBUG_TRACE, "==>ldbm_back_modrdn(newSuperior=%s)\n", - (newSuperior ? newSuperior : "NULL"), - 0, 0 ); + Debug( LDAP_DEBUG_TRACE, + "==>ldbm_back_modrdn: dn: %s newSuperior=%s\n", + dn->bv_len ? dn->bv_val : "NULL", + newSuperior->bv_len ? newSuperior->bv_val : "NULL", 0 ); #endif /* get entry with writer lock */ - if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) { + if ( (e = dn2entry_w( be, ndn->bv_val, &matched )) == NULL ) { char* matched_dn = NULL; struct berval** refs; @@ -95,12 +99,12 @@ ldbm_back_modrdn( matched_dn = strdup( matched->e_dn ); refs = is_entry_referral( matched ) ? get_entry_referrals( be, conn, op, matched, - dn, LDAP_SCOPE_DEFAULT ) + dn->bv_val, LDAP_SCOPE_DEFAULT ) : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { refs = referral_rewrite( default_referral, - NULL, dn, LDAP_SCOPE_DEFAULT ); + NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, LDAP_REFERRAL, @@ -116,7 +120,7 @@ ldbm_back_modrdn( /* parent is a referral, don't allow add */ /* parent is an alias, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn, LDAP_SCOPE_DEFAULT ); + conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, @@ -276,7 +280,7 @@ ldbm_back_modrdn( newSuperior, 0, 0 ); #endif - np_dn = ch_strdup( newSuperior ); + np_dn = ch_strdup( newSuperior->bv_val ); np_ndn = ch_strdup( np_dn ); (void) dn_normalize( np_ndn ); @@ -300,8 +304,7 @@ ldbm_back_modrdn( /* newSuperior == entry being moved?, if so ==> ERROR */ /* Get Entry with dn=newSuperior. Does newSuperior exist? */ - if ( newSuperior[ 0 ] != '\0' ) { - + if ( nnewSuperior->bv_len ) { if( (np = dn2entry_w( be, np_ndn, NULL )) == NULL) { #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ERR, @@ -444,9 +447,9 @@ ldbm_back_modrdn( } /* Build target dn and make sure target entry doesn't exist already. */ - build_new_dn( &new_dn, e->e_dn, new_parent_dn, newrdn ); + build_new_dn( &new_dn, e->e_dn, new_parent_dn, newrdn->bv_val ); - new_ndn = ch_strdup(new_dn); + new_ndn = ch_strdup( new_dn ); (void) dn_normalize( new_ndn ); #ifdef NEW_LOGGING @@ -475,25 +478,25 @@ ldbm_back_modrdn( #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: new ndn (%s) does not exist\n", new_ndn )); + "ldbm_back_modrdn: new ndn (%s) does not exist\n", new_ndn )); #else Debug( LDAP_DEBUG_TRACE, - "ldbm_back_modrdn: new ndn=%s does not exist\n", - new_ndn, 0, 0 ); + "ldbm_back_modrdn: new ndn=%s does not exist\n", + new_ndn, 0, 0 ); #endif /* Get attribute types and values of our new rdn, we will * need to add that to our new entry */ - if ( rdn_attrs( newrdn, &new_rdn_types, &new_rdn_vals ) ) { + if ( rdn_attrs( newrdn->bv_val, &new_rdn_types, &new_rdn_vals ) ) { #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, - "ldbm_back_modrdn: can't figure out type(s)/value(s) of newrdn\n" )); + "ldbm_back_modrdn: can't figure out type(s)/value(s) of newrdn\n" )); #else Debug( LDAP_DEBUG_TRACE, - "ldbm_back_modrdn: can't figure out type(s)/value(s) of newrdn\n", - 0, 0, 0 ); + "ldbm_back_modrdn: can't figure out type(s)/value(s) of newrdn\n", + 0, 0, 0 ); #endif send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, @@ -512,11 +515,11 @@ ldbm_back_modrdn( #endif /* Retrieve the old rdn from the entry's dn */ - if ( (old_rdn = dn_rdn( be, dn )) == NULL ) { + if ( (old_rdn = dn_rdn( be, dn->bv_val )) == NULL ) { #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, "ldbm_back_modrdn: can't figure out old_rdn from dn (%s)\n", - dn )); + dn->bv_val )); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: can't figure out old_rdn from dn\n", @@ -750,7 +753,7 @@ ldbm_back_modrdn( } /* modify memory copy of entry */ - rc = ldbm_modify_internal( be, conn, op, dn, &mod[0], e, + rc = ldbm_modify_internal( be, conn, op, dn->bv_val, &mod[0], e, &text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index bc5e67989c..753477a8e1 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -29,8 +29,8 @@ ldbm_back_search( Backend *be, Connection *conn, Operation *op, - const char *base, - const char *nbase, + struct berval *base, + struct berval *nbase, int scope, int deref, int slimit, @@ -59,13 +59,13 @@ ldbm_back_search( #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, - "ldbm_back_search: enter\n" )); + "ldbm_back_search: enter\n" )); #else Debug(LDAP_DEBUG_TRACE, "=> ldbm_back_search\n", 0, 0, 0); #endif - if ( *nbase == '\0' ) { + if ( nbase->bv_len == 0 ) { /* DIT root special case */ e = (Entry *) &slap_entry_root; @@ -79,13 +79,13 @@ ldbm_back_search( } else if ( deref & LDAP_DEREF_FINDING ) { /* deref dn and get entry with reader lock */ - e = deref_dn_r( be, nbase, &err, &matched, &text ); + e = deref_dn_r( be, nbase->bv_val, &err, &matched, &text ); if( err == LDAP_NO_SUCH_OBJECT ) err = LDAP_REFERRAL; } else { /* get entry with reader lock */ - e = dn2entry_r( be, nbase, &matched ); + e = dn2entry_r( be, nbase->bv_val, &matched ); err = e != NULL ? LDAP_SUCCESS : LDAP_REFERRAL; text = NULL; } @@ -100,21 +100,21 @@ ldbm_back_search( erefs = is_entry_referral( matched ) ? get_entry_referrals( be, conn, op, matched, - base, scope ) + base->bv_val, scope ) : NULL; cache_return_entry_r( &li->li_cache, matched ); if( erefs ) { refs = referral_rewrite( erefs, matched_dn, - base, scope ); + base->bv_val, scope ); ber_bvecfree( erefs ); } } else { refs = referral_rewrite( default_referral, - NULL, base, scope ); + NULL, base->bv_val, scope ); } send_ldap_result( conn, op, err, @@ -129,7 +129,7 @@ ldbm_back_search( /* entry is a referral, don't allow add */ char *matched_dn = ch_strdup( e->e_dn ); struct berval **erefs = get_entry_referrals( be, - conn, op, e, base, scope ); + conn, op, e, base->bv_val, scope ); struct berval **refs = NULL; cache_return_entry_r( &li->li_cache, e ); @@ -146,7 +146,7 @@ ldbm_back_search( if( erefs ) { refs = referral_rewrite( erefs, matched_dn, - base, scope ); + base->bv_val, scope ); ber_bvecfree( erefs ); } diff --git a/servers/slapd/back-monitor/modify.c b/servers/slapd/back-monitor/modify.c index 54ba7b3e85..faf38b73fd 100644 --- a/servers/slapd/back-monitor/modify.c +++ b/servers/slapd/back-monitor/modify.c @@ -50,8 +50,8 @@ monitor_back_modify( Backend *be, Connection *conn, Operation *op, - const char *dn, - const char *ndn, + struct berval *dn, + struct berval *ndn, Modifications *modlist ) { @@ -68,7 +68,7 @@ monitor_back_modify( #endif /* acquire and lock entry */ - monitor_cache_dn2entry( mi, ndn, &e, &matched ); + monitor_cache_dn2entry( mi, ndn->bv_val, &e, &matched ); if ( e == NULL ) { send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched ? matched->e_dn : NULL, diff --git a/servers/slapd/back-monitor/search.c b/servers/slapd/back-monitor/search.c index 5ccceb907c..57d7fa5d0a 100644 --- a/servers/slapd/back-monitor/search.c +++ b/servers/slapd/back-monitor/search.c @@ -139,18 +139,18 @@ monitor_send_children( int monitor_back_search( Backend *be, - Connection *conn, - Operation *op, - const char *base, - const char *nbase, - int scope, - int deref, - int slimit, - int tlimit, - Filter *filter, - const char *filterstr, - struct berval **attrs, - int attrsonly + Connection *conn, + Operation *op, + struct berval *base, + struct berval *nbase, + int scope, + int deref, + int slimit, + int tlimit, + Filter *filter, + const char *filterstr, + struct berval **attrs, + int attrsonly ) { struct monitorinfo *mi = (struct monitorinfo *) be->be_private; @@ -167,7 +167,7 @@ monitor_back_search( /* get entry with reader lock */ - monitor_cache_dn2entry( mi, nbase, &e, &matched ); + monitor_cache_dn2entry( mi, nbase->bv_val, &e, &matched ); if ( e == NULL ) { send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched ? matched->e_dn : NULL, diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index cd773ba816..e331ca85ec 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -252,8 +252,8 @@ glue_back_search ( BackendDB *b0, Connection *conn, Operation *op, - const char *dn, - const char *ndn, + struct berval *dn, + struct berval *ndn, int scope, int deref, int slimit, @@ -272,12 +272,13 @@ glue_back_search ( struct berval bv; - if (tlimit) + if (tlimit) { stoptime = slap_get_time () + tlimit; + } switch (scope) { case LDAP_SCOPE_BASE: - be = glue_back_select (b0, ndn); + be = glue_back_select (b0, ndn->bv_val); if (be && be->be_search) { rc = be->be_search (be, conn, op, dn, ndn, scope, @@ -295,8 +296,6 @@ glue_back_search ( op->o_glue = &gs; op->o_sresult = glue_back_sresult; op->o_response = glue_back_response; - bv.bv_len = strlen(ndn); - bv.bv_val = (char *) ndn; /* * Execute in reverse order, most general first @@ -326,26 +325,26 @@ glue_back_search ( } be = gi->n[i].be; if (scope == LDAP_SCOPE_ONELEVEL && - !strcmp (gi->n[i].pdn, ndn)) { + !strcmp (gi->n[i].pdn, ndn->bv_val)) { rc = be->be_search (be, conn, op, - be->be_suffix[0]->bv_val, - be->be_nsuffix[0]->bv_val, - LDAP_SCOPE_BASE, deref, + be->be_suffix[0], be->be_nsuffix[0], + LDAP_SCOPE_BASE, deref, s2limit, t2limit, filter, filterstr, - attrs, attrsonly); + attrs, attrsonly); + } else if (scope == LDAP_SCOPE_SUBTREE && - dnIsSuffix(be->be_nsuffix[0], &bv)) { + dnIsSuffix(be->be_nsuffix[0], ndn)) { rc = be->be_search (be, conn, op, - be->be_suffix[0]->bv_val, - be->be_nsuffix[0]->bv_val, - scope, deref, + be->be_suffix[0], be->be_nsuffix[0], + scope, deref, s2limit, t2limit, filter, filterstr, - attrs, attrsonly); + attrs, attrsonly); + } else if (dnIsSuffix(&bv, be->be_nsuffix[0])) { - rc = be->be_search (be, conn, op, - dn, ndn, scope, deref, + rc = be->be_search (be, conn, op, dn, ndn, + scope, deref, s2limit, t2limit, filter, filterstr, - attrs, attrsonly); + attrs, attrsonly); } } break; @@ -354,8 +353,9 @@ glue_back_search ( op->o_response = NULL; op->o_glue = NULL; - send_search_result (conn, op, gs.err, gs.matched, NULL, gs.refs, - NULL, gs.nentries); + send_search_result (conn, op, gs.err, gs.matched, NULL, + gs.refs, NULL, gs.nentries); + done: if (gs.matched) free (gs.matched); @@ -422,22 +422,22 @@ glue_back_modify ( BackendDB *b0, Connection *conn, Operation *op, - const char *dn, - const char *ndn, + struct berval *dn, + struct berval *ndn, Modifications *mod ) { BackendDB *be; int rc; - be = glue_back_select (b0, ndn); + be = glue_back_select (b0, ndn->bv_val); if (be && be->be_modify) { rc = be->be_modify (be, conn, op, dn, ndn, mod); } else { rc = LDAP_UNWILLING_TO_PERFORM; - send_ldap_result (conn, op, rc, NULL, "No modify target found", - NULL, NULL); + send_ldap_result (conn, op, rc, NULL, + "No modify target found", NULL, NULL); } return rc; } @@ -447,24 +447,27 @@ glue_back_modrdn ( BackendDB *b0, Connection *conn, Operation *op, - const char *dn, - const char *ndn, - const char *newrdn, + struct berval *dn, + struct berval *ndn, + struct berval *newrdn, + struct berval *nnewrdn, int del, - const char *newsup + struct berval *newsup, + struct berval *nnewsup ) { BackendDB *be; int rc; - be = glue_back_select (b0, ndn); + be = glue_back_select (b0, ndn->bv_val); if (be && be->be_modrdn) { - rc = be->be_modrdn (be, conn, op, dn, ndn, newrdn, del, newsup); + rc = be->be_modrdn (be, conn, op, dn, ndn, + newrdn, nnewrdn, del, newsup, nnewsup ); } else { rc = LDAP_UNWILLING_TO_PERFORM; - send_ldap_result (conn, op, rc, NULL, "No modrdn target found", - NULL, NULL); + send_ldap_result (conn, op, rc, NULL, + "No modrdn target found", NULL, NULL); } return rc; } diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index a1316fc983..1f283932e0 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -376,7 +376,7 @@ do_modify( } } - if ( (*be->be_modify)( be, conn, op, pdn->bv_val, ndn->bv_val, mods ) == 0 + if ( (*be->be_modify)( be, conn, op, pdn, ndn, mods ) == 0 #ifdef SLAPD_MULTIMASTER && !repl_user #endif diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index b28bae6c10..d07242eb40 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -384,9 +384,9 @@ do_modrdn( if ( !be->be_update_ndn.bv_len || repl_user ) #endif { - if ( (*be->be_modrdn)( be, conn, op, pdn->bv_val, ndn->bv_val, - pnewrdn->bv_val, deloldrdn, - pnewSuperior ? pnewSuperior->bv_val : NULL ) == 0 + if ( (*be->be_modrdn)( be, conn, op, pdn, ndn, + pnewrdn, nnewrdn, deloldrdn, + pnewSuperior, nnewSuperior ) == 0 #ifdef SLAPD_MULTIMASTER && ( !be->be_update_ndn.bv_len || !repl_user ) #endif diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 39f50d5c0b..c365d4131e 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -327,7 +327,7 @@ do_search( /* actually do the search and send the result(s) */ if ( be->be_search ) { - (*be->be_search)( be, conn, op, pbase->bv_val, nbase->bv_val, + (*be->be_search)( be, conn, op, pbase, nbase, scope, deref, sizelimit, timelimit, filter, fstr.bv_val, attrs, attrsonly ); } else { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 75695c76cf..fdddcc2870 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1020,15 +1020,17 @@ struct slap_op; /* Backend function typedefs */ typedef int (BI_init) LDAP_P((BackendInfo *bi)); -typedef int (BI_config) LDAP_P((BackendInfo *bi, const char *fname, - int lineno, int argc, char **argv)); +typedef int (BI_config) LDAP_P((BackendInfo *bi, + const char *fname, int lineno, + int argc, char **argv)); typedef int (BI_open) LDAP_P((BackendInfo *bi)); typedef int (BI_close) LDAP_P((BackendInfo *bi)); typedef int (BI_destroy) LDAP_P((BackendInfo *bi)); typedef int (BI_db_init) LDAP_P((Backend *bd)); -typedef int (BI_db_config) LDAP_P((Backend *bd, const char *fname, - int lineno, int argc, char **argv)); +typedef int (BI_db_config) LDAP_P((Backend *bd, + const char *fname, int lineno, + int argc, char **argv)); typedef int (BI_db_open) LDAP_P((Backend *bd)); typedef int (BI_db_close) LDAP_P((Backend *bd)); typedef int (BI_db_destroy) LDAP_P((Backend *bd)); @@ -1041,7 +1043,7 @@ typedef int (BI_op_unbind) LDAP_P((BackendDB *bd, struct slap_conn *c, struct slap_op *o )); typedef int (BI_op_search) LDAP_P((BackendDB *bd, struct slap_conn *c, struct slap_op *o, - const char *base, const char *nbase, + struct berval *base, struct berval *nbase, int scope, int deref, int slimit, int tlimit, Filter *f, const char *filterstr, @@ -1052,12 +1054,14 @@ typedef int (BI_op_compare)LDAP_P((BackendDB *bd, AttributeAssertion *ava)); typedef int (BI_op_modify) LDAP_P((BackendDB *bd, struct slap_conn *c, struct slap_op *o, - const char *dn, const char *ndn, Modifications *m)); + struct berval *dn, struct berval *ndn, + Modifications *m)); typedef int (BI_op_modrdn) LDAP_P((BackendDB *bd, struct slap_conn *c, struct slap_op *o, - const char *dn, const char *ndn, - const char *newrdn, int deleteoldrdn, - const char *newSuperior)); + struct berval *dn, struct berval *ndn, + struct berval *newrdn, struct berval *nnewrdn, + int deleteoldrdn, + struct berval *newSup, struct berval *nnewSup )); typedef int (BI_op_add) LDAP_P((BackendDB *bd, struct slap_conn *c, struct slap_op *o, Entry *e)); @@ -1241,13 +1245,14 @@ struct slap_backend_info { struct slap_op; struct slap_conn; -typedef void (slap_response)(struct slap_conn *, struct slap_op *, ber_tag_t, - ber_int_t, ber_int_t, const char *, const char *, struct berval **, - const char *, struct berval *, struct berval *, LDAPControl **); +typedef void (slap_response)( struct slap_conn *, struct slap_op *, + ber_tag_t, ber_int_t, ber_int_t, const char *, const char *, + struct berval **, const char *, struct berval *, + struct berval *, LDAPControl ** ); -typedef void (slap_sresult)(struct slap_conn *, struct slap_op *, ber_int_t, - const char *, const char *, struct berval **, LDAPControl **, - int nentries); +typedef void (slap_sresult)( struct slap_conn *, struct slap_op *, + ber_int_t, const char *, const char *, struct berval **, + LDAPControl **, int nentries); /* * represents an operation pending from an ldap client