more URI into bindconf

This commit is contained in:
Pierangelo Masarati 2005-11-16 21:52:14 +00:00
parent 81b28fe329
commit 28aca605c7
5 changed files with 49 additions and 29 deletions

View File

@ -2337,6 +2337,8 @@ replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv )
struct berval bc = BER_BVNULL;
char numbuf[32];
assert( !BER_BVISNULL( &ri->ri_bindconf.sb_uri ) );
BER_BVZERO( bv );
len = snprintf(numbuf, sizeof( numbuf ), SLAP_X_ORDERED_FMT, i );
@ -2345,14 +2347,13 @@ replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv )
return;
}
len += strlen( ri->ri_uri ) + STRLENOF("uri=");
if ( ri->ri_nsuffix ) {
for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) {
len += ri->ri_nsuffix[i].bv_len + STRLENOF(" suffix=\"\"");
}
}
if ( ri->ri_attrs ) {
len += STRLENOF("attr");
len += STRLENOF(" attrs");
if ( ri->ri_exclude ) len++;
for (i=0; !BER_BVISNULL( &ri->ri_attrs[i].an_name ); i++) {
len += 1 + ri->ri_attrs[i].an_name.bv_len;
@ -2365,8 +2366,13 @@ replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv )
bv->bv_len = len;
ptr = lutil_strcopy( bv->bv_val, numbuf );
ptr = lutil_strcopy( ptr, "uri=" );
ptr = lutil_strcopy( ptr, ri->ri_uri );
/* start with URI from bindconf */
assert( !BER_BVISNULL( &bc ) );
if ( bc.bv_val ) {
strcpy( ptr, bc.bv_val );
ch_free( bc.bv_val );
}
if ( ri->ri_nsuffix ) {
for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) {
@ -2376,15 +2382,11 @@ replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv )
}
}
if ( ri->ri_attrs ) {
ptr = lutil_strcopy( ptr, "attr" );
ptr = lutil_strcopy( ptr, " attrs" );
if ( ri->ri_exclude ) *ptr++ = '!';
*ptr++ = '=';
ptr = anlist_unparse( ri->ri_attrs, ptr );
}
if ( bc.bv_val ) {
strcpy( ptr, bc.bv_val );
ch_free( bc.bv_val );
}
}
static int
@ -2472,7 +2474,11 @@ config_replica(ConfigArgs *c) {
return(1);
} else {
for(i = 1; i < c->argc; i++) {
if(!strncasecmp(c->argv[i], "suffix=", STRLENOF( "suffix="))) {
if(!strncasecmp(c->argv[i], "uri=", STRLENOF("uri="))) {
/* dealt with separately; don't let it get to bindconf */
;
} else if(!strncasecmp(c->argv[i], "suffix=", STRLENOF( "suffix="))) {
switch(add_replica_suffix(c->be, nr, c->argv[i] + STRLENOF("suffix="))) {
case 1:
Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: "
@ -2494,9 +2500,20 @@ config_replica(ConfigArgs *c) {
break;
}
} else if(!strncasecmp(c->argv[i], "attr", STRLENOF("attr"))) {
} else if (!strncasecmp(c->argv[i], "attr", STRLENOF("attr"))
|| !strncasecmp(c->argv[i], "attrs", STRLENOF("attrs")))
{
int exclude = 0;
char *arg = c->argv[i] + STRLENOF("attr");
if (arg[0] == 's') {
arg++;
} else {
Debug( LDAP_DEBUG_ANY,
"%s: \"attr\" "
"is deprecated (and undocumented); "
"use \"attrs\" instead.\n",
c->log, 0, 0 );
}
if(arg[0] == '!') {
arg++;
exclude = 1;

View File

@ -992,6 +992,7 @@ static slap_verbmasks methkey[] = {
};
static slap_cf_aux_table bindkey[] = {
{ BER_BVC("uri="), offsetof(slap_bindconf, sb_uri), 'b', 1, NULL },
{ BER_BVC("starttls="), offsetof(slap_bindconf, sb_tls), 'd', 0, tlskey },
{ BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 'd', 0, methkey },
{ BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 'b', 1, NULL },
@ -1151,6 +1152,10 @@ bindconf_unparse( slap_bindconf *bc, struct berval *bv )
}
void bindconf_free( slap_bindconf *bc ) {
if ( !BER_BVISNULL( &bc->sb_uri ) ) {
ch_free( bc->sb_uri.bv_val );
BER_BVZERO( &bc->sb_uri );
}
if ( !BER_BVISNULL( &bc->sb_binddn ) ) {
ch_free( bc->sb_binddn.bv_val );
BER_BVZERO( &bc->sb_binddn );

View File

@ -59,7 +59,7 @@ add_replica_info(
be->be_replica[ i ]
= ch_calloc( sizeof( struct slap_replica_info ), 1 );
be->be_replica[ i ]->ri_uri = uri;
ber_str2bv( uri, 0, 0, &be->be_replica[ i ]->ri_bindconf.sb_uri );
be->be_replica[ i ]->ri_host = host;
be->be_replica[ i ]->ri_nsuffix = NULL;
be->be_replica[ i ]->ri_attrs = NULL;
@ -81,9 +81,6 @@ destroy_replica_info(
}
for ( ; be->be_replica[ i ] != NULL; i++ ) {
ch_free( (char *)be->be_replica[ i ]->ri_uri );
ber_bvarray_free( be->be_replica[ i ]->ri_nsuffix );
if ( be->be_replica[ i ]->ri_attrs ) {

View File

@ -1543,6 +1543,7 @@ LDAP_SLAPD_V (int) slapMode;
#define SB_TLS_CRITICAL 2
typedef struct slap_bindconf {
struct berval sb_uri;
int sb_tls;
int sb_method;
struct berval sb_binddn;
@ -1555,7 +1556,6 @@ typedef struct slap_bindconf {
} slap_bindconf;
struct slap_replica_info {
const char *ri_uri; /* supersedes be_replica */
const char *ri_host; /* points to host part of uri */
BerVarray ri_nsuffix; /* array of suffixes this replica accepts */
AttributeName *ri_attrs; /* attrs to replicate, NULL=all */

View File

@ -48,7 +48,6 @@ typedef struct syncinfo_s {
struct slap_backend_db *si_be;
struct re_s *si_re;
long si_rid;
struct berval si_provideruri;
slap_bindconf si_bindconf;
struct berval si_base;
struct berval si_logbase;
@ -420,11 +419,11 @@ do_syncrep1(
psub = &si->si_be->be_nsuffix[0];
/* Init connection to master */
rc = ldap_initialize( &si->si_ld, si->si_provideruri.bv_val );
rc = ldap_initialize( &si->si_ld, si->si_bindconf.sb_uri.bv_val );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY,
"do_syncrep1: ldap_initialize failed (%s)\n",
si->si_provideruri.bv_val, 0, 0 );
si->si_bindconf.sb_uri.bv_val, 0, 0 );
return rc;
}
@ -455,7 +454,7 @@ do_syncrep1(
if( rc != LDAP_OPT_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "Error: ldap_set_option "
"(%s,SECPROPS,\"%s\") failed!\n",
si->si_provideruri.bv_val, si->si_bindconf.sb_secprops, 0 );
si->si_bindconf.sb_uri.bv_val, si->si_bindconf.sb_secprops, 0 );
goto done;
}
}
@ -2559,9 +2558,6 @@ void
syncinfo_free( syncinfo_t *sie )
{
ldap_pvt_thread_mutex_destroy( &sie->si_mutex );
if ( !BER_BVISNULL( &sie->si_provideruri ) ) {
ch_free( sie->si_provideruri.bv_val );
}
bindconf_free( &sie->si_bindconf );
@ -2733,7 +2729,7 @@ parse_syncrepl_line(
STRLENOF( PROVIDERSTR "=" ) ) )
{
val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
ber_str2bv( val, 0, 1, &si->si_provideruri );
ber_str2bv( val, 0, 1, &si->si_bindconf.sb_uri );
gots |= GOT_PROVIDER;
} else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
STRLENOF( SCHEMASTR "=" ) ) )
@ -3091,8 +3087,8 @@ add_syncrepl(
} else {
Debug( LDAP_DEBUG_CONFIG,
"Config: ** successfully added syncrepl \"%s\"\n",
BER_BVISNULL( &si->si_provideruri ) ?
"(null)" : si->si_provideruri.bv_val, 0, 0 );
BER_BVISNULL( &si->si_bindconf.sb_uri ) ?
"(null)" : si->si_bindconf.sb_uri.bv_val, 0, 0 );
if ( !si->si_schemachecking ) {
SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
}
@ -3104,14 +3100,19 @@ add_syncrepl(
static void
syncrepl_unparse( syncinfo_t *si, struct berval *bv )
{
struct berval bc;
struct berval bc, uri;
char buf[BUFSIZ*2], *ptr;
int i;
/* temporarily inhibit bindconf from printing URI */
uri = si->si_bindconf.sb_uri;
BER_BVZERO( &si->si_bindconf.sb_uri );
bindconf_unparse( &si->si_bindconf, &bc );
si->si_bindconf.sb_uri = uri;
ptr = buf;
ptr += sprintf( ptr, IDSTR "=%03ld " PROVIDERSTR "=%s",
si->si_rid, si->si_provideruri.bv_val );
ptr += snprintf( ptr, sizeof( buf ), IDSTR "=%03ld " PROVIDERSTR "=%s",
si->si_rid, si->si_bindconf.sb_uri.bv_val );
if ( !BER_BVISNULL( &bc )) {
ptr = lutil_strcopy( ptr, bc.bv_val );
free( bc.bv_val );