From b1534d0ea91751479a319c713da0f9c75e60be4a Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 29 Apr 2006 02:15:53 +0000 Subject: [PATCH] Kludge to allow reading undefined attrs in DNs at startup --- servers/slapd/bconfig.c | 11 +++++++++++ servers/slapd/dn.c | 10 ++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index aa6b5ace24..09e21cdff8 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -40,6 +40,8 @@ static struct berval config_rdn = BER_BVC("cn=config"); static struct berval schema_rdn = BER_BVC("cn=schema"); +extern int slap_DN_strict; /* dn.c */ + #ifdef SLAPD_MODULES typedef struct modpath_s { struct modpath_s *mp_next; @@ -3010,6 +3012,7 @@ config_setup_ldif( BackendDB *be, const char *dir, int readit ) { if ( readit ) { void *thrctx = ldap_pvt_thread_pool_context(); + int prev_DN_strict; op = (Operation *) &opbuf; connection_fake_init( &conn, op, thrctx ); @@ -3040,8 +3043,16 @@ config_setup_ldif( BackendDB *be, const char *dir, int readit ) { cb.sc_private = ≻ op->o_bd = &cfb->cb_db; + + /* Allow unknown attrs in DNs */ + prev_DN_strict = slap_DN_strict; + slap_DN_strict = 0; + rc = op->o_bd->be_search( op, &rs ); + /* Restore normal DN validation */ + slap_DN_strict = prev_DN_strict; + ldap_pvt_thread_pool_context_reset( thrctx ); } diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 83d042d9b4..be7b0aea0f 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -53,6 +53,8 @@ #define AVA_PRIVATE( ava ) ( ( AttributeDescription * )(ava)->la_private ) +int slap_DN_strict = SLAP_AD_NOINSERT; + static int LDAPRDN_validate( LDAPRDN rdn ) { @@ -75,7 +77,7 @@ LDAPRDN_validate( LDAPRDN rdn ) if ( rc != LDAP_SUCCESS ) { rc = slap_bv2undef_ad( &ava->la_attr, &ad, &text, - SLAP_AD_PROXIED|SLAP_AD_NOINSERT ); + SLAP_AD_PROXIED|slap_DN_strict ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } @@ -139,7 +141,7 @@ LDAPDN_validate( LDAPDN dn ) if ( rc != LDAP_SUCCESS ) { rc = slap_bv2undef_ad( &ava->la_attr, &ad, &text, - SLAP_AD_PROXIED|SLAP_AD_NOINSERT ); + SLAP_AD_PROXIED|slap_DN_strict ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } @@ -356,7 +358,7 @@ LDAPRDN_rewrite( LDAPRDN rdn, unsigned flags, void *ctx ) if ( rc != LDAP_SUCCESS ) { rc = slap_bv2undef_ad( &ava->la_attr, &ad, &text, - SLAP_AD_PROXIED|SLAP_AD_NOINSERT ); + SLAP_AD_PROXIED|slap_DN_strict ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } @@ -488,7 +490,7 @@ LDAPDN_rewrite( LDAPDN dn, unsigned flags, void *ctx ) if ( rc != LDAP_SUCCESS ) { rc = slap_bv2undef_ad( &ava->la_attr, &ad, &text, - SLAP_AD_PROXIED|SLAP_AD_NOINSERT ); + SLAP_AD_PROXIED|slap_DN_strict ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } -- 2.39.5