]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/rwmmap.c
trim listed modules
[openldap] / servers / slapd / overlays / rwmmap.c
index dce3a95f73087fdd218f13695ac00cf23b289758..c05032a36aa3cd18d30f1fd79c309c4c2834ec2e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2006 The OpenLDAP Foundation.
+ * Copyright 1999-2007 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -142,6 +142,13 @@ rwm_map( struct ldapmap *map, struct berval *s, struct berval *bv, int remap )
 {
        struct ldapmapping *mapping;
 
+       /* map->map may be NULL when mapping is configured,
+        * but map->remap can't */
+       if ( map->remap == NULL ) {
+               *bv = *s;
+               return;
+       }
+
        BER_BVZERO( bv );
        ( void )rwm_mapping( map, s, &mapping, remap );
        if ( mapping != NULL ) {
@@ -451,6 +458,7 @@ rwm_int_filter_map_rewrite(
 {
        int             i;
        Filter          *p;
+       AttributeDescription *ad;
        struct berval   atmp,
                        vtmp,
                        *tmp;
@@ -478,9 +486,10 @@ rwm_int_filter_map_rewrite(
                return LDAP_OTHER;
        }
 
-       switch ( f->f_choice ) {
+       switch ( f->f_choice & SLAPD_FILTER_MASK ) {
        case LDAP_FILTER_EQUALITY:
-               if ( map_attr_value( dc, &f->f_av_desc, &atmp,
+               ad = f->f_av_desc;
+               if ( map_attr_value( dc, &ad, &atmp,
                                        &f->f_av_value, &vtmp, RWM_MAP ) )
                {
                        goto computed;
@@ -496,7 +505,8 @@ rwm_int_filter_map_rewrite(
                break;
 
        case LDAP_FILTER_GE:
-               if ( map_attr_value( dc, &f->f_av_desc, &atmp,
+               ad = f->f_av_desc;
+               if ( map_attr_value( dc, &ad, &atmp,
                                        &f->f_av_value, &vtmp, RWM_MAP ) )
                {
                        goto computed;
@@ -512,7 +522,8 @@ rwm_int_filter_map_rewrite(
                break;
 
        case LDAP_FILTER_LE:
-               if ( map_attr_value( dc, &f->f_av_desc, &atmp,
+               ad = f->f_av_desc;
+               if ( map_attr_value( dc, &ad, &atmp,
                                        &f->f_av_value, &vtmp, RWM_MAP ) )
                {
                        goto computed;
@@ -528,7 +539,8 @@ rwm_int_filter_map_rewrite(
                break;
 
        case LDAP_FILTER_APPROX:
-               if ( map_attr_value( dc, &f->f_av_desc, &atmp,
+               ad = f->f_av_desc;
+               if ( map_attr_value( dc, &ad, &atmp,
                                        &f->f_av_value, &vtmp, RWM_MAP ) )
                {
                        goto computed;
@@ -544,7 +556,8 @@ rwm_int_filter_map_rewrite(
                break;
 
        case LDAP_FILTER_SUBSTRINGS:
-               if ( map_attr_value( dc, &f->f_sub_desc, &atmp,
+               ad = f->f_sub_desc;
+               if ( map_attr_value( dc, &ad, &atmp,
                                        NULL, NULL, RWM_MAP ) )
                {
                        goto computed;
@@ -606,7 +619,8 @@ rwm_int_filter_map_rewrite(
                break;
 
        case LDAP_FILTER_PRESENT:
-               if ( map_attr_value( dc, &f->f_desc, &atmp,
+               ad = f->f_desc;
+               if ( map_attr_value( dc, &ad, &atmp,
                                        NULL, NULL, RWM_MAP ) )
                {
                        goto computed;
@@ -652,7 +666,8 @@ rwm_int_filter_map_rewrite(
 
        case LDAP_FILTER_EXT: {
                if ( f->f_mr_desc ) {
-                       if ( map_attr_value( dc, &f->f_mr_desc, &atmp,
+                       ad = f->f_mr_desc;
+                       if ( map_attr_value( dc, &ad, &atmp,
                                                &f->f_mr_value, &vtmp, RWM_MAP ) )
                        {
                                goto computed;
@@ -680,7 +695,7 @@ rwm_int_filter_map_rewrite(
                break;
        }
 
-       case 0:
+       case -1:
 computed:;
                filter_free_x( op, f );
                f->f_choice = SLAPD_FILTER_COMPUTED;