mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
allow undefined schema items to be returned by back-ldap and remapped by the rwm overlay
This commit is contained in:
parent
8697bcdf7a
commit
6e12819387
@ -420,15 +420,24 @@ ldap_build_entry(
|
||||
if ( pretty ) {
|
||||
rc = pretty( attr->a_desc->ad_type->sat_syntax,
|
||||
&attr->a_vals[i], &pval, NULL );
|
||||
|
||||
} else {
|
||||
rc = validate( attr->a_desc->ad_type->sat_syntax,
|
||||
&attr->a_vals[i] );
|
||||
}
|
||||
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
attr->a_nvals = NULL;
|
||||
attr_free( attr );
|
||||
goto next_attr;
|
||||
/* check if, by chance, it's an undefined objectClass */
|
||||
if ( attr->a_desc == slap_schema.si_ad_objectClass &&
|
||||
oc_bvfind_undef( &attr->a_vals[i] ) != NULL )
|
||||
{
|
||||
ber_dupbv( &pval, &attr->a_vals[i] );
|
||||
|
||||
} else {
|
||||
attr->a_nvals = NULL;
|
||||
attr_free( attr );
|
||||
goto next_attr;
|
||||
}
|
||||
}
|
||||
|
||||
if ( pretty ) {
|
||||
@ -539,7 +548,7 @@ ldap_back_entry_get(
|
||||
|
||||
retry:
|
||||
rc = ldap_search_ext_s( lc->lc_ld, ndn->bv_val, LDAP_SCOPE_BASE, filter,
|
||||
gattr, 0, NULL, NULL, LDAP_NO_LIMIT,
|
||||
at ? gattr : NULL, 0, NULL, NULL, LDAP_NO_LIMIT,
|
||||
LDAP_NO_LIMIT, &result );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
if ( rc == LDAP_SERVER_DOWN && do_retry ) {
|
||||
|
@ -170,6 +170,47 @@ oc_bvfind( struct berval *ocname )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
static LDAP_SLIST_HEAD(OCUList, slap_object_class) oc_undef_list
|
||||
= LDAP_SLIST_HEAD_INITIALIZER(&oc_undef_list);
|
||||
|
||||
ObjectClass *
|
||||
oc_bvfind_undef( struct berval *ocname )
|
||||
{
|
||||
ObjectClass *oc = oc_bvfind( ocname );
|
||||
|
||||
if ( oc ) {
|
||||
return oc;
|
||||
}
|
||||
|
||||
LDAP_SLIST_FOREACH( oc, &oc_undef_list, soc_next ) {
|
||||
int d = oc->soc_cname.bv_len - ocname->bv_len;
|
||||
|
||||
if ( d ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( strcasecmp( oc->soc_cname.bv_val, ocname->bv_val ) == 0 ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( oc ) {
|
||||
return oc;
|
||||
}
|
||||
|
||||
oc = ch_malloc( sizeof( ObjectClass ) + ocname->bv_len + 1 );
|
||||
memset( oc, 0, sizeof( ObjectClass ) );
|
||||
|
||||
oc->soc_cname.bv_len = ocname->bv_len;
|
||||
oc->soc_cname.bv_val = (char *)&oc[ 1 ];
|
||||
AC_MEMCPY( oc->soc_cname.bv_val, ocname->bv_val, ocname->bv_len );
|
||||
|
||||
LDAP_SLIST_NEXT( oc, soc_next ) = NULL;
|
||||
LDAP_SLIST_INSERT_HEAD( &oc_undef_list, oc, soc_next );
|
||||
|
||||
return oc;
|
||||
}
|
||||
|
||||
static int
|
||||
oc_create_required(
|
||||
ObjectClass *soc,
|
||||
@ -337,6 +378,13 @@ oc_destroy( void )
|
||||
if (o->soc_allowed) ldap_memfree(o->soc_allowed);
|
||||
ldap_objectclass_free((LDAPObjectClass *)o);
|
||||
}
|
||||
|
||||
while( !LDAP_SLIST_EMPTY(&oc_undef_list) ) {
|
||||
o = LDAP_SLIST_FIRST(&oc_undef_list);
|
||||
LDAP_SLIST_REMOVE_HEAD(&oc_undef_list, soc_next);
|
||||
|
||||
ch_free( (ObjectClass *)o );
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -771,7 +771,9 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first )
|
||||
goto cleanup_attr;
|
||||
}
|
||||
|
||||
if ( (*ap)->a_desc->ad_type->sat_no_user_mod ) {
|
||||
if ( (*ap)->a_desc->ad_type->sat_no_user_mod
|
||||
&& (*ap)->a_desc->ad_type != slap_schema.si_at_undefined )
|
||||
{
|
||||
goto next_attr;
|
||||
}
|
||||
|
||||
|
@ -142,10 +142,19 @@ rwm_map_config(
|
||||
"is not defined in schema\n",
|
||||
fname, lineno, dst );
|
||||
|
||||
mapping[0].m_dst_oc = oc_bvfind_undef( &mapping[0].m_dst );
|
||||
if ( mapping[0].m_dst_oc == NULL ) {
|
||||
fprintf( stderr, "%s: line %d: unable to mimic destination objectClass '%s'\n",
|
||||
fname, lineno, dst );
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
mapping[0].m_dst_oc = ch_malloc( sizeof( ObjectClass ) );
|
||||
memset( mapping[0].m_dst_oc, 0, sizeof( ObjectClass ) );
|
||||
mapping[0].m_dst_oc->soc_cname = mapping[0].m_dst;
|
||||
mapping[0].m_flags |= RWMMAP_F_FREE_DST;
|
||||
#endif
|
||||
}
|
||||
mapping[1].m_src_oc = mapping[0].m_dst_oc;
|
||||
|
||||
|
@ -1248,7 +1248,7 @@ slap_schema_load( void )
|
||||
}
|
||||
}
|
||||
|
||||
slap_at_undefined.sat_syntax = slap_schema.si_syn_distinguishedName;
|
||||
slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString;
|
||||
slap_schema.si_at_undefined = &slap_at_undefined;
|
||||
|
||||
return LDAP_SUCCESS;
|
||||
|
Loading…
Reference in New Issue
Block a user