char *dn, *massaged_dn;
#endif /* ENABLE_REWRITE */
BackendDB *tmp_be;
+ struct berval bdn, *ndn = NULL;
/*
* syntax:
return( 1 );
}
- tmp_be = select_backend( argv[1], 0, 0 );
+ bdn.bv_val = argv[1];
+ bdn.bv_len = strlen(bdn.bv_val);
+ if ( dnNormalize( NULL, &bdn, &ndn ) != LDAP_SUCCESS ) {
+ fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n",
+ fname, lineno, bdn.bv_val );
+ return( 1 );
+ }
+ tmp_be = select_backend( ndn, 0, 0 );
+ ber_bvfree( ndn );
+ ndn = NULL;
if ( tmp_be != NULL && tmp_be != be ) {
fprintf( stderr, "%s: line %d: suffix already in use"
" by another backend in"
return( 1 );
}
- tmp_be = select_backend( argv[2], 0, 0 );
+ bdn.bv_val = argv[2];
+ bdn.bv_len = strlen(bdn.bv_val);
+ if ( dnNormalize( NULL, &bdn, &ndn ) != LDAP_SUCCESS ) {
+ fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n",
+ fname, lineno, bdn.bv_val );
+ return( 1 );
+ }
+ tmp_be = select_backend( ndn, 0, 0 );
+ ber_bvfree( ndn );
if ( tmp_be != NULL ) {
fprintf( stderr, "%s: line %d: massaged suffix"
" already in use by another backend in"
char **
ldap_back_map_attrs(
struct ldapmap *at_map,
- char **a,
+ struct berval **a,
int remap
)
{
int i, j, count;
- char **na, *mapped;
+ char *mapped, **na;
if (a == NULL)
return(NULL);
return(NULL);
for (i = 0, j = 0; i < count; i++) {
- mapped = ldap_back_map(at_map, a[i], remap);
+ mapped = ldap_back_map(at_map, a[i]->bv_val, remap);
if (mapped != NULL) {
- mapped = ch_strdup(mapped);
- if (mapped == NULL) {
- charray_free(na);
- return(NULL);
- }
na[j] = mapped;
j++;
}
}
mapped_attrs = ldap_back_map_attrs(&li->at_map, attrs, 0);
- if ( mapped_attrs == NULL ) {
- mapped_attrs = attrs;
+ if ( mapped_attrs == NULL && attrs) {
+ for (count=0; attrs[count]; count++);
+ mapped_attrs = ch_malloc( (count+1) * sizeof(char *));
+ for (count=0; attrs[count]; count++) {
+ mapped_attrs[count] = attrs[count]->bv_val;
+ }
+ mapped_attrs[count] = NULL;
}
if ((msgid = ldap_search(lc->ld, mbase, scope, mapped_filter, mapped_attrs,
if ( err ) {
free( err );
}
- if ( mapped_attrs != attrs ) {
- charray_free( mapped_attrs );
+ if ( mapped_attrs ) {
+ free( mapped_attrs );
}
#ifdef ENABLE_REWRITE
if ( mapped_filter != mfilter ) {
return (-1);
}
- for (i = 0; attrs != NULL && attrs[i] != NULL; i++)
- charray_add(&sattrs, attrs[i]->bv_val);
+ for (i = 0; attrs != NULL && attrs[i] != NULL; i++);
if (i > 0) {
+ sattrs = ch_malloc( (i+1) * sizeof(char *));
+ for (i = 0; attrs[i]; i++)
+ sattrs[i] = attrs[i]->bv_val;
+ sattrs[i] = NULL;
attrs_tcl = Tcl_Merge (i, sattrs);
- charray_free(sattrs);
+ free(sattrs);
}
for (i = 0; be->be_suffix[i] != NULL; i++);