From b8b0bb000baa2af9a93c9e7763fda02f36bde32c Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 4 May 2005 23:57:33 +0000 Subject: [PATCH] honor T-F filters (ITS#3706) --- servers/slapd/overlays/rwm.c | 31 +++++++++++++++++++++++++++++++ servers/slapd/overlays/rwm.h | 7 ++++++- servers/slapd/overlays/rwmmap.c | 22 ++++++++++++++++++++-- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index b696e37942..c4f827ac4f 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -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; } diff --git a/servers/slapd/overlays/rwm.h b/servers/slapd/overlays/rwm.h index 59e440c587..d27e6ac2a8 100644 --- a/servers/slapd/overlays/rwm.h +++ b/servers/slapd/overlays/rwm.h @@ -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( diff --git a/servers/slapd/overlays/rwmmap.c b/servers/slapd/overlays/rwmmap.c index 62bb845685..bfa40a1de1 100644 --- a/servers/slapd/overlays/rwmmap.c +++ b/servers/slapd/overlays/rwmmap.c @@ -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: