]> git.sur5r.net Git - openldap/commitdiff
use BerVarray for suffix_massaging stuff
authorPierangelo Masarati <ando@openldap.org>
Wed, 1 May 2002 17:45:03 +0000 (17:45 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 1 May 2002 17:45:03 +0000 (17:45 +0000)
servers/slapd/back-ldap/back-ldap.h
servers/slapd/back-ldap/config.c
servers/slapd/back-ldap/init.c
servers/slapd/back-ldap/search.c
servers/slapd/back-ldap/suffixmassage.c

index 81f8b0c871b7d7a3c8d11dd5dd036f60085598cc..3145ddd881ea556d9f375c72dcba0d8cb12477d1 100644 (file)
@@ -80,7 +80,7 @@ struct ldapinfo {
 #ifdef ENABLE_REWRITE
        struct rewrite_info *rwinfo;
 #else /* !ENABLE_REWRITE */
-       struct berval **suffix_massage;
+       BerVarray suffix_massage;
 #endif /* !ENABLE_REWRITE */
 
        struct ldapmap oc_map;
index 3343dc594a6ff42c8657df35c88b9d0ded3bd7de..6df5ff97e260f64f175dc47bf6761cac9321a6ea 100644 (file)
@@ -126,7 +126,9 @@ ldap_back_db_config(
                BackendDB *tmp_be;
                struct berval bvnc, *nvnc = NULL, *pvnc = NULL, 
                        brnc, *nrnc = NULL, *prnc = NULL;
+#ifdef ENABLE_REWRITE
                int rc;
+#endif /* ENABLE_REWRITE */
                
                /*
                 * syntax:
@@ -211,11 +213,11 @@ ldap_back_db_config(
                return( rc );
 
 #else /* !ENABLE_REWRITE */
-               ber_bvecadd( &li->suffix_massage, pvnc );
-               ber_bvecadd( &li->suffix_massage, nvnc );
+               ber_bvarray_add( &li->suffix_massage, pvnc );
+               ber_bvarray_add( &li->suffix_massage, nvnc );
                
-               ber_bvecadd( &li->suffix_massage, prnc );
-               ber_bvecadd( &li->suffix_massage, nrnc );
+               ber_bvarray_add( &li->suffix_massage, prnc );
+               ber_bvarray_add( &li->suffix_massage, nrnc );
 #endif /* !ENABLE_REWRITE */
 
        /* rewrite stuff ... */
index d744a976810e145eeab45c5ec683499f48f6462d..2b4a1c81f93f08626acf720d46e3228b2c09b530 100644 (file)
@@ -183,7 +183,7 @@ ldap_back_db_destroy(
                }
 #else /* !ENABLE_REWRITE */
                if (li->suffix_massage) {
-                       ber_bvecfree( li->suffix_massage );
+                       ber_bvarray_free( li->suffix_massage );
                }
 #endif /* !ENABLE_REWRITE */
 
index d85babb9cd512b844bbf9f3aa4dc1235d7747e63..a3de170009240055f404310d92558c3ccd9a9307 100644 (file)
@@ -479,18 +479,19 @@ ldap_send_entry(
                 * It is necessary to try to rewrite attributes with
                 * dn syntax because they might be used in ACLs as
                 * members of groups; since ACLs are applied to the
-                * rewritten stuff, no dn-based subecj clause could
+                * rewritten stuff, no dn-based subject clause could
                 * be used at the ldap backend side (see
                 * http://www.OpenLDAP.org/faq/data/cache/452.html)
                 * The problem can be overcome by moving the dn-based
                 * ACLs to the target directory server, and letting
                 * everything pass thru the ldap backend.
                 */
+               /* FIXME: #ifndef ENABLE_REWRITE should we massage these? */
                } else if ( strcmp( attr->a_desc->ad_type->sat_syntax->ssyn_oid,
                                        SLAPD_DN_SYNTAX ) == 0 ) {
                        int i;
                        for ( i = 0, bv = attr->a_vals; bv->bv_val; bv++, i++ ) {
-                               char *newval;
+                               char *newval = NULL;
                                
                                switch ( rewrite_session( li->rwinfo,
                                                        "searchResult",
@@ -516,9 +517,7 @@ ldap_send_entry(
                                                bv->bv_val, newval );
 #endif /* !NEW_LOGGING */
                                        free( bv->bv_val );
-                                       bv->bv_val = newval;
-                                       bv->bv_len = strlen( newval );
-                                       
+                                       ber_str2bv( newval, 0, 0, bv );
                                        break;
                                        
                                case REWRITE_REGEXEC_UNWILLING:
@@ -547,7 +546,7 @@ ldap_send_entry(
                ch_free(attr);
        }
        
-       if ( ent.e_dn && ent.e_dn != bdn.bv_val )
+       if ( ent.e_dn && ( ent.e_dn != bdn.bv_val ) )
                free( ent.e_dn );
        if ( ent.e_ndn )
                free( ent.e_ndn );
index 0847740f02fbcc1c09008ca63a45d733134f55c9..9f0311e6e75d50364eed6dadc7ee580415b37631 100644 (file)
@@ -74,9 +74,9 @@ ldap_back_dn_massage(
        }
 
         for ( i = 0;
-                li->suffix_massage[i] != NULL;
+                li->suffix_massage[i].bv_val != NULL;
                 i += 4 ) {
-                int aliasLength = li->suffix_massage[i+src]->bv_len;
+                int aliasLength = li->suffix_massage[i+src].bv_len;
                 int diff = dn->bv_len - aliasLength;
 
                 if ( diff < 0 ) {
@@ -91,11 +91,11 @@ ldap_back_dn_massage(
                         /* XXX or an escaped separator... oh well */
                 }
 
-                if ( !strcmp( li->suffix_massage[i+src]->bv_val, &dn->bv_val[diff] ) ) {
-                       res->bv_len = diff + li->suffix_massage[i+dst]->bv_len;
+                if ( !strcmp( li->suffix_massage[i+src].bv_val, &dn->bv_val[diff] ) ) {
+                       res->bv_len = diff + li->suffix_massage[i+dst].bv_len;
                         res->bv_val = ch_malloc( res->bv_len + 1 );
                         strncpy( res->bv_val, dn->bv_val, diff );
-                        strcpy( &res->bv_val[diff], li->suffix_massage[i+dst]->bv_val );
+                        strcpy( &res->bv_val[diff], li->suffix_massage[i+dst].bv_val );
 #ifdef NEW_LOGGING
                                        LDAP_LOG (( "suffixmassage", LDAP_LEVEL_ARGS,
                                                "ldap_back_dn_massage: converted \"%s\" to \"%s\"\n",