&config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
"DESC 'OpenLDAP attributeTypes' "
"EQUALITY caseIgnoreMatch "
+ "SUBSTR caseIgnoreSubstringsMatch "
"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
NULL, NULL },
{ "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
&config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
"DESC 'OpenLDAP DIT content rules' "
"EQUALITY caseIgnoreMatch "
+ "SUBSTR caseIgnoreSubstringsMatch "
"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
NULL, NULL },
{ "extra_attrs", "attrlist", 2, 2, 0, ARG_DB|ARG_MAGIC,
&config_generic, "( OLcfgGlAt:85 NAME 'olcLdapSyntaxes' "
"DESC 'OpenLDAP ldapSyntax' "
"EQUALITY caseIgnoreMatch "
+ "SUBSTR caseIgnoreSubstringsMatch "
"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
NULL, NULL },
{ "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
&config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
"DESC 'OpenLDAP object classes' "
"EQUALITY caseIgnoreMatch "
+ "SUBSTR caseIgnoreSubstringsMatch "
"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
NULL, NULL },
{ "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
&config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
"EQUALITY caseIgnoreMatch "
+ "SUBSTR caseIgnoreSubstringsMatch "
"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
{ "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
&config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
int i;
for (i=0, oc = cfn->c_oc_head; i<c->valx; i++) {
prev = oc;
- oc_next( &oc );
+ if ( !oc_next( &oc ))
+ break;
}
} else
/* If adding the first, and head exists, find its prev */
int i;
for (i=0, at = cfn->c_at_head; i<c->valx; i++) {
prev = at;
- at_next( &at );
+ if ( !at_next( &at ))
+ break;
}
} else
/* If adding the first, and head exists, find its prev */
int i;
for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++ ) {
prev = syn;
- syn_next( &syn );
+ if ( !syn_next( &syn ))
+ break;
}
} else
/* If adding the first, and head exists, find its prev */
return rc;
}
+/* Insert all superior classes of the given class */
static int
count_oc( ObjectClass *oc, ConfigOCs ***copp, int *nocs )
{
ConfigOCs co, *cop;
ObjectClass **sups;
+ for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
+ if ( count_oc( *sups, copp, nocs ) ) {
+ return -1;
+ }
+ }
+
co.co_name = &oc->soc_cname;
cop = avl_find( CfOcTree, &co, CfOc_cmp );
if ( cop ) {
}
}
- for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
- if ( count_oc( *sups, copp, nocs ) ) {
- return -1;
- }
- }
-
return 0;
}
+/* Find all superior classes of the given objectclasses,
+ * return list in order of most-subordinate first.
+ *
+ * Special / auxiliary / Cft_Misc classes always take precedence.
+ */
static ConfigOCs **
count_ocs( Attribute *oc_at, int *nocs )
{
- int i;
+ int i, j, misc = -1;
ConfigOCs **colst = NULL;
*nocs = 0;
- for ( i = 0; !BER_BVISNULL( &oc_at->a_nvals[i] ); i++ )
- /* count attrs */ ;
-
- for ( ; i--; ) {
+ for ( i = oc_at->a_numvals; i--; ) {
ObjectClass *oc = oc_bvfind( &oc_at->a_nvals[i] );
assert( oc != NULL );
}
}
+ /* invert order */
+ i = 0;
+ j = *nocs - 1;
+ while ( i < j ) {
+ ConfigOCs *tmp = colst[i];
+ colst[i] = colst[j];
+ colst[j] = tmp;
+ if (tmp->co_type == Cft_Misc)
+ misc = j;
+ i++; j--;
+ }
+ /* Move misc class to front of list */
+ if (misc > 0) {
+ ConfigOCs *tmp = colst[misc];
+ for (i=misc; i>0; i--)
+ colst[i] = colst[i-1];
+ colst[0] = tmp;
+ }
+
return colst;
}
oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
+ for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
+ if (ml->sml_desc == slap_schema.si_ad_objectClass)
+ return rc;
+ }
+
colst = count_ocs( oc_at, &nocs );
/* make sure add/del flags are clear; should always be true */
rs->sr_matched = last->ce_entry->e_name.bv_val;
rs->sr_err = LDAP_NO_SUCH_OBJECT;
} else if ( ce->ce_kids ) {
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
} else if ( op->o_abandon ) {
rs->sr_err = SLAPD_ABANDON;
- } else if ( ce->ce_type == Cft_Overlay || ce->ce_type == Cft_Database ){
+ } else if ( ce->ce_type == Cft_Overlay ||
+ ce->ce_type == Cft_Database ||
+ ce->ce_type == Cft_Misc ){
char *iptr;
int count, ixold;
ldap_pvt_thread_pool_pause( &connection_pool );
if ( ce->ce_type == Cft_Overlay ){
- if ( SLAP_ISGLOBALOVERLAY(ce->ce_be ) ) {
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
- rs->sr_text = "Cannot delete global overlays";
+ overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi, op );
+ } else if ( ce->ce_type == Cft_Misc ) {
+ /*
+ * only Cft_Misc objects that have a co_lddel handler set in
+ * the ConfigOCs struct can be deleted. This code also
+ * assumes that the entry can be only have one objectclass
+ * with co_type == Cft_Misc
+ */
+ ConfigOCs co, *coptr;
+ Attribute *oc_at;
+ int i;
+
+ oc_at = attr_find( ce->ce_entry->e_attrs,
+ slap_schema.si_ad_objectClass );
+ if ( !oc_at ) {
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "objectclass not found";
ldap_pvt_thread_pool_resume( &connection_pool );
goto out;
- } else {
- overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi, op );
}
- } else { /* Cft_Database*/
+ for ( i=0; !BER_BVISNULL(&oc_at->a_nvals[i]); i++ ) {
+ co.co_name = &oc_at->a_nvals[i];
+ coptr = avl_find( CfOcTree, &co, CfOc_cmp );
+ if ( coptr == NULL || coptr->co_type != Cft_Misc ) {
+ continue;
+ }
+ if ( ! coptr->co_lddel || coptr->co_lddel( ce, op ) ){
+ rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ if ( ! coptr->co_lddel ) {
+ rs->sr_text = "No delete handler found";
+ } else {
+ rs->sr_err = LDAP_OTHER;
+ /* FIXME: We should return a helpful error message
+ * here */
+ }
+ ldap_pvt_thread_pool_resume( &connection_pool );
+ goto out;
+ }
+ break;
+ }
+ } else if (ce->ce_type == Cft_Database ) {
if ( ce->ce_be == frontendDB || ce->ce_be == op->o_bd ){
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
rs->sr_text = "Cannot delete config or frontend database";
ldap_pvt_thread_pool_resume( &connection_pool );
goto out;
- }
+ }
if ( ce->ce_be->bd_info->bi_db_close ) {
ce->ce_be->bd_info->bi_db_close( ce->ce_be, NULL );
}
} else {
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
}
+out:
#else
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
#endif /* SLAP_CONFIG_DELETE */
-out:
send_ldap_result( op, rs );
return rs->sr_err;
}
bv.bv_len );
c->value_dn.bv_len += bv.bv_len;
c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
- rdn = c->value_dn;
+ rdnNormalize( 0, NULL, NULL, &c->value_dn, &rdn, NULL );
c->ca_private = cf;
e = config_build_entry( op, rs, ceparent, c, &rdn,
&CFOC_SCHEMA, NULL );
+ ch_free( rdn.bv_val );
if ( !e ) {
return -1;
} else if ( e && cf->c_kids ) {
Operation *op = NULL;
void *thrctx;
int isFrontend = 0;
+ int isFrontendChild = 0;
/* Create entry for frontend database if it does not exist already */
if ( !entry_put_got_frontend ) {
}
}
}
+
+ /* Child entries of the frontend database, e.g. slapo-chain's back-ldap
+ * instances, may appear before the config database entry in the ldif, skip
+ * auto-creation of olcDatabase={0}config in such a case */
+ if ( !entry_put_got_config &&
+ !strncmp( e->e_nname.bv_val, "olcDatabase", STRLENOF( "olcDatabase" ))) {
+ struct berval pdn;
+ dnParent( &e->e_nname, &pdn );
+ while ( pdn.bv_len ) {
+ if ( !strncmp( pdn.bv_val, "olcDatabase",
+ STRLENOF( "olcDatabase" ))) {
+ if ( !strncmp( pdn.bv_val +
+ STRLENOF( "olcDatabase" ), "={-1}frontend",
+ STRLENOF( "={-1}frontend" )) ||
+ !strncmp( pdn.bv_val +
+ STRLENOF( "olcDatabase" ), "=frontend",
+ STRLENOF( "=frontend" ))) {
+
+ isFrontendChild = 1;
+ break;
+ }
+ }
+ dnParent( &pdn, &pdn );
+ }
+ }
+
/* Create entry for config database if it does not exist already */
- if ( !entry_put_got_config && !isFrontend ) {
+ if ( !entry_put_got_config && !isFrontend && !isFrontendChild ) {
if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
STRLENOF( "olcDatabase" ))) {
if ( strncmp( e->e_nname.bv_val +