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 );
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;
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++) {
}
}
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
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: "
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;
};
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 },
}
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 );
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;
}
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 ) {
#define SB_TLS_CRITICAL 2
typedef struct slap_bindconf {
+ struct berval sb_uri;
int sb_tls;
int sb_method;
struct berval sb_binddn;
} 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 */
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;
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;
}
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;
}
}
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 );
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 "=" ) ) )
} 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;
}
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 );