]> git.sur5r.net Git - openldap/commitdiff
honor T-F filters (ITS#3706)
authorPierangelo Masarati <ando@openldap.org>
Wed, 4 May 2005 23:57:33 +0000 (23:57 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 4 May 2005 23:57:33 +0000 (23:57 +0000)
servers/slapd/overlays/rwm.c
servers/slapd/overlays/rwm.h
servers/slapd/overlays/rwmmap.c

index b696e379427ac3b434ef4325fc62cb6fca642405..c4f827ac4fb72b83f1b7fd71eb01c17bd81fb0fd 100644 (file)
@@ -1310,6 +1310,10 @@ rwm_db_config(
     char       **argv
 )
 {
+       slap_overinst           *on = (slap_overinst *) be->bd_info;
+       struct ldaprwmap        *rwmap = 
+                       (struct ldaprwmap *)on->on_bi.bi_private;
+
        int             rc = 0;
        char            *argv0 = NULL;
 
@@ -1327,6 +1331,33 @@ rwm_db_config(
        } else if ( strcasecmp( argv[0], "suffixmassage" ) == 0 ) {
                rc = rwm_suffixmassage_config( be, fname, lineno, argc, argv );
 
+       } else if ( strcasecmp( argv[0], "t-f-support" ) == 0 ) {
+               if ( argc != 2 ) {
+                       fprintf( stderr,
+               "%s: line %d: \"t-f-support {no|yes|discover}\" needs 1 argument.\n",
+                                       fname, lineno );
+                       return( 1 );
+               }
+
+               if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
+                       rwmap->rwm_flags &= ~(RWM_F_SUPPORT_T_F|RWM_F_SUPPORT_T_F_DISCOVER);
+
+               } else if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
+                       rwmap->rwm_flags |= RWM_F_SUPPORT_T_F;
+
+#if 0
+               /* TODO: not implemented yet */
+               } else if ( strcasecmp( argv[ 1 ], "discover" ) == 0 ) {
+                       rwmap->rwm_flags |= RWM_F_SUPPORT_T_F_DISCOVER;
+#endif
+
+               } else {
+                       fprintf( stderr,
+       "%s: line %d: unknown value \"%s\" for \"t-f-support {no|yes|discover}\".\n",
+                               fname, lineno, argv[ 1 ] );
+                       return 1;
+               }
+
        } else {
                rc = SLAP_CONF_UNKNOWN;
        }
index 59e440c58744beb2a70b0c8a07b0f22714d008d1..d27e6ac2a875fc84630fc91a6437afd0b11547e9 100644 (file)
@@ -80,6 +80,11 @@ struct ldaprwmap {
         */
        struct ldapmap rwm_oc;
        struct ldapmap rwm_at;
+
+#define        RWM_F_NONE                      0x0000U
+#define        RWM_F_SUPPORT_T_F               0x4000U
+#define        RWM_F_SUPPORT_T_F_DISCOVER      0x8000U
+       unsigned        rwm_flags;
 };
 
 /* Whatever context ldap_back_dn_massage needs... */
@@ -110,7 +115,7 @@ void rwm_map ( struct ldapmap *map, struct berval *s, struct berval *m,
        int remap );
 int rwm_mapping ( struct ldapmap *map, struct berval *s,
                struct ldapmapping **m, int remap );
-#define RWM_MAP        0
+#define RWM_MAP                0
 #define RWM_REMAP      1
 char *
 rwm_map_filter(
index 62bb845685367631c3a5c3fd739214bfd9455907..bfa40a1de139ac0224b044084bdeca59e9560bf1 100644 (file)
@@ -450,8 +450,18 @@ rwm_int_filter_map_rewrite(
                        vtmp,
                        tmp;
        static struct berval
+#if 0
                        ber_bvfalse = BER_BVC( "(?=false)" ),
+#endif
+                       /* better than nothing... */
+                       ber_bvfalse = BER_BVC( "(!(objectClass=*))" ),
+                       ber_bvtf_false = BER_BVC( "(|)" ),
+#if 0
                        ber_bvtrue = BER_BVC( "(?=true)" ),
+#endif
+                       /* better than nothing... */
+                       ber_bvtrue = BER_BVC( "(objectClass=*)" ),
+                       ber_bvtf_true = BER_BVC( "(&)" ),
                        ber_bvundefined = BER_BVC( "(?=undefined)" ),
                        ber_bverror = BER_BVC( "(?=error)" ),
                        ber_bvunknown = BER_BVC( "(?=unknown)" ),
@@ -666,11 +676,19 @@ rwm_int_filter_map_rewrite(
        case SLAPD_FILTER_COMPUTED:
                switch ( f->f_result ) {
                case LDAP_COMPARE_FALSE:
-                       tmp = ber_bvfalse;
+                       if ( dc->rwmap->rwm_flags & RWM_F_SUPPORT_T_F ) {
+                               tmp = ber_bvtf_false;
+                       } else {
+                               tmp = ber_bvfalse;
+                       }
                        break;
 
                case LDAP_COMPARE_TRUE:
-                       tmp = ber_bvtrue;
+                       if ( dc->rwmap->rwm_flags & RWM_F_SUPPORT_T_F ) {
+                               tmp = ber_bvtf_true;
+                       } else {
+                               tmp = ber_bvtrue;
+                       }
                        break;
                        
                case SLAPD_COMPARE_UNDEFINED: