]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-meta/init.c
fix ITS#3464
[openldap] / servers / slapd / back-meta / init.c
index 01d987453701d420ba07a55a42e3788558cebaa2..e7883ce14738fb4077c9eda321983e02961997d3 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
 #include "slap.h"
 #include "../back-ldap/back-ldap.h"
 #include "back-meta.h"
-#include "external.h"
-
-#if SLAPD_META == SLAPD_MOD_DYNAMIC
-
-int
-init_module( int argc, char *argv[] ) {
-    BackendInfo bi;
-
-    memset( &bi, '\0', sizeof( bi ) );
-    bi.bi_type = "meta";
-    bi.bi_init = meta_back_initialize;
-
-    backend_add( &bi );
-    return 0;
-}
-
-#endif /* SLAPD_META */
 
 int
 meta_back_open(
@@ -127,22 +110,23 @@ conn_free(
        void *v_lc
 )
 {
-       struct metaconn *lc = v_lc;
-       struct metasingleconn *lsc;
+       struct metaconn         *lc = v_lc;
+       struct metasingleconn   *lsc;
 
-       for ( lsc = lc->conns; !META_LAST(lsc); lsc++ ) {
-               if ( lsc->ld != NULL ) {
-                       ldap_unbind( lsc->ld );
+       for ( lsc = lc->mc_conns; !META_LAST( lsc ); lsc++ ) {
+               if ( lsc->msc_ld != NULL ) {
+                       ldap_unbind_ext_s( lsc->msc_ld, NULL, NULL );
                }
-               if ( lsc->bound_dn.bv_val ) {
-                       ber_memfree( lsc->bound_dn.bv_val );
+               if ( !BER_BVISNULL( &lsc->msc_bound_ndn ) ) {
+                       ber_memfree( lsc->msc_bound_ndn.bv_val );
                }
-               if ( lsc->cred.bv_val ) {
-                       memset( lsc->cred.bv_val, 0, lsc->cred.bv_len );
-                       ber_memfree( lsc->cred.bv_val );
+               if ( !BER_BVISNULL( &lsc->msc_cred ) ) {
+                       /* destroy sensitive data */
+                       memset( lsc->msc_cred.bv_val, 0, lsc->msc_cred.bv_len );
+                       ber_memfree( lsc->msc_cred.bv_val );
                }
        }
-       free( lc->conns );
+       free( lc->mc_conns );
        free( lc );
 }
 
@@ -160,34 +144,34 @@ target_free(
                struct metatarget *lt
 )
 {
-       if ( lt->uri ) {
-               free( lt->uri );
+       if ( lt->mt_uri ) {
+               free( lt->mt_uri );
        }
-       if ( lt->psuffix.bv_val ) {
-               free( lt->psuffix.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_psuffix ) ) {
+               free( lt->mt_psuffix.bv_val );
        }
-       if ( lt->suffix.bv_val ) {
-               free( lt->suffix.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_nsuffix ) ) {
+               free( lt->mt_nsuffix.bv_val );
        }
-       if ( lt->binddn.bv_val ) {
-               free( lt->binddn.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_binddn ) ) {
+               free( lt->mt_binddn.bv_val );
        }
-       if ( lt->bindpw.bv_val ) {
-               free( lt->bindpw.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_bindpw ) ) {
+               free( lt->mt_bindpw.bv_val );
        }
-       if ( lt->pseudorootdn.bv_val ) {
-               free( lt->pseudorootdn.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_pseudorootdn ) ) {
+               free( lt->mt_pseudorootdn.bv_val );
        }
-       if ( lt->pseudorootpw.bv_val ) {
-               free( lt->pseudorootpw.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_pseudorootpw ) ) {
+               free( lt->mt_pseudorootpw.bv_val );
        }
-       if ( lt->rwmap.rwm_rw ) {
-               rewrite_info_delete( &lt->rwmap.rwm_rw );
+       if ( lt->mt_rwmap.rwm_rw ) {
+               rewrite_info_delete( &lt->mt_rwmap.rwm_rw );
        }
-       avl_free( lt->rwmap.rwm_oc.remap, NULL );
-       avl_free( lt->rwmap.rwm_oc.map, mapping_free );
-       avl_free( lt->rwmap.rwm_at.remap, NULL );
-       avl_free( lt->rwmap.rwm_at.map, mapping_free );
+       avl_free( lt->mt_rwmap.rwm_oc.remap, NULL );
+       avl_free( lt->mt_rwmap.rwm_oc.map, mapping_free );
+       avl_free( lt->mt_rwmap.rwm_at.remap, NULL );
+       avl_free( lt->mt_rwmap.rwm_at.map, mapping_free );
 }
 
 int
@@ -238,3 +222,11 @@ meta_back_db_destroy(
        return 0;
 }
 
+#if SLAPD_META == SLAPD_MOD_DYNAMIC
+
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( meta )
+
+#endif /* SLAPD_META == SLAPD_MOD_DYNAMIC */
+
+