X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Foverlays%2Fdynlist.c;h=4150659d24ee8370edafcb931efc71b70dea67ef;hb=5a6cd2403f70be749037464a1ffd4ca1b8e1b4ea;hp=80c3835446f7543d8f180b998fcd9be3e2b1acd0;hpb=7841f4f53834cedca7fca83291da16849ec85277;p=openldap
diff --git a/servers/slapd/overlays/dynlist.c b/servers/slapd/overlays/dynlist.c
index 80c3835446..4150659d24 100644
--- a/servers/slapd/overlays/dynlist.c
+++ b/servers/slapd/overlays/dynlist.c
@@ -1,7 +1,8 @@
/* dynlist.c - dynamic list overlay */
+/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 2003-2005 The OpenLDAP Foundation.
+ * Copyright 2003-2007 The OpenLDAP Foundation.
* Portions Copyright 2004-2005 Pierangelo Masarati.
* All rights reserved.
*
@@ -22,9 +23,15 @@
#ifdef SLAPD_OVER_DYNLIST
-#if LDAP_VENDOR_VERSION_MINOR != X && LDAP_VENDOR_VERSION_MINOR < 3
+#if LDAP_VENDOR_VERSION_MINOR == X || LDAP_VENDOR_VERSION_MINOR > 3
+#if SLAPD_OVER_DYNGROUP != SLAPD_MOD_STATIC
+#define TAKEOVER_DYNGROUP
+#endif
+#else
+#if LDAP_VENDOR_VERSION_MINOR < 3
#define OL_2_2_COMPAT
#endif
+#endif
#include
@@ -51,6 +58,8 @@ static AttributeName anlist_no_attrs[] = {
static AttributeName *slap_anlist_no_attrs = anlist_no_attrs;
#endif
+static AttributeDescription *ad_dgIdentity;
+
typedef struct dynlist_info_t {
ObjectClass *dli_oc;
AttributeDescription *dli_ad;
@@ -60,13 +69,20 @@ typedef struct dynlist_info_t {
} dynlist_info_t;
static dynlist_info_t *
-dynlist_is_dynlist( Operation *op, SlapReply *rs )
+dynlist_is_dynlist_next( Operation *op, SlapReply *rs, dynlist_info_t *old_dli )
{
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
- dynlist_info_t *dli = (dynlist_info_t *)on->on_bi.bi_private;
+ dynlist_info_t *dli;
Attribute *a;
+ if ( old_dli == NULL ) {
+ dli = (dynlist_info_t *)on->on_bi.bi_private;
+
+ } else {
+ dli = old_dli->dli_next;
+ }
+
a = attrs_find( rs->sr_entry->e_attrs, slap_schema.si_ad_objectClass );
if ( a == NULL ) {
/* FIXME: objectClass must be present; for non-storage
@@ -76,10 +92,10 @@ dynlist_is_dynlist( Operation *op, SlapReply *rs )
}
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;
@@ -173,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 ) );
@@ -191,7 +208,8 @@ dynlist_sc_update( Operation *op, SlapReply *rs )
for ( a = rs->sr_entry->e_attrs; a != NULL; a = a->a_next ) {
BerVarray vals, nvals = NULL;
- int i, j;
+ int i, j,
+ is_oc = a->a_desc == slap_schema.si_ad_objectClass;
/* if attribute is not requested, skip it */
if ( rs->sr_attrs == NULL ) {
@@ -231,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 ) {
@@ -240,6 +257,14 @@ dynlist_sc_update( Operation *op, SlapReply *rs )
}
for ( i = 0, j = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) {
+ if ( is_oc ) {
+ ObjectClass *soc = oc_bvfind( &a->a_vals[i] );
+
+ if ( soc->soc_kind == LDAP_SCHEMA_STRUCTURAL ) {
+ continue;
+ }
+ }
+
if ( access_allowed( op, rs->sr_entry, a->a_desc,
&a->a_nvals[i], ACL_READ, &acl_state ) )
{
@@ -268,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 ) );
@@ -282,15 +308,17 @@ dynlist_sc_update( Operation *op, SlapReply *rs )
done:;
if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
entry_free( rs->sr_entry );
+ rs->sr_entry = NULL;
+ rs->sr_flags ^= REP_ENTRY_MUSTBEFREED;
}
return 0;
}
static int
-dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
+dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
{
- Attribute *a;
+ Attribute *a, *id = NULL;
slap_callback cb;
Operation o = *op;
SlapReply r = { REP_SEARCH };
@@ -307,9 +335,32 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
return SLAP_CB_CONTINUE;
}
- e = entry_dup( rs->sr_entry );
+#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 {
+ e = rs->sr_entry;
+ }
e_flags = rs->sr_flags | ( REP_ENTRY_MODIFIABLE | REP_ENTRY_MUSTBEFREED );
+ if ( ad_dgIdentity && ( id = attrs_find( e->e_attrs, ad_dgIdentity ))) {
+ o.o_dn = id->a_vals[0];
+ o.o_ndn = id->a_nvals[0];
+ o.o_groups = NULL;
+ }
+
dlc.dlc_e = e;
dlc.dlc_dli = dli;
cb.sc_private = &dlc;
@@ -323,14 +374,6 @@ dynlist_send_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;
@@ -348,9 +391,9 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
continue;
}
- if ( lud->lud_host ) {
+ if ( lud->lud_host != NULL ) {
/* FIXME: host not allowed; reject as illegal? */
- Debug( LDAP_DEBUG_ANY, "dynlist_send_entry(\"%s\"): "
+ Debug( LDAP_DEBUG_ANY, "dynlist_prepare_entry(\"%s\"): "
"illegal URI \"%s\"\n",
e->e_name.bv_val, url->bv_val, 0 );
goto cleanup;
@@ -363,6 +406,7 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
* this can be useful in case of a database serving
* the empty suffix */
BER_BVSTR( &dn, "" );
+
} else {
ber_str2bv( lud->lud_dn, 0, 0, &dn );
}
@@ -374,6 +418,8 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
o.ors_scope = lud->lud_scope;
if ( dli->dli_member_ad != NULL ) {
+ /* if ( lud->lud_attrs != NULL ),
+ * the URL should be ignored */
o.ors_attrs = slap_anlist_no_attrs;
} else if ( lud->lud_attrs == NULL ) {
@@ -431,6 +477,7 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
if ( lud->lud_filter == NULL ) {
ber_dupbv_x( &o.ors_filterstr,
&dli->dli_default_filter, op->o_tmpmemctx );
+
} else {
struct berval flt;
ber_str2bv( lud->lud_filter, 0, 0, &flt );
@@ -444,7 +491,7 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
goto cleanup;
}
- o.o_bd = select_backend( &o.o_req_ndn, 0, 1 );
+ o.o_bd = select_backend( &o.o_req_ndn, 1 );
if ( o.o_bd && o.o_bd->be_search ) {
#ifdef SLAP_OPATTRS
r.sr_attr_flags = slap_attr_flags( o.ors_attrs );
@@ -453,6 +500,9 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
}
cleanup:;
+ if ( id ) {
+ slap_op_groups_free( &o );
+ }
if ( o.ors_filter ) {
filter_free_x( &o, o.ors_filter );
}
@@ -467,13 +517,10 @@ cleanup:;
if ( !BER_BVISNULL( &o.o_req_ndn ) ) {
op->o_tmpfree( o.o_req_ndn.bv_val, op->o_tmpmemctx );
}
- if ( o.ors_filterstr.bv_val != lud->lud_filter ) {
- op->o_tmpfree( o.ors_filterstr.bv_val, op->o_tmpmemctx );
- lud->lud_filter = NULL;
- }
- if ( lud ) {
- ldap_free_urldesc( lud );
- }
+ assert( BER_BVISNULL( &o.ors_filterstr )
+ || o.ors_filterstr.bv_val != lud->lud_filter );
+ op->o_tmpfree( o.ors_filterstr.bv_val, op->o_tmpmemctx );
+ ldap_free_urldesc( lud );
}
rs->sr_entry = e;
@@ -501,6 +548,8 @@ 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 = NULL;
for ( ; dli != NULL; dli = dli->dli_next ) {
if ( op->oq_compare.rs_ava->aa_desc == dli->dli_member_ad ) {
@@ -508,12 +557,18 @@ dynlist_compare( Operation *op, SlapReply *rs )
* interested in. We'll use slapd's existing dyngroup
* evaluator to get the answer we want.
*/
- int cache = op->o_do_not_cache;
-
- op->o_do_not_cache = 1;
- rs->sr_err = backend_group( op, NULL, &op->o_req_ndn,
- &op->oq_compare.rs_ava->aa_value, dli->dli_oc, dli->dli_ad );
- op->o_do_not_cache = cache;
+ struct berval *id = NULL;
+
+ o.o_do_not_cache = 1;
+
+ if ( ad_dgIdentity && backend_attribute( &o, NULL, &o.o_req_ndn,
+ ad_dgIdentity, &id, ACL_READ ) == LDAP_SUCCESS ) {
+ o.o_dn = *id;
+ o.o_ndn = *id;
+ o.o_groups = NULL; /* authz changed, invalidate cached groups */
+ }
+ rs->sr_err = backend_group( &o, NULL, &o.o_req_ndn,
+ &o.oq_compare.rs_ava->aa_value, dli->dli_oc, dli->dli_ad );
switch ( rs->sr_err ) {
case LDAP_SUCCESS:
rs->sr_err = LDAP_COMPARE_TRUE;
@@ -528,47 +583,38 @@ dynlist_compare( Operation *op, SlapReply *rs )
* the assertion is FALSE rather than
* UNDEFINED */
rs->sr_err = LDAP_COMPARE_FALSE;
+ break;
}
+ if ( id ) ber_bvarray_free_x( id, o.o_tmpmemctx );
+
return SLAP_CB_CONTINUE;
}
}
+ if ( overlay_entry_get_ov( &o, &o.o_req_ndn, NULL, NULL, 0, &e, on ) !=
+ LDAP_SUCCESS || e == NULL ) {
+ return SLAP_CB_CONTINUE;
+ }
+ if ( ad_dgIdentity ) {
+ Attribute *id = attrs_find( e->e_attrs, ad_dgIdentity );
+ if ( id ) {
+ o.o_dn = id->a_vals[0];
+ o.o_ndn = id->a_nvals[0];
+ o.o_groups = NULL;
+ }
+ }
dli = (dynlist_info_t *)on->on_bi.bi_private;
for ( ; dli != NULL && rs->sr_err != LDAP_COMPARE_TRUE; dli = dli->dli_next ) {
Attribute *a;
slap_callback cb;
- Operation o = *op;
SlapReply r = { REP_SEARCH };
AttributeName an[2];
int rc;
dynlist_sc_t dlc = { 0 };
- Entry *e;
-
- int cache = op->o_do_not_cache;
- struct berval op_dn = op->o_dn,
- op_ndn = op->o_ndn;
- BackendDB *op_bd = op->o_bd;
-
- /* fetch the entry as rootdn (a hack to see if it exists
- * and if it has the right objectClass) */
- op->o_do_not_cache = 1;
- op->o_dn = op->o_bd->be_rootdn;
- op->o_ndn = op->o_bd->be_rootndn;
- op->o_bd = select_backend( &op->o_req_ndn, 0, 0 );
-
- r.sr_err = be_entry_get_rw( op, &op->o_req_ndn,
- dli->dli_oc, NULL, 0, &e );
- if ( e != NULL ) {
- be_entry_release_r( op, e );
- }
- op->o_do_not_cache = cache;
- op->o_dn = op_dn;
- op->o_ndn = op_ndn;
- op->o_bd = op_bd;
- if ( r.sr_err != LDAP_SUCCESS ) {
+
+ if ( !is_entry_objectclass_or_sub( e, dli->dli_oc ))
continue;
- }
/* if the entry has the right objectClass, generate
* the dynamic list and compare */
@@ -584,17 +630,13 @@ dynlist_compare( Operation *op, SlapReply *rs )
o.ors_tlimit = SLAP_NO_LIMIT;
o.ors_slimit = SLAP_NO_LIMIT;
- o.o_bd = select_backend( &o.o_req_ndn, 0, 1 );
+ 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;
@@ -604,11 +646,16 @@ dynlist_compare( Operation *op, SlapReply *rs )
o.ors_attrs = an;
o.ors_attrsonly = 0;
+ 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 ) {
@@ -617,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 );
@@ -627,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;
@@ -642,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;
}
@@ -654,9 +706,17 @@ dynlist_response( Operation *op, SlapReply *rs )
case LDAP_REQ_SEARCH:
if ( rs->sr_type == REP_SEARCH && !get_manageDSAit( op ) )
{
- dli = dynlist_is_dynlist( op, rs );
- if ( dli != NULL ) {
- return dynlist_send_entry( op, rs, dli );
+ int rc = LDAP_OTHER;
+
+ for ( dli = dynlist_is_dynlist_next( op, rs, NULL );
+ dli;
+ dli = dynlist_is_dynlist_next( op, rs, dli ) )
+ {
+ rc = dynlist_prepare_entry( op, rs, dli );
+ }
+
+ if ( rc != LDAP_OTHER ) {
+ return rc;
}
}
break;
@@ -691,7 +751,7 @@ dynlist_build_def_filter( dynlist_info_t *dli )
dli->dli_default_filter.bv_len = STRLENOF( "(!(objectClass=" "))" )
+ dli->dli_oc->soc_cname.bv_len;
- dli->dli_default_filter.bv_val = SLAP_MALLOC( dli->dli_default_filter.bv_len + 1 );
+ dli->dli_default_filter.bv_val = ch_malloc( dli->dli_default_filter.bv_len + 1 );
if ( dli->dli_default_filter.bv_val == NULL ) {
Debug( LDAP_DEBUG_ANY, "dynlist_db_open: malloc failed.\n",
0, 0, 0 );
@@ -775,7 +835,20 @@ dynlist_db_config(
for ( dlip = (dynlist_info_t **)&on->on_bi.bi_private;
*dlip; dlip = &(*dlip)->dli_next )
- /* go to last */;
+ {
+ /* The same URL attribute / member attribute pair
+ * cannot be repeated */
+ if ( (*dlip)->dli_ad == ad && (*dlip)->dli_member_ad == member_ad ) {
+ Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+ "\"dynlist-attrset []\": "
+ "URL attributeDescription \"%s\" already mapped.\n",
+ fname, lineno, ad->ad_cname.bv_val );
+#if 0
+ /* make it a warning... */
+ return 1;
+#endif
+ }
+ }
*dlip = (dynlist_info_t *)ch_calloc( 1, sizeof( dynlist_info_t ) );
(*dlip)->dli_oc = oc;
@@ -840,10 +913,22 @@ dynlist_db_config(
return 1;
}
-
for ( dlip = (dynlist_info_t **)&on->on_bi.bi_private;
*dlip; dlip = &(*dlip)->dli_next )
- /* go to last */;
+ {
+ /* The same URL attribute / member attribute pair
+ * cannot be repeated */
+ if ( (*dlip)->dli_ad == ad && (*dlip)->dli_member_ad == member_ad ) {
+ Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+ "\"dynlist-attrpair \": "
+ "URL attributeDescription \"%s\" already mapped.\n",
+ fname, lineno, ad->ad_cname.bv_val );
+#if 0
+ /* make it a warning... */
+ return 1;
+#endif
+ }
+ }
*dlip = (dynlist_info_t *)ch_calloc( 1, sizeof( dynlist_info_t ) );
(*dlip)->dli_oc = oc;
@@ -867,6 +952,7 @@ dynlist_db_config(
enum {
DL_ATTRSET = 1,
DL_ATTRPAIR,
+ DL_ATTRPAIR_COMPAT,
DL_LAST
};
@@ -884,6 +970,11 @@ static ConfigTable dlcfg[] = {
{ "dynlist-attrpair", "member-ad> dli_next ) {
struct berval bv;
- char *ptr = c->msg;
+ char *ptr = c->cr_msg;
assert( dli->dli_oc != NULL );
assert( dli->dli_ad != NULL );
- ptr += snprintf( c->msg, sizeof( c->msg ),
+ ptr += snprintf( c->cr_msg, sizeof( c->cr_msg ),
SLAP_X_ORDERED_FMT "%s %s", i,
dli->dli_oc->soc_cname.bv_val,
dli->dli_ad->ad_cname.bv_val );
@@ -926,12 +1017,13 @@ dl_cfgen( ConfigArgs *c )
ptr = lutil_strcopy( ptr, dli->dli_member_ad->ad_cname.bv_val );
}
- bv.bv_val = c->msg;
+ bv.bv_val = c->cr_msg;
bv.bv_len = ptr - bv.bv_val;
value_add_one( &c->rvalue_vals, &bv );
}
break;
+ case DL_ATTRPAIR_COMPAT:
case DL_ATTRPAIR:
rc = 1;
break;
@@ -979,6 +1071,7 @@ dl_cfgen( ConfigArgs *c )
}
break;
+ case DL_ATTRPAIR_COMPAT:
case DL_ATTRPAIR:
rc = 1;
break;
@@ -988,7 +1081,7 @@ dl_cfgen( ConfigArgs *c )
break;
}
- return 1; /* FIXME */
+ return rc;
}
switch( c->type ) {
@@ -1002,47 +1095,66 @@ dl_cfgen( ConfigArgs *c )
oc = oc_find( c->argv[ 1 ] );
if ( oc == NULL ) {
- snprintf( c->msg, sizeof( c->msg ),
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
"\"dynlist-attrset []\": "
"unable to find ObjectClass \"%s\"",
c->argv[ 1 ] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
- c->log, c->msg, 0 );
+ c->log, c->cr_msg, 0 );
return 1;
}
rc = slap_str2ad( c->argv[ 2 ], &ad, &text );
if ( rc != LDAP_SUCCESS ) {
- snprintf( c->msg, sizeof( c->msg ),
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
"\"dynlist-attrset []\": "
"unable to find AttributeDescription \"%s\"",
c->argv[ 2 ] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
- c->log, c->msg, 0 );
+ c->log, c->cr_msg, 0 );
return 1;
}
if ( !is_at_subtype( ad->ad_type, slap_schema.si_ad_labeledURI->ad_type ) ) {
- snprintf( c->msg, sizeof( c->msg ),
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
"\"dynlist-attrset []\": "
"AttributeDescription \"%s\" "
"must be a subtype of \"labeledURI\"",
c->argv[ 2 ] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
- c->log, c->msg, 0 );
+ c->log, c->cr_msg, 0 );
return 1;
}
if ( c->argc == 4 ) {
rc = slap_str2ad( c->argv[ 3 ], &member_ad, &text );
if ( rc != LDAP_SUCCESS ) {
- snprintf( c->msg, sizeof( c->msg ),
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
"\"dynlist-attrset []\": "
"unable to find AttributeDescription \"%s\"\n",
c->argv[ 3 ] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
- c->log, c->msg, 0 );
+ c->log, c->cr_msg, 0 );
+ return 1;
+ }
+ }
+
+ for ( dlip = (dynlist_info_t **)&on->on_bi.bi_private;
+ *dlip; dlip = &(*dlip)->dli_next )
+ {
+ /* The same URL attribute / member attribute pair
+ * cannot be repeated */
+ if ( (*dlip)->dli_ad == ad && (*dlip)->dli_member_ad == member_ad ) {
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
+ "\"dynlist-attrset []\": "
+ "URL attributeDescription \"%s\" already mapped.\n",
+ ad->ad_cname.bv_val );
+ Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
+ c->log, c->cr_msg, 0 );
+#if 0
+ /* make it a warning... */
return 1;
+#endif
}
}
@@ -1053,12 +1165,12 @@ dl_cfgen( ConfigArgs *c )
i < c->valx; i++ )
{
if ( *dlip == NULL ) {
- snprintf( c->msg, sizeof( c->msg ),
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
"\"dynlist-attrset []\": "
"invalid index {%d}\n",
c->valx );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
- c->log, c->msg, 0 );
+ c->log, c->cr_msg, 0 );
return 1;
}
dlip = &(*dlip)->dli_next;
@@ -1082,6 +1194,13 @@ dl_cfgen( ConfigArgs *c )
} break;
+ case DL_ATTRPAIR_COMPAT:
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
+ "warning: \"attrpair\" only supported for limited "
+ "backward compatibility with overlay \"dyngroup\"" );
+ Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg, 0 );
+ /* fallthru */
+
case DL_ATTRPAIR: {
dynlist_info_t **dlip;
ObjectClass *oc = NULL;
@@ -1091,50 +1210,65 @@ dl_cfgen( ConfigArgs *c )
oc = oc_find( "groupOfURLs" );
if ( oc == NULL ) {
- snprintf( c->msg, sizeof( c->msg ),
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
"\"dynlist-attrpair \": "
"unable to find default ObjectClass \"groupOfURLs\"" );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
- c->log, c->msg, 0 );
+ c->log, c->cr_msg, 0 );
return 1;
}
rc = slap_str2ad( c->argv[ 1 ], &member_ad, &text );
if ( rc != LDAP_SUCCESS ) {
- snprintf( c->msg, sizeof( c->msg ),
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
"\"dynlist-attrpair \": "
"unable to find AttributeDescription \"%s\"",
c->argv[ 1 ] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
- c->log, c->msg, 0 );
+ c->log, c->cr_msg, 0 );
return 1;
}
rc = slap_str2ad( c->argv[ 2 ], &ad, &text );
if ( rc != LDAP_SUCCESS ) {
- snprintf( c->msg, sizeof( c->msg ),
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
"\"dynlist-attrpair \": "
"unable to find AttributeDescription \"%s\"\n",
c->argv[ 2 ] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
- c->log, c->msg, 0 );
+ c->log, c->cr_msg, 0 );
return 1;
}
if ( !is_at_subtype( ad->ad_type, slap_schema.si_ad_labeledURI->ad_type ) ) {
- snprintf( c->msg, sizeof( c->msg ),
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
"\"dynlist-attrset []\": "
"AttributeDescription \"%s\" "
"must be a subtype of \"labeledURI\"",
c->argv[ 2 ] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
- c->log, c->msg, 0 );
+ c->log, c->cr_msg, 0 );
return 1;
}
for ( dlip = (dynlist_info_t **)&on->on_bi.bi_private;
*dlip; dlip = &(*dlip)->dli_next )
- /* goto last */;
+ {
+ /* The same URL attribute / member attribute pair
+ * cannot be repeated */
+ if ( (*dlip)->dli_ad == ad && (*dlip)->dli_member_ad == member_ad ) {
+ snprintf( c->cr_msg, sizeof( c->cr_msg ),
+ "\"dynlist-attrpair \": "
+ "URL attributeDescription \"%s\" already mapped.\n",
+ ad->ad_cname.bv_val );
+ Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
+ c->log, c->cr_msg, 0 );
+#if 0
+ /* make it a warning... */
+ return 1;
+#endif
+ }
+ }
*dlip = (dynlist_info_t *)ch_calloc( 1, sizeof( dynlist_info_t ) );
@@ -1157,12 +1291,15 @@ dl_cfgen( ConfigArgs *c )
static int
dynlist_db_open(
- BackendDB *be )
+ BackendDB *be,
+ ConfigReply *cr )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
dynlist_info_t *dli = (dynlist_info_t *)on->on_bi.bi_private;
ObjectClass *oc = NULL;
AttributeDescription *ad = NULL;
+ const char *text;
+ int rc;
if ( dli == NULL ) {
dli = ch_calloc( 1, sizeof( dynlist_info_t ) );
@@ -1170,16 +1307,13 @@ dynlist_db_open(
}
for ( ; dli; dli = dli->dli_next ) {
- const char *text;
- int rc;
-
if ( dli->dli_oc == NULL ) {
if ( oc == NULL ) {
oc = oc_find( "groupOfURLs" );
if ( oc == NULL ) {
- Debug( LDAP_DEBUG_ANY, "dynlist_db_open: "
- "unable to fetch objectClass \"groupOfURLs\".\n",
- 0, 0, 0 );
+ 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;
}
}
@@ -1191,9 +1325,10 @@ dynlist_db_open(
if ( ad == NULL ) {
rc = slap_str2ad( "memberURL", &ad, &text );
if ( rc != LDAP_SUCCESS ) {
- Debug( LDAP_DEBUG_ANY, "dynlist_db_open: "
- "unable to fetch attributeDescription \"memberURL\": %d (%s).\n",
- rc, text, 0 );
+ 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;
}
}
@@ -1201,18 +1336,30 @@ dynlist_db_open(
dli->dli_ad = ad;
}
- rc = dynlist_build_def_filter( dli );
- if ( rc != 0 ) {
- return rc;
+ if ( BER_BVISNULL( &dli->dli_default_filter ) ) {
+ rc = dynlist_build_def_filter( dli );
+ if ( rc != 0 ) {
+ return rc;
+ }
}
}
+ rc = slap_str2ad( "dgIdentity", &ad_dgIdentity, &text );
+ if ( rc != LDAP_SUCCESS ) {
+ 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 */
+ }
+
return 0;
}
static int
dynlist_db_destroy(
- BackendDB *be )
+ BackendDB *be,
+ ConfigReply *cr )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
@@ -1231,7 +1378,13 @@ dynlist_db_destroy(
return 0;
}
-static slap_overinst dynlist = { { NULL } };
+static slap_overinst dynlist = { { NULL } };
+#ifdef TAKEOVER_DYNGROUP
+static char *obsolete_names[] = {
+ "dyngroup",
+ NULL
+};
+#endif
#if SLAPD_OVER_DYNLIST == SLAPD_MOD_DYNAMIC
static
@@ -1244,6 +1397,12 @@ dynlist_initialize(void)
#endif
dynlist.on_bi.bi_type = "dynlist";
+
+#ifdef TAKEOVER_DYNGROUP
+ /* makes dynlist incompatible with dyngroup */
+ dynlist.on_bi.bi_obsolete_names = obsolete_names;
+#endif
+
#ifdef OL_2_2_COMPAT
dynlist.on_bi.bi_db_config = dynlist_db_config;
#else