more about ITS#4086: fix back-meta as well

This commit is contained in:
Pierangelo Masarati 2005-10-14 00:43:23 +00:00
parent 918405d154
commit b48ace2dfe
2 changed files with 54 additions and 35 deletions

View File

@ -208,6 +208,7 @@ map_attr_value(
ldap_back_map( &dc->target->mt_rwmap.rwm_at, &ad->ad_cname, mapped_attr, remap ); ldap_back_map( &dc->target->mt_rwmap.rwm_at, &ad->ad_cname, mapped_attr, remap );
if ( BER_BVISNULL( mapped_attr ) || BER_BVISEMPTY( mapped_attr ) ) { if ( BER_BVISNULL( mapped_attr ) || BER_BVISEMPTY( mapped_attr ) ) {
#if 0
/* /*
* FIXME: are we sure we need to search oc_map if at_map fails? * FIXME: are we sure we need to search oc_map if at_map fails?
*/ */
@ -215,6 +216,12 @@ map_attr_value(
if ( BER_BVISNULL( mapped_attr ) || BER_BVISEMPTY( mapped_attr ) ) { if ( BER_BVISNULL( mapped_attr ) || BER_BVISEMPTY( mapped_attr ) ) {
*mapped_attr = ad->ad_cname; *mapped_attr = ad->ad_cname;
} }
#endif
if ( dc->target->mt_rwmap.rwm_at.drop_missing ) {
return -1;
}
*mapped_attr = ad->ad_cname;
} }
if ( value == NULL ) { if ( value == NULL ) {
@ -271,13 +278,28 @@ ldap_back_int_filter_map_rewrite(
{ {
int i; int i;
Filter *p; Filter *p;
struct berval atmp; struct berval atmp,
struct berval vtmp; vtmp,
*tmp;
static struct berval
/* better than nothing... */
ber_bvfalse = BER_BVC( "(!(objectClass=*))" ),
ber_bvtf_false = BER_BVC( "(|)" ),
/* better than nothing... */
ber_bvtrue = BER_BVC( "(objectClass=*)" ),
ber_bvtf_true = BER_BVC( "(&)" ),
#if 0
/* no longer needed; preserved for completeness */
ber_bvundefined = BER_BVC( "(?=undefined)" ),
#endif
ber_bverror = BER_BVC( "(?=error)" ),
ber_bvunknown = BER_BVC( "(?=unknown)" ),
ber_bvnone = BER_BVC( "(?=none)" );
ber_len_t len; ber_len_t len;
if ( f == NULL ) { if ( f == NULL ) {
ber_str2bv( "No filter!", STRLENOF( "No filter!" ), 1, fstr ); ber_dupbv( fstr, &ber_bvnone );
return -1; return LDAP_OTHER;
} }
switch ( f->f_choice ) { switch ( f->f_choice ) {
@ -285,7 +307,7 @@ ldap_back_int_filter_map_rewrite(
if ( map_attr_value( dc, f->f_av_desc, &atmp, if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) ) &f->f_av_value, &vtmp, remap ) )
{ {
return -1; goto computed;
} }
fstr->bv_len = atmp.bv_len + vtmp.bv_len fstr->bv_len = atmp.bv_len + vtmp.bv_len
@ -302,7 +324,7 @@ ldap_back_int_filter_map_rewrite(
if ( map_attr_value( dc, f->f_av_desc, &atmp, if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) ) &f->f_av_value, &vtmp, remap ) )
{ {
return -1; goto computed;
} }
fstr->bv_len = atmp.bv_len + vtmp.bv_len fstr->bv_len = atmp.bv_len + vtmp.bv_len
@ -319,7 +341,7 @@ ldap_back_int_filter_map_rewrite(
if ( map_attr_value( dc, f->f_av_desc, &atmp, if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) ) &f->f_av_value, &vtmp, remap ) )
{ {
return -1; goto computed;
} }
fstr->bv_len = atmp.bv_len + vtmp.bv_len fstr->bv_len = atmp.bv_len + vtmp.bv_len
@ -336,7 +358,7 @@ ldap_back_int_filter_map_rewrite(
if ( map_attr_value( dc, f->f_av_desc, &atmp, if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) ) &f->f_av_value, &vtmp, remap ) )
{ {
return -1; goto computed;
} }
fstr->bv_len = atmp.bv_len + vtmp.bv_len fstr->bv_len = atmp.bv_len + vtmp.bv_len
@ -353,7 +375,7 @@ ldap_back_int_filter_map_rewrite(
if ( map_attr_value( dc, f->f_sub_desc, &atmp, if ( map_attr_value( dc, f->f_sub_desc, &atmp,
NULL, NULL, remap ) ) NULL, NULL, remap ) )
{ {
return -1; goto computed;
} }
/* cannot be a DN ... */ /* cannot be a DN ... */
@ -415,7 +437,7 @@ ldap_back_int_filter_map_rewrite(
if ( map_attr_value( dc, f->f_desc, &atmp, if ( map_attr_value( dc, f->f_desc, &atmp,
NULL, NULL, remap ) ) NULL, NULL, remap ) )
{ {
return -1; goto computed;
} }
fstr->bv_len = atmp.bv_len + ( STRLENOF( "(=*)" ) ); fstr->bv_len = atmp.bv_len + ( STRLENOF( "(=*)" ) );
@ -436,11 +458,13 @@ ldap_back_int_filter_map_rewrite(
f->f_choice == LDAP_FILTER_OR ? '|' : '!' ); f->f_choice == LDAP_FILTER_OR ? '|' : '!' );
for ( p = f->f_list; p != NULL; p = p->f_next ) { for ( p = f->f_list; p != NULL; p = p->f_next ) {
int rc;
len = fstr->bv_len; len = fstr->bv_len;
if ( ldap_back_int_filter_map_rewrite( dc, p, &vtmp, remap ) ) rc = ldap_back_int_filter_map_rewrite( dc, p, &vtmp, remap );
{ if ( rc != LDAP_SUCCESS ) {
return -1; return rc;
} }
fstr->bv_len += vtmp.bv_len; fstr->bv_len += vtmp.bv_len;
@ -459,7 +483,7 @@ ldap_back_int_filter_map_rewrite(
if ( map_attr_value( dc, f->f_mr_desc, &atmp, if ( map_attr_value( dc, f->f_mr_desc, &atmp,
&f->f_mr_value, &vtmp, remap ) ) &f->f_mr_value, &vtmp, remap ) )
{ {
return -1; goto computed;
} }
} else { } else {
@ -483,43 +507,38 @@ ldap_back_int_filter_map_rewrite(
ber_memfree( vtmp.bv_val ); ber_memfree( vtmp.bv_val );
break; break;
case SLAPD_FILTER_COMPUTED: { case SLAPD_FILTER_COMPUTED:
struct berval bv;
switch ( f->f_result ) { switch ( f->f_result ) {
case LDAP_COMPARE_FALSE: case LDAP_COMPARE_FALSE:
if ( dc->target->mt_flags & LDAP_BACK_F_SUPPORT_T_F ) {
BER_BVSTR( &bv, "(|)" );
break;
}
/* fallthru */
/* FIXME: treat UNDEFINED as FALSE */ /* FIXME: treat UNDEFINED as FALSE */
case SLAPD_COMPARE_UNDEFINED: case SLAPD_COMPARE_UNDEFINED:
/* better than nothing... */ computed:;
BER_BVSTR( &bv, "(!(objectClass=*))" ); if ( dc->target->mt_flags & LDAP_BACK_F_SUPPORT_T_F ) {
tmp = &ber_bvtf_false;
break;
}
tmp = &ber_bvfalse;
break; break;
case LDAP_COMPARE_TRUE: case LDAP_COMPARE_TRUE:
if ( dc->target->mt_flags & LDAP_BACK_F_SUPPORT_T_F ) { if ( dc->target->mt_flags & LDAP_BACK_F_SUPPORT_T_F ) {
BER_BVSTR( &bv, "(&)" ); tmp = &ber_bvtf_true;
break; break;
} }
/* better than nothing... */ tmp = &ber_bvtrue;
BER_BVSTR( &bv, "(objectClass=*)" );
break; break;
default: default:
BER_BVSTR( &bv, "(?=error)" ); tmp = &ber_bverror;
break; break;
} }
ber_dupbv( fstr, &bv ); ber_dupbv( fstr, tmp );
} break; break;
default: default:
ber_str2bv( "(?=unknown)", STRLENOF( "(?=unknown)" ), 1, fstr ); ber_dupbv( fstr, &ber_bvunknown );
break; break;
} }

View File

@ -685,6 +685,7 @@ computed:;
case SLAPD_FILTER_COMPUTED: case SLAPD_FILTER_COMPUTED:
switch ( f->f_result ) { switch ( f->f_result ) {
case LDAP_COMPARE_FALSE: case LDAP_COMPARE_FALSE:
/* FIXME: treat UNDEFINED as FALSE */
case SLAPD_COMPARE_UNDEFINED: case SLAPD_COMPARE_UNDEFINED:
if ( dc->rwmap->rwm_flags & RWM_F_SUPPORT_T_F ) { if ( dc->rwmap->rwm_flags & RWM_F_SUPPORT_T_F ) {
tmp = &ber_bvtf_false; tmp = &ber_bvtf_false;
@ -696,10 +697,9 @@ computed:;
case LDAP_COMPARE_TRUE: case LDAP_COMPARE_TRUE:
if ( dc->rwmap->rwm_flags & RWM_F_SUPPORT_T_F ) { if ( dc->rwmap->rwm_flags & RWM_F_SUPPORT_T_F ) {
tmp = &ber_bvtf_true; tmp = &ber_bvtf_true;
break;
} else {
tmp = &ber_bvtrue;
} }
tmp = &ber_bvtrue;
break; break;
default: default: