diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 05:34:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 05:34:56 +0000 |
commit | 3fa3e6ac17cbab8003ce3b3ae87928de5f5eaaf4 (patch) | |
tree | 1fa47166862724850b871e1900513bf04d3c1cc2 /servers/slapd/back-asyncmeta/config.c | |
parent | Adding upstream version 2.6.7+dfsg. (diff) | |
download | openldap-3fa3e6ac17cbab8003ce3b3ae87928de5f5eaaf4.tar.xz openldap-3fa3e6ac17cbab8003ce3b3ae87928de5f5eaaf4.zip |
Adding upstream version 2.6.8+dfsg.upstream/2.6.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | servers/slapd/back-asyncmeta/config.c | 103 |
1 files changed, 58 insertions, 45 deletions
diff --git a/servers/slapd/back-asyncmeta/config.c b/servers/slapd/back-asyncmeta/config.c index e4cc5ea..9271ba8 100644 --- a/servers/slapd/back-asyncmeta/config.c +++ b/servers/slapd/back-asyncmeta/config.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software <http://www.openldap.org/>. * - * Copyright 2016-2022 The OpenLDAP Foundation. + * Copyright 2016-2024 The OpenLDAP Foundation. * Portions Copyright 2016 Symas Corporation. * All rights reserved. * @@ -496,18 +496,14 @@ asyncmeta_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *c ) static int asyncmeta_back_new_target( - a_metatarget_t **mtp, - a_metainfo_t *mi ) + a_metatarget_t *mt, + a_metainfo_t *mi, + BackendDB *db ) { - a_metatarget_t *mt; - - *mtp = NULL; int i; assert ( mi != NULL ); - mt = ch_calloc( sizeof( a_metatarget_t ), 1 ); - - ldap_pvt_thread_mutex_init( &mt->mt_uri_mutex ); + assert ( mt != NULL ); mt->mt_idassert_mode = LDAP_BACK_IDASSERT_LEGACY; mt->mt_idassert_authmethod = LDAP_AUTH_NONE; @@ -515,8 +511,9 @@ asyncmeta_back_new_target( /* by default, use proxyAuthz control on each operation */ mt->mt_idassert_flags = LDAP_BACK_AUTH_PRESCRIPTIVE; - *mtp = mt; - + if ( !SLAP_DBOPEN(db) || !(slapMode & SLAP_SERVER_MODE)) { + return 0; + } for ( i = 0; i < mi->mi_num_conns; i++ ) { a_metaconn_t *mc = &mi->mi_conns[i]; mc->mc_conns = ch_realloc( mc->mc_conns, sizeof( a_metasingleconn_t ) * mi->mi_ntargets); @@ -1884,7 +1881,6 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) LDAPURLDesc *ludp; struct berval dn; int j; - char **uris = NULL; if ( c->be->be_nsuffix == NULL ) { @@ -1894,39 +1890,6 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) return 1; } - i = mi->mi_ntargets++; - - mi->mi_targets = ( a_metatarget_t ** )ch_realloc( mi->mi_targets, - sizeof( a_metatarget_t * ) * mi->mi_ntargets ); - if ( mi->mi_targets == NULL ) { - snprintf( c->cr_msg, sizeof( c->cr_msg ), - "out of memory while storing server name" - " in \"%s <protocol>://<server>[:port]/<naming context>\"", - c->argv[0] ); - Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); - return 1; - } - - if ( asyncmeta_back_new_target( &mi->mi_targets[ i ], mi ) != 0 ) { - snprintf( c->cr_msg, sizeof( c->cr_msg ), - "unable to init server" - " in \"%s <protocol>://<server>[:port]/<naming context>\"", - c->argv[0] ); - Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); - return 1; - } - - mt = mi->mi_targets[ i ]; - - mt->mt_rebind_f = mi->mi_rebind_f; - mt->mt_urllist_f = mi->mi_urllist_f; - mt->mt_urllist_p = mt; - - if ( META_BACK_QUARANTINE( mi ) ) { - ldap_pvt_thread_mutex_init( &mt->mt_quarantine_mutex ); - } - mt->mt_mc = mi->mi_mc; - for ( j = 1; j < c->argc; j++ ) { char **tmpuris = ldap_str2charray( c->argv[ j ], "\t" ); @@ -1948,6 +1911,8 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) } } + mt = ch_calloc( sizeof( a_metatarget_t ), 1 ); + for ( j = 0; uris[ j ] != NULL; j++ ) { char *tmpuri = NULL; @@ -1964,6 +1929,7 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) j-1, c->argv[0] ); Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); ldap_charray_free( uris ); + asyncmeta_target_free( mt ); return 1; } @@ -1980,6 +1946,7 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); ldap_free_urllist( ludp ); ldap_charray_free( uris ); + asyncmeta_target_free( mt ); return 1; } @@ -1996,6 +1963,7 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); ldap_free_urllist( ludp ); ldap_charray_free( uris ); + asyncmeta_target_free( mt ); return( 1 ); } @@ -2018,6 +1986,7 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); ldap_free_urllist( ludp ); ldap_charray_free( uris ); + asyncmeta_target_free( mt ); return( 1 ); } @@ -2029,6 +1998,7 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); ldap_free_urllist( ludp ); ldap_charray_free( uris ); + asyncmeta_target_free( mt ); return( 1 ); } @@ -2040,6 +2010,7 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) snprintf( c->cr_msg, sizeof( c->cr_msg ), "no memory?" ); Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); ldap_charray_free( uris ); + asyncmeta_target_free( mt ); return( 1 ); } ldap_memfree( uris[ j ] ); @@ -2051,7 +2022,10 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) if ( mt->mt_uri == NULL) { snprintf( c->cr_msg, sizeof( c->cr_msg ), "no memory?" ); Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); + asyncmeta_target_free( mt ); return( 1 ); + } else { + ldap_pvt_thread_mutex_init( &mt->mt_uri_mutex ); } /* @@ -2067,8 +2041,47 @@ asyncmeta_back_cf_gen( ConfigArgs *c ) snprintf( c->cr_msg, sizeof( c->cr_msg ), "<naming context> of URI must be within the naming context of this database." ); Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); + asyncmeta_target_free( mt ); + return 1; + } + + i = mi->mi_ntargets++; + + mi->mi_targets = ( a_metatarget_t ** )ch_realloc( mi->mi_targets, + sizeof( a_metatarget_t * ) * mi->mi_ntargets ); + if ( mi->mi_targets == NULL ) { + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "out of memory while storing server name" + " in \"%s <protocol>://<server>[:port]/<naming context>\"", + c->argv[0] ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); + asyncmeta_target_free( mt ); return 1; } + + mi->mi_targets[ i ] = mt; + if ( asyncmeta_back_new_target( mt, mi, c->be ) != 0 ) { + /* does not currently happen, asyncmeta back_new_target always returns 0 */ + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "unable to init server" + " in \"%s <protocol>://<server>[:port]/<naming context>\"", + c->argv[0] ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); + asyncmeta_target_free( mt ); + mi->mi_ntargets--; + return 1; + } + + + mt->mt_rebind_f = mi->mi_rebind_f; + mt->mt_urllist_f = mi->mi_urllist_f; + mt->mt_urllist_p = mt; + + if ( META_BACK_QUARANTINE( mi ) ) { + ldap_pvt_thread_mutex_init( &mt->mt_quarantine_mutex ); + } + mt->mt_mc = mi->mi_mc; + c->ca_private = mt; config_push_cleanup( c, asyncmeta_cf_cleanup ); } break; |