mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-11-27 02:22:00 +08:00
ITS#10197 Back-meta and back-asyncmeta add a new target structure and increase the number of targets even if uri parsing fails
Reproducible when adding a new target via cn=config
This commit is contained in:
parent
01a1c1293b
commit
bd6dc46ad0
@ -777,6 +777,9 @@ asyncmeta_db_has_pending_ops(a_metainfo_t *mi);
|
||||
int
|
||||
asyncmeta_db_has_mscs(a_metainfo_t *mi);
|
||||
|
||||
void
|
||||
asyncmeta_target_free(a_metatarget_t *mt);
|
||||
|
||||
/* The the maximum time in seconds after a result has been received on a connection,
|
||||
* after which it can be reset if a sender error occurs. Should this be configurable? */
|
||||
#define META_BACK_RESULT_INTERVAL (2)
|
||||
|
@ -496,19 +496,14 @@ asyncmeta_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *c )
|
||||
|
||||
static int
|
||||
asyncmeta_back_new_target(
|
||||
a_metatarget_t **mtp,
|
||||
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;
|
||||
@ -516,7 +511,6 @@ 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;
|
||||
}
|
||||
@ -1887,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 ) {
|
||||
@ -1897,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, c->be ) != 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" );
|
||||
|
||||
@ -1951,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;
|
||||
|
||||
@ -1967,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;
|
||||
}
|
||||
|
||||
@ -1983,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;
|
||||
}
|
||||
|
||||
@ -1999,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 );
|
||||
}
|
||||
|
||||
@ -2021,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 );
|
||||
}
|
||||
|
||||
@ -2032,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 );
|
||||
|
||||
}
|
||||
@ -2043,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 ] );
|
||||
@ -2054,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 );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2070,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;
|
||||
|
@ -325,7 +325,7 @@ asyncmeta_back_clear_miconns( a_metainfo_t *mi )
|
||||
free(mi->mi_conns);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
asyncmeta_target_free(
|
||||
a_metatarget_t *mt )
|
||||
{
|
||||
|
@ -685,6 +685,9 @@ meta_target_finish( metainfo_t *mi, metatarget_t *mt,
|
||||
const char *log, char *msg, size_t msize
|
||||
);
|
||||
|
||||
extern void
|
||||
meta_back_target_free( metatarget_t *mt );
|
||||
|
||||
extern LDAP_REBIND_PROC meta_back_default_rebind;
|
||||
extern LDAP_URLLIST_PROC meta_back_default_urllist;
|
||||
|
||||
|
@ -565,16 +565,10 @@ meta_rwi_init( struct rewrite_info **rwm_rw )
|
||||
|
||||
static int
|
||||
meta_back_new_target(
|
||||
metatarget_t **mtp )
|
||||
metatarget_t *mt )
|
||||
{
|
||||
metatarget_t *mt;
|
||||
|
||||
*mtp = NULL;
|
||||
|
||||
mt = ch_calloc( sizeof( metatarget_t ), 1 );
|
||||
|
||||
if ( meta_rwi_init( &mt->mt_rwmap.rwm_rw )) {
|
||||
ch_free( mt );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -587,8 +581,6 @@ meta_back_new_target(
|
||||
/* by default, use proxyAuthz control on each operation */
|
||||
mt->mt_idassert_flags = LDAP_BACK_AUTH_PRESCRIPTIVE;
|
||||
|
||||
*mtp = mt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1960,7 +1952,6 @@ meta_back_cf_gen( ConfigArgs *c )
|
||||
LDAPURLDesc *ludp;
|
||||
struct berval dn;
|
||||
int j;
|
||||
|
||||
char **uris = NULL;
|
||||
|
||||
if ( c->be->be_nsuffix == NULL ) {
|
||||
@ -1970,39 +1961,17 @@ meta_back_cf_gen( ConfigArgs *c )
|
||||
return 1;
|
||||
}
|
||||
|
||||
i = mi->mi_ntargets++;
|
||||
|
||||
mi->mi_targets = ( metatarget_t ** )ch_realloc( mi->mi_targets,
|
||||
sizeof( 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 ( meta_back_new_target( &mi->mi_targets[ i ] ) != 0 ) {
|
||||
mt = ch_calloc( sizeof( metatarget_t ), 1 );
|
||||
if ( meta_back_new_target( mt ) != 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 );
|
||||
meta_back_target_free( mt );
|
||||
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" );
|
||||
|
||||
@ -2012,6 +1981,7 @@ meta_back_cf_gen( ConfigArgs *c )
|
||||
" in \"%s <protocol>://<server>[:port]/<naming context>\"",
|
||||
j-1, c->argv[0] );
|
||||
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg );
|
||||
meta_back_target_free( mt );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2040,6 +2010,7 @@ meta_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 );
|
||||
meta_back_target_free( mt );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2056,6 +2027,7 @@ meta_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 );
|
||||
meta_back_target_free( mt );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2072,6 +2044,7 @@ meta_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 );
|
||||
meta_back_target_free( mt );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
@ -2094,6 +2067,7 @@ meta_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 );
|
||||
meta_back_target_free( mt );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
@ -2105,6 +2079,7 @@ meta_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 );
|
||||
meta_back_target_free( mt );
|
||||
return( 1 );
|
||||
|
||||
}
|
||||
@ -2116,6 +2091,7 @@ meta_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 );
|
||||
meta_back_target_free( mt );
|
||||
return( 1 );
|
||||
}
|
||||
ldap_memfree( uris[ j ] );
|
||||
@ -2127,6 +2103,7 @@ meta_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 );
|
||||
meta_back_target_free( mt );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
@ -2143,8 +2120,34 @@ meta_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 );
|
||||
meta_back_target_free( mt );
|
||||
return 1;
|
||||
}
|
||||
|
||||
i = mi->mi_ntargets++;
|
||||
|
||||
mi->mi_targets = ( metatarget_t ** )ch_realloc( mi->mi_targets,
|
||||
sizeof( 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 );
|
||||
meta_back_target_free( mt );
|
||||
return 1;
|
||||
}
|
||||
|
||||
mi->mi_targets[i] = mt;
|
||||
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, meta_cf_cleanup );
|
||||
} break;
|
||||
|
@ -326,8 +326,8 @@ meta_back_map_free( struct ldapmap *lm )
|
||||
lm->map = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
target_free(
|
||||
void
|
||||
meta_back_target_free(
|
||||
metatarget_t *mt )
|
||||
{
|
||||
if ( mt->mt_uri ) {
|
||||
@ -433,7 +433,7 @@ meta_back_db_destroy(
|
||||
ldap_pvt_thread_mutex_destroy( &mt->mt_quarantine_mutex );
|
||||
}
|
||||
|
||||
target_free( mt );
|
||||
meta_back_target_free( mt );
|
||||
}
|
||||
|
||||
free( mi->mi_targets );
|
||||
|
Loading…
Reference in New Issue
Block a user