Date: Thu, 2 May 2002 08:54:59 GMT

From: h.b.furuseth@usit.uio.no
To: openldap-its@OpenLDAP.org
Subject: Patch: Bugs with back-ldap/meta mappings

Full_Name: Hallvard B. Furuseth
Version: HEAD
OS: Linux
URL: http://folk.uio.no/hbf/OpenLDAP/back-ldap.txt
Submission from: (NULL) (158.36.148.34)


The source claims the 'map' attribute has syntax
map {objectclass | attribute}   {<source> | *}      [<dest> | *]
while it actually has syntax
map {objectclass | attribute} [<local name> | *] {<foreign name> |
*}
except that the code is confused about it.  Removed attributes are
put in both the maps for local and foreign names:
	# Remove description and present title as description instead
	map attribute	description
	map attribute	description title
-->
	slapd.conf: line 10: duplicate mapping found (ignored)

Also, map.c:ldap_back_map_attrs() loops forever on removed attributes
(ie. if one asks ldapsearch for an attribute which has been removed).
This commit is contained in:
Kurt Zeilenga 2002-06-12 16:39:05 +00:00
parent 8aee3e5113
commit b5e7208cb8
3 changed files with 48 additions and 71 deletions

View File

@ -232,7 +232,7 @@ ldap_back_db_config(
if ( argc < 3 || argc > 4 ) {
fprintf( stderr,
"%s: line %d: syntax is \"map {objectclass | attribute} {<source> | *} [<dest> | *]\"\n",
"%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
fname, lineno );
return( 1 );
}
@ -243,32 +243,24 @@ ldap_back_db_config(
map = &li->at_map;
} else {
fprintf( stderr, "%s: line %d: syntax is "
"\"map {objectclass | attribute} {<source> | *} "
"[<dest> | *]\"\n",
"\"map {objectclass | attribute} [<local> | *] "
"{<foreign> | *}\"\n",
fname, lineno );
return( 1 );
}
if ( strcasecmp( argv[2], "*" ) != 0 ) {
src = argv[2];
if ( argc < 4 )
dst = "";
else if ( strcasecmp( argv[3], "*" ) == 0 )
dst = src;
else
dst = argv[3];
if ( strcmp( argv[2], "*" ) == 0 ) {
if ( argc < 4 || strcmp( argv[3], "*" ) == 0 ) {
map->drop_missing = ( argc < 4 );
return 0;
}
src = dst = argv[3];
} else if ( argc < 4 ) {
src = "";
dst = argv[2];
} else {
if ( argc < 4 ) {
map->drop_missing = 1;
return 0;
}
if ( strcasecmp( argv[3], "*" ) == 0 ) {
map->drop_missing = 0;
return 0;
}
src = argv[3];
dst = src;
src = argv[2];
dst = ( strcmp( argv[3], "*" ) == 0 ? src : argv[3] );
}
if ( ( map == &li->at_map )
@ -290,15 +282,11 @@ ldap_back_db_config(
}
ber_str2bv( src, 0, 1, &mapping->src );
ber_str2bv( dst, 0, 1, &mapping->dst );
if ( *dst != 0 ) {
mapping[1].src = mapping->dst;
mapping[1].dst = mapping->src;
} else {
mapping[1].src = mapping->src;
mapping[1].dst = mapping->dst;
}
mapping[1].src = mapping->dst;
mapping[1].dst = mapping->src;
if ( avl_find( map->map, (caddr_t)mapping, mapping_cmp ) != NULL ||
if ( (*src != '\0' &&
avl_find( map->map, (caddr_t)mapping, mapping_cmp ) != NULL) ||
avl_find( map->remap, (caddr_t)&mapping[1], mapping_cmp ) != NULL)
{
fprintf( stderr,
@ -307,8 +295,9 @@ ldap_back_db_config(
return 0;
}
avl_insert( &map->map, (caddr_t)mapping,
mapping_cmp, mapping_dup );
if ( *src != '\0' )
avl_insert( &map->map, (caddr_t)mapping,
mapping_cmp, mapping_dup );
avl_insert( &map->remap, (caddr_t)&mapping[1],
mapping_cmp, mapping_dup );

View File

@ -216,7 +216,7 @@ ldap_back_map_attrs(
int remap
)
{
int i;
int i, j;
char **na;
struct berval mapped;
@ -231,14 +231,14 @@ ldap_back_map_attrs(
if (na == NULL)
return(NULL);
for (i = 0; an[i].an_name.bv_val; ) {
for (i = j = 0; an[i].an_name.bv_val; i++) {
ldap_back_map(at_map, &an[i].an_name, &mapped, remap);
if (mapped.bv_val != NULL) {
na[i] = mapped.bv_val;
i++;
}
if (mapped.bv_val != NULL)
na[j++] = mapped.bv_val;
}
na[i] = NULL;
if (j == 0 && i != 0)
na[j++] = LDAP_NO_ATTRS;
na[j] = NULL;
return(na);
}

View File

@ -503,7 +503,7 @@ meta_back_db_config(
if ( argc < 3 || argc > 4 ) {
fprintf( stderr,
"%s: line %d: syntax is \"map {objectclass | attribute} {<source> | *} [<dest> | *]\"\n",
"%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
fname, lineno );
return 1;
}
@ -514,32 +514,23 @@ meta_back_db_config(
map = &li->targets[ i ]->at_map;
} else {
fprintf( stderr,
"%s: line %d: syntax is \"map {objectclass | attribute} {<source> | *} [<dest> | *]\"\n",
"%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
fname, lineno );
return 1;
}
if ( strcasecmp( argv[ 2 ], "*" ) != 0 ) {
src = argv[ 2 ];
if ( argc < 4 ) {
dst = "";
} else if ( strcasecmp( argv[ 3 ], "*" ) == 0 ) {
dst = src;
} else {
dst = argv[ 3 ];
if ( strcmp( argv[ 2 ], "*" ) == 0 ) {
if ( argc < 4 || strcmp( argv[ 3 ], "*" ) == 0 ) {
map->drop_missing = ( argc < 4 );
return 0;
}
src = dst = argv[ 3 ];
} else if ( argc < 4 ) {
src = "";
dst = argv[ 2 ];
} else {
if ( argc < 4 ) {
map->drop_missing = 1;
return 0;
}
if ( strcasecmp( argv[ 3 ], "*" ) == 0 ) {
map->drop_missing = 0;
return 0;
}
src = argv[ 3 ];
dst = src;
src = argv[ 2 ];
dst = ( strcmp( argv[ 3 ], "*" ) == 0 ? src : argv[ 3 ] );
}
if ( ( map == &li->targets[ i ]->at_map )
@ -559,16 +550,12 @@ meta_back_db_config(
}
ber_str2bv( src, 0, 1, &mapping->src );
ber_str2bv( dst, 0, 1, &mapping->dst );
if ( *dst != 0 ) {
mapping[ 1 ].src = mapping->dst;
mapping[ 1 ].dst = mapping->src;
} else {
mapping[ 1 ].src = mapping->src;
mapping[ 1 ].dst = mapping->dst;
}
mapping[ 1 ].src = mapping->dst;
mapping[ 1 ].dst = mapping->src;
if ( avl_find( map->map, ( caddr_t )mapping,
mapping_cmp ) != NULL
if ( (*src != '\0' &&
avl_find( map->map, ( caddr_t )mapping,
mapping_cmp ) != NULL)
|| avl_find( map->remap, ( caddr_t )&mapping[ 1 ],
mapping_cmp ) != NULL) {
fprintf( stderr,
@ -577,8 +564,9 @@ meta_back_db_config(
return 0;
}
avl_insert( &map->map, ( caddr_t )mapping,
mapping_cmp, mapping_dup );
if ( *src != '\0' )
avl_insert( &map->map, ( caddr_t )mapping,
mapping_cmp, mapping_dup );
avl_insert( &map->remap, ( caddr_t )&mapping[ 1 ],
mapping_cmp, mapping_dup );