]> git.sur5r.net Git - openldap/commitdiff
remap compare attribute; fix erroneous pointers; minor cleanup
authorPierangelo Masarati <ando@openldap.org>
Thu, 30 Dec 2004 17:46:38 +0000 (17:46 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 30 Dec 2004 17:46:38 +0000 (17:46 +0000)
servers/slapd/overlays/rwm.c
servers/slapd/overlays/rwmmap.c

index f6f5179eda6f071e2961f20f5503b0f5bfabc7ca..1c1da03a810ae0d57c6452f6c1adc9871dd8b2d4 100644 (file)
@@ -263,14 +263,22 @@ rwm_op_compare( Operation *op, SlapReply *rs )
                mapped_at = op->orc_ava->aa_desc->ad_cname;
 
        } else {
-               rwm_map( &rwmap->rwm_at, &op->orc_ava->aa_desc->ad_cname,
-                               &mapped_at, RWM_MAP );
-               if ( BER_BVISNULL( &mapped_at ) || BER_BVISEMPTY( &mapped_at ) )
-               {
-                       op->o_bd->bd_info = (BackendInfo *)on->on_info;
-                       send_ldap_error( op, rs, LDAP_OTHER, "compare attributeType map error" );
-                       return -1;
+               struct ldapmapping      *mapping = NULL;
+               AttributeDescription    *ad = op->orc_ava->aa_desc;
+
+               ( void )rwm_mapping( &rwmap->rwm_at, &op->orc_ava->aa_desc->ad_cname,
+                               &mapping, RWM_MAP );
+               if ( mapping == NULL ) {
+                       if ( rwmap->rwm_at.drop_missing ) {
+                               op->o_bd->bd_info = (BackendInfo *)on->on_info;
+                               send_ldap_error( op, rs, LDAP_OTHER, "compare attributeType map error" );
+                               return -1;
+                       }
+
+               } else {
+                       ad = mapping->m_dst_ad;
                }
+
                if ( op->orc_ava->aa_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName )
                {
                        struct berval   *mapped_valsp[2];
@@ -295,6 +303,7 @@ rwm_op_compare( Operation *op, SlapReply *rs )
 
                        op->orc_ava->aa_value = mapped_vals[0];
                }
+               op->orc_ava->aa_desc = ad;
        }
 
        return SLAP_CB_CONTINUE;
index 3a29f3ed2190fc0e4fea7c8f3dc3010cc2a6f619..033e84b51c0aebfc57f5d339ef37d5685b4b6e93 100644 (file)
@@ -136,7 +136,7 @@ rwm_map( struct ldapmap *map, struct berval *s, struct berval *bv, int remap )
        struct ldapmapping *mapping;
 
        BER_BVZERO( bv );
-       rwm_mapping( map, s, &mapping, remap );
+       ( void )rwm_mapping( map, s, &mapping, remap );
        if ( mapping != NULL ) {
                if ( !BER_BVISNULL( &mapping->m_dst ) ) {
                        *bv = mapping->m_dst;
@@ -702,7 +702,8 @@ rwm_filter_map_rewrite(
 
        switch ( rewrite_session( fdc.rwmap->rwm_rw, fdc.ctx, 
                                ( !BER_BVISEMPTY( &ftmp ) ? ftmp.bv_val : "" ), 
-                               fdc.conn, &fstr->bv_val )) {
+                               fdc.conn, &fstr->bv_val ) )
+       {
        case REWRITE_REGEXEC_OK:
                if ( !BER_BVISNULL( fstr ) ) {
                        fstr->bv_len = strlen( fstr->bv_val );
@@ -714,7 +715,7 @@ rwm_filter_map_rewrite(
 
                Debug( LDAP_DEBUG_ARGS,
                        "[rw] %s: \"%s\" -> \"%s\"\n",
-                       dc->ctx, ftmp.bv_val, fstr->bv_val );           
+                       fdc.ctx, ftmp.bv_val, fstr->bv_val );           
                rc = LDAP_SUCCESS;
                break;
                
@@ -1031,12 +1032,13 @@ rwm_referral_result_rewrite(
                         * legal to trim values when adding/modifying;
                         * it should be when searching (e.g. ACLs).
                         */
-                       ch_free( &a_vals[i].bv_val );
+                       ch_free( a_vals[i].bv_val );
                        if ( last > i ) {
                                a_vals[i] = a_vals[last];
                        }
                        BER_BVZERO( &a_vals[last] );
                        last--;
+                       i--;
                        break;
 
                default:
@@ -1089,7 +1091,7 @@ rwm_dnattr_result_rewrite(
                         * legal to trim values when adding/modifying;
                         * it should be when searching (e.g. ACLs).
                         */
-                       ch_free( &a_vals[i].bv_val );
+                       ch_free( a_vals[i].bv_val );
                        if ( last > i ) {
                                a_vals[i] = a_vals[last];
                        }