]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-meta/config.c
Do not return pointers into BerElement we do not own
[openldap] / servers / slapd / back-meta / config.c
index 4477c2346d4bb42c61e2982a1540c4ba9bfa4120..87ae4e76f46cdc676453ebdbdb778027adfb6ab1 100644 (file)
@@ -73,6 +73,7 @@
 
 #include "slap.h"
 #include "../back-ldap/back-ldap.h"
+#undef ldap_debug       /* silence a warning in ldap-int.h */
 #include "../../../libraries/libldap/ldap-int.h"
 #include "back-meta.h"
 
@@ -356,6 +357,16 @@ meta_back_db_config(
                }
                ber_str2bv( argv[ 1 ], 0L, 1, &li->targets[ i ]->bindpw );
                
+       /* save bind creds for referral rebinds? */
+       } else if ( strcasecmp( argv[0], "rebind-as-user" ) == 0 ) {
+               if (argc != 1) {
+                       fprintf( stderr,
+       "%s: line %d: rebind-as-user takes no arguments\n",
+                           fname, lineno );
+                       return( 1 );
+               }
+               li->savecred = 1;
+       
        /* name to use as pseudo-root dn */
        } else if ( strcasecmp( argv[ 0 ], "pseudorootdn" ) == 0 ) {
                int             i = li->ntargets-1;
@@ -492,9 +503,17 @@ meta_back_db_config(
                int             i = li->ntargets-1;
 
                if ( i < 0 ) {
+#ifndef LDAP_CACHING
                        fprintf( stderr,
        "%s: line %d: need \"uri\" directive first\n",
                                fname, lineno );
+#else /* LDAP_CACHING */
+                       if ( strcasecmp( argv[0], "rewriteEngine" ) == 0 ) {
+                               li->rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
+                       }
+                       return rewrite_parse(li->rwinfo, fname, lineno,
+                                       argc, argv); 
+#endif /* LDAP_CACHING */
                }
                
                return rewrite_parse( li->targets[ i ]->rwinfo, fname, lineno,
@@ -502,89 +521,19 @@ meta_back_db_config(
 
        /* objectclass/attribute mapping */
        } else if ( strcasecmp( argv[ 0 ], "map" ) == 0 ) {
-               struct ldapmap *map;
-               struct ldapmapping *mapping;
-               char *src, *dst;
                int             i = li->ntargets-1;
 
-               if ( i < 0 ) {
-                       fprintf( stderr,
-       "%s: line %d: need \"uri\" directive first\n",
-                               fname, lineno );
-               }
-               
-
-               if ( argc < 3 || argc > 4 ) {
-                       fprintf( stderr,
-       "%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
-                               fname, lineno );
-                       return 1;
-               }
-
-               if ( strcasecmp( argv[ 1 ], "objectClass" ) == 0 ) {
-                       map = &li->targets[ i ]->oc_map;
-               } else if ( strcasecmp( argv[ 1 ], "attribute" ) == 0 ) {
-                       map = &li->targets[ i ]->at_map;
-               } else {
-                       fprintf( stderr,
-       "%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
-                               fname, lineno );
-                       return 1;
-               }
-
-               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 {
-                       src = argv[ 2 ];
-                       dst = ( strcmp( argv[ 3 ], "*" ) == 0 ? src : argv[ 3 ] );
-               }
-
-               if ( ( map == &li->targets[ i ]->at_map )
-                       && ( strcasecmp( src, "objectclass" ) == 0
-                               || strcasecmp( dst, "objectclass" ) == 0 ) ) {
-                       fprintf( stderr,
-       "%s: line %d: objectclass attribute cannot be mapped\n",
-                               fname, lineno );
-               }
-
-               mapping = ch_calloc( 2, sizeof( struct ldapmapping ) );
-               if ( mapping == NULL ) {
-                       fprintf( stderr,
-                               "%s: line %d: out of memory\n",
-                               fname, lineno );
-                       return 1;
-               }
-               ber_str2bv( src, 0, 1, &mapping->src );
-               ber_str2bv( dst, 0, 1, &mapping->dst );
-               mapping[ 1 ].src = mapping->dst;
-               mapping[ 1 ].dst = mapping->src;
-
-               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,
-       "%s: line %d: duplicate mapping found (ignored)\n",
-                               fname, lineno );
+               return ldap_back_map_config( &li->targets[ i ]->oc_map, 
+                               &li->targets[ i ]->at_map,
+                               fname, lineno, argc, argv );
+       /* anything else */
+       } else {
+#ifdef LDAP_CACHING
+               if ( meta_back_cache_config( be, fname, lineno, argc, argv ) == 0 ) {
                        return 0;
                }
+#endif /* LDAP_CACHING */
 
-               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 );
-
-       /* anything else */
-       } else {
                fprintf( stderr,
        "%s: line %d: unknown directive \"%s\" in meta database definition"
        " (ignored)\n",