From: Pierangelo Masarati Date: Wed, 3 Jan 2007 21:35:18 +0000 (+0000) Subject: shortcut schema mapping if not configured X-Git-Tag: OPENLDAP_REL_ENG_2_4_4ALPHA~8^2~268 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bce4063a17eb4a8f0a78b028ab8bd24d1d56c4f3;p=openldap shortcut schema mapping if not configured --- diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index 2396288bf0..4e87d36dd2 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -1643,7 +1643,6 @@ rwm_db_init( BackendDB *be ) { slap_overinst *on = (slap_overinst *) be->bd_info; - struct ldapmapping *mapping = NULL; struct ldaprwmap *rwmap; #ifdef ENABLE_REWRITE char *rargv[ 3 ]; @@ -1672,13 +1671,6 @@ rwm_db_init( rewrite_parse( rwmap->rwm_rw, "", 2, 2, rargv ); #endif /* ENABLE_REWRITE */ - if ( rwm_map_init( &rwmap->rwm_oc, &mapping ) != LDAP_SUCCESS || - rwm_map_init( &rwmap->rwm_at, &mapping ) != LDAP_SUCCESS ) - { - rc = 1; - goto error_return; - } - error_return:; on->on_bi.bi_private = (void *)rwmap; diff --git a/servers/slapd/overlays/rwmconf.c b/servers/slapd/overlays/rwmconf.c index ce7776b515..81e0b3b594 100644 --- a/servers/slapd/overlays/rwmconf.c +++ b/servers/slapd/overlays/rwmconf.c @@ -47,6 +47,7 @@ rwm_map_config( struct ldapmapping *mapping; char *src, *dst; int is_oc = 0; + int rc = 0; if ( argc < 3 || argc > 4 ) { fprintf( stderr, @@ -73,7 +74,7 @@ rwm_map_config( if ( strcmp( argv[2], "*" ) == 0 ) { if ( argc < 4 || strcmp( argv[3], "*" ) == 0 ) { map->drop_missing = ( argc < 4 ); - return 0; + goto success_return; } src = dst = argv[3]; @@ -230,7 +231,13 @@ rwm_map_config( avl_insert( &map->remap, (caddr_t)&mapping[1], rwm_mapping_cmp, rwm_mapping_dup ); - return 0; +success_return:; + if ( !is_oc && map->map == NULL ) { + /* only init if required */ + rc = rwm_map_init( map, &mapping ) != LDAP_SUCCESS; + } + + return rc; error_return:; if ( mapping ) { diff --git a/servers/slapd/overlays/rwmmap.c b/servers/slapd/overlays/rwmmap.c index ce399a8f9c..c05032a36a 100644 --- a/servers/slapd/overlays/rwmmap.c +++ b/servers/slapd/overlays/rwmmap.c @@ -142,6 +142,13 @@ rwm_map( struct ldapmap *map, struct berval *s, struct berval *bv, int remap ) { struct ldapmapping *mapping; + /* map->map may be NULL when mapping is configured, + * but map->remap can't */ + if ( map->remap == NULL ) { + *bv = *s; + return; + } + BER_BVZERO( bv ); ( void )rwm_mapping( map, s, &mapping, remap ); if ( mapping != NULL ) {