X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Foverlays%2Fdynlist.c;h=4150659d24ee8370edafcb931efc71b70dea67ef;hb=5a6cd2403f70be749037464a1ffd4ca1b8e1b4ea;hp=45173af76b2dac76ccf604c28912ea35cfe4d063;hpb=2d4f198662019b57a05b7a3b67fa4e83af4bbe81;p=openldap diff --git a/servers/slapd/overlays/dynlist.c b/servers/slapd/overlays/dynlist.c index 45173af76b..4150659d24 100644 --- a/servers/slapd/overlays/dynlist.c +++ b/servers/slapd/overlays/dynlist.c @@ -92,10 +92,10 @@ dynlist_is_dynlist_next( Operation *op, SlapReply *rs, dynlist_info_t *old_dli ) } for ( ; dli; dli = dli->dli_next ) { - if ( value_find_ex( slap_schema.si_ad_objectClass, + if ( attr_valfind( a, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, - a->a_nvals, &dli->dli_oc->soc_cname, + &dli->dli_oc->soc_cname, NULL, op->o_tmpmemctx ) == 0 ) { return dli; @@ -189,6 +189,7 @@ dynlist_sc_update( Operation *op, SlapReply *rs ) mod.sm_type = dlc->dlc_dli->dli_member_ad->ad_cname; mod.sm_values = vals; mod.sm_nvalues = nvals; + mod.sm_numvals = 1; (void)modify_add_values( e, &mod, /* permissive */ 1, &text, textbuf, sizeof( textbuf ) ); @@ -248,8 +249,7 @@ dynlist_sc_update( Operation *op, SlapReply *rs ) } /* test access to attribute */ - for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) - /* just count */ ; + i = a->a_numvals; vals = op->o_tmpalloc( ( i + 1 ) * sizeof( struct berval ), op->o_tmpmemctx ); if ( a->a_nvals != a->a_vals ) { @@ -293,6 +293,7 @@ dynlist_sc_update( Operation *op, SlapReply *rs ) mod.sm_type = a->a_desc->ad_cname; mod.sm_values = vals; mod.sm_nvalues = nvals; + mod.sm_numvals = j; (void)modify_add_values( e, &mod, /* permissive */ 1, &text, textbuf, sizeof( textbuf ) ); @@ -334,6 +335,19 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli ) return SLAP_CB_CONTINUE; } +#ifndef SLAP_OPATTRS + opattrs = ( rs->sr_attrs == NULL ) ? 0 : an_find( rs->sr_attrs, &AllOper ); + userattrs = ( rs->sr_attrs == NULL ) ? 1 : an_find( rs->sr_attrs, &AllUser ); +#else /* SLAP_OPATTRS */ + opattrs = SLAP_OPATTRS( rs->sr_attr_flags ); + userattrs = SLAP_USERATTRS( rs->sr_attr_flags ); +#endif /* SLAP_OPATTRS */ + + /* Don't generate member list if it wasn't requested */ + if ( dli->dli_member_ad && !userattrs && !ad_inlist( dli->dli_member_ad, rs->sr_attrs ) ) { + return SLAP_CB_CONTINUE; + } + if ( !( rs->sr_flags & REP_ENTRY_MODIFIABLE ) ) { e = entry_dup( rs->sr_entry ); } else { @@ -360,14 +374,6 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli ) o.ors_tlimit = SLAP_NO_LIMIT; o.ors_slimit = SLAP_NO_LIMIT; -#ifndef SLAP_OPATTRS - opattrs = ( rs->sr_attrs == NULL ) ? 0 : an_find( rs->sr_attrs, &AllOper ); - userattrs = ( rs->sr_attrs == NULL ) ? 1 : an_find( rs->sr_attrs, &AllUser ); -#else /* SLAP_OPATTRS */ - opattrs = SLAP_OPATTRS( rs->sr_attr_flags ); - userattrs = SLAP_USERATTRS( rs->sr_attr_flags ); -#endif /* SLAP_OPATTRS */ - for ( url = a->a_nvals; !BER_BVISNULL( url ); url++ ) { LDAPURLDesc *lud = NULL; int i, j; @@ -543,7 +549,7 @@ dynlist_compare( Operation *op, SlapReply *rs ) slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; dynlist_info_t *dli = (dynlist_info_t *)on->on_bi.bi_private; Operation o = *op; - Entry *e; + Entry *e = NULL; for ( ; dli != NULL; dli = dli->dli_next ) { if ( op->oq_compare.rs_ava->aa_desc == dli->dli_member_ad ) { @@ -586,7 +592,7 @@ dynlist_compare( Operation *op, SlapReply *rs ) } } - if ( be_entry_get_rw( &o, &o.o_req_ndn, NULL, NULL, 0, &e ) != + if ( overlay_entry_get_ov( &o, &o.o_req_ndn, NULL, NULL, 0, &e, on ) != LDAP_SUCCESS || e == NULL ) { return SLAP_CB_CONTINUE; } @@ -626,15 +632,11 @@ dynlist_compare( Operation *op, SlapReply *rs ) o.o_bd = select_backend( &o.o_req_ndn, 1 ); if ( !o.o_bd || !o.o_bd->be_search ) { - return SLAP_CB_CONTINUE; + goto release; } - BER_BVSTR( &o.ors_filterstr, "(objectClass=*)" ); - o.ors_filter = str2filter_x( op, o.ors_filterstr.bv_val ); - if ( o.ors_filter == NULL ) { - /* FIXME: error? */ - return SLAP_CB_CONTINUE; - } + o.ors_filterstr = *slap_filterstr_objectClass_pres; + o.ors_filter = (Filter *) slap_filter_objectClass_pres; o.ors_scope = LDAP_SCOPE_BASE; o.ors_deref = LDAP_DEREF_NEVER; @@ -647,14 +649,13 @@ dynlist_compare( Operation *op, SlapReply *rs ) o.o_acl_priv = ACL_COMPARE; rc = o.o_bd->be_search( &o, &r ); - filter_free_x( &o, o.ors_filter ); if ( o.o_dn.bv_val != op->o_dn.bv_val ) { slap_op_groups_free( &o ); } if ( rc != 0 ) { - return rc; + goto release; } if ( dlc.dlc_e != NULL ) { @@ -663,7 +664,7 @@ dynlist_compare( Operation *op, SlapReply *rs ) if ( r.sr_err != LDAP_SUCCESS || r.sr_entry == NULL ) { /* error? */ - return SLAP_CB_CONTINUE; + goto release; } for ( a = attrs_find( r.sr_entry->e_attrs, op->orc_ava->aa_desc ); @@ -673,10 +674,10 @@ dynlist_compare( Operation *op, SlapReply *rs ) /* if we're here, we got a match... */ rs->sr_err = LDAP_COMPARE_FALSE; - if ( value_find_ex( op->orc_ava->aa_desc, + if ( attr_valfind( a, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, - a->a_nvals, &op->orc_ava->aa_value, op->o_tmpmemctx ) == 0 ) + &op->orc_ava->aa_value, NULL, op->o_tmpmemctx ) == 0 ) { rs->sr_err = LDAP_COMPARE_TRUE; break; @@ -688,6 +689,11 @@ dynlist_compare( Operation *op, SlapReply *rs ) } } +release:; + if ( e != NULL ) { + overlay_entry_release_ov( &o, e, 0, on ); + } + return SLAP_CB_CONTINUE; } @@ -1075,7 +1081,7 @@ dl_cfgen( ConfigArgs *c ) break; } - return 1; /* FIXME */ + return rc; } switch( c->type ) { @@ -1305,7 +1311,8 @@ dynlist_db_open( if ( oc == NULL ) { oc = oc_find( "groupOfURLs" ); if ( oc == NULL ) { - sprintf( cr->msg, "unable to fetch objectClass \"groupOfURLs\"" ); + snprintf( cr->msg, sizeof( cr->msg), + "unable to fetch objectClass \"groupOfURLs\"" ); Debug( LDAP_DEBUG_ANY, "dynlist_db_open: %s.\n", cr->msg, 0, 0 ); return 1; } @@ -1318,7 +1325,8 @@ dynlist_db_open( if ( ad == NULL ) { rc = slap_str2ad( "memberURL", &ad, &text ); if ( rc != LDAP_SUCCESS ) { - sprintf( cr->msg, "unable to fetch attributeDescription \"memberURL\": %d (%s)", + snprintf( cr->msg, sizeof( cr->msg), + "unable to fetch attributeDescription \"memberURL\": %d (%s)", rc, text ); Debug( LDAP_DEBUG_ANY, "dynlist_db_open: %s.\n", cr->msg, 0, 0 ); return 1; @@ -1338,7 +1346,8 @@ dynlist_db_open( rc = slap_str2ad( "dgIdentity", &ad_dgIdentity, &text ); if ( rc != LDAP_SUCCESS ) { - sprintf( cr->msg, "unable to fetch attributeDescription \"dgIdentity\": %d (%s)", + snprintf( cr->msg, sizeof( cr->msg), + "unable to fetch attributeDescription \"dgIdentity\": %d (%s)", rc, text ); Debug( LDAP_DEBUG_ANY, "dynlist_db_open: %s\n", cr->msg, 0, 0 ); /* Just a warning */