]> git.sur5r.net Git - openldap/commitdiff
shortcut schema mapping if not configured
authorPierangelo Masarati <ando@openldap.org>
Wed, 3 Jan 2007 21:35:18 +0000 (21:35 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 3 Jan 2007 21:35:18 +0000 (21:35 +0000)
servers/slapd/overlays/rwm.c
servers/slapd/overlays/rwmconf.c
servers/slapd/overlays/rwmmap.c

index 2396288bf056449a82f8604bc8584f9f91ef79a2..4e87d36dd2b05098e299f092f6df37b6f482f5ab 100644 (file)
@@ -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, "<suffix massage>", 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;
 
index ce7776b5154d5fbecff6094efa4f9cb9995ad2a9..81e0b3b594e45a2514c57a74f59c4bde832b0866 100644 (file)
@@ -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 ) {
index ce399a8f9ced466bed4ce73aba7f7a8c3b6960ce..c05032a36aa3cd18d30f1fd79c309c4c2834ec2e 100644 (file)
@@ -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 ) {