From 271c32328152bf2934eefe5bc8bee8a7d826ae02 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 25 Oct 2001 15:15:34 +0000 Subject: [PATCH] Fixes ITS#1385 --- servers/slapd/config.c | 27 +++++++++++++-------------- servers/slapd/proto-slap.h | 1 + servers/slapd/repl.c | 24 ++++++++++++++++++++++++ servers/slapd/tools/mimic.c | 5 +++++ 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/servers/slapd/config.c b/servers/slapd/config.c index fbac293f57..cfeb8c1bae 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -1691,22 +1691,21 @@ read_config( const char *fname ) } else { for ( i = 1; i < cargc; i++ ) { if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) { - char *nsuffix = ch_strdup( cargv[i] + 7 ); - if ( dn_normalize( nsuffix ) != NULL ) { - if ( select_backend( nsuffix, 0 ) == be ) { - charray_add( &be->be_replica[nr]->ri_nsuffix, nsuffix ); - } else { + + switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) { + case 1: #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_INFO, - "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n", - fname, lineno, cargv[i] + 7 )); + LDAP_LOG(( "config", LDAP_LEVEL_INFO, + "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n", + fname, lineno, cargv[i] + 7 )); #else - Debug( LDAP_DEBUG_ANY, - "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n", - fname, lineno, cargv[i] + 7 ); + Debug( LDAP_DEBUG_ANY, + "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n", + fname, lineno, cargv[i] + 7 ); #endif - } - } else { + break; + + case 2: #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n", @@ -1716,8 +1715,8 @@ read_config( const char *fname ) "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n", fname, lineno, 0 ); #endif + break; } - free( nsuffix ); } } } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 6933ab6259..fad2d895b4 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -499,6 +499,7 @@ LDAP_SLAPD_F (char *) phonetic LDAP_P(( char *s )); * repl.c */ LDAP_SLAPD_F (int) add_replica_info LDAP_P(( Backend *be, const char *host )); +LDAP_SLAPD_F (int) add_replica_suffix LDAP_P(( Backend *be, int nr, const char *suffix )); LDAP_SLAPD_F (void) replog LDAP_P(( Backend *be, Operation *op, char *dn, void *change )); /* diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index e309d942cf..dff5b5c82b 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -46,6 +46,30 @@ add_replica_info( return( i ); } +int +add_replica_suffix( + Backend *be, + int nr, + const char *suffix +) +{ + char *nsuffix = ch_strdup( suffix ); + int rc = 0; + + if ( dn_normalize( nsuffix ) != NULL ) { + if ( select_backend( nsuffix, 0 ) == be ) { + charray_add( &be->be_replica[nr]->ri_nsuffix, nsuffix ); + } else { + rc = 1; + } + } else { + rc = 2; + } + free( nsuffix ); + + return( rc ); +} + void replog( Backend *be, diff --git a/servers/slapd/tools/mimic.c b/servers/slapd/tools/mimic.c index 2b373f7db6..6783a55402 100644 --- a/servers/slapd/tools/mimic.c +++ b/servers/slapd/tools/mimic.c @@ -204,6 +204,11 @@ int add_replica_info( Backend *be, const char *host ) return 0; } +int add_replica_suffix( Backend *be, int nr, const char *suffix ) +{ + return 0; +} + int parse_limits( Backend *be, const char *fname, int lineno, int argc, char **argv ) { return 0; -- 2.39.5