From 7ff1f42f7ef9f492e32c19608fb1283d77714974 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sun, 21 Mar 2021 14:58:22 +0000 Subject: [PATCH] ITS#8246 frontend and config DBs are unique Also make sure config_add_internal errmsg is returned to slapadd --- servers/slapd/bconfig.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index bff03612eb..0104fc8ead 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -1060,6 +1060,11 @@ config_resize_lthreads(ConfigArgs *c) return slapd_daemon_resize( new_daemon_threads ); } +#define GOT_CONFIG 1 +#define GOT_FRONTEND 2 +static int +config_unique_db; + static int config_generic(ConfigArgs *c) { int i; @@ -1784,9 +1789,19 @@ config_generic(ConfigArgs *c) { /* NOTE: config is always the first backend! */ if ( !strcasecmp( c->argv[1], "config" )) { + if (config_unique_db & GOT_CONFIG) { + sprintf( c->cr_msg, "config DB already defined"); + return(1); + } c->be = LDAP_STAILQ_FIRST(&backendDB); + config_unique_db |= GOT_CONFIG; } else if ( !strcasecmp( c->argv[1], "frontend" )) { + if (config_unique_db & GOT_FRONTEND) { + sprintf( c->cr_msg, "frontend DB already defined"); + return(1); + } c->be = frontendDB; + config_unique_db |= GOT_FRONTEND; } else { c->be = backend_db_init(c->argv[1], NULL, c->valx, &c->reply); if ( !c->be ) { @@ -7808,8 +7823,10 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text ) if ( bi && bi->bi_tool_entry_put && config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 ) return bi->bi_tool_entry_put( &cfb->cb_db, e, text ); - else + else { + ber_str2bv( ca.cr_msg, 0, 0, text ); return NOID; + } } static ID