From d06a8bd19859c6b0d6a29788c0d280efb9b76626 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Thu, 5 Apr 2007 16:12:24 +0000 Subject: [PATCH] olcDatabase=config always gets index 0, don't allow multiple olcDatabase=config entries (ITS#4914) --- servers/slapd/bconfig.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 49d7f2660d..5dfc35e542 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -3958,7 +3958,7 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e, { CfEntryInfo *ce; int index = -1, gotindex = 0, nsibs, rc = 0; - int renumber = 0, tailindex = 0, isfrontend = 0; + int renumber = 0, tailindex = 0, isfrontend = 0, isconfig = 0; char *ptr1, *ptr2 = NULL; struct berval rdn; @@ -3973,9 +3973,14 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e, /* See if the rdn has an index already */ dnRdn( &e->e_name, &rdn ); - if ( ce_type == Cft_Database && !strncmp( rdn.bv_val + rdn.bv_len - - STRLENOF("frontend"), "frontend", STRLENOF("frontend") )) - isfrontend = 1; + if ( ce_type == Cft_Database ) { + if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("frontend"), + "frontend", STRLENOF("frontend") )) + isfrontend = 1; + else if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("config"), + "config", STRLENOF("config") )) + isconfig = 1; + } ptr1 = ber_bvchr( &e->e_name, '{' ); if ( ptr1 && ptr1 - e->e_name.bv_val < rdn.bv_len ) { char *next; @@ -3994,6 +3999,9 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e, if ( index != -1 || !isfrontend ) return LDAP_NAMING_VIOLATION; } + if ( isconfig && index != 0 ){ + return LDAP_NAMING_VIOLATION; + } } /* count related kids */ @@ -4014,6 +4022,10 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e, renumber = 1; } } + /* config DB is always "0" */ + if ( isconfig && index == -1 ) { + index = 0; + } if ( !isfrontend && index == -1 ) { index = nsibs; } -- 2.39.5