X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-meta%2Finit.c;h=e7883ce14738fb4077c9eda321983e02961997d3;hb=8d14165274b244d6f91587502bd0a23ec7b08a87;hp=0598fac873f9941595f101e9809edd1a1620b4ed;hpb=975a5e9a24e971197baa9ea2d4479100977c9060;p=openldap diff --git a/servers/slapd/back-meta/init.c b/servers/slapd/back-meta/init.c index 0598fac873..e7883ce147 100644 --- a/servers/slapd/back-meta/init.c +++ b/servers/slapd/back-meta/init.c @@ -1,101 +1,46 @@ -/* - * Copyright 1998-2001 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . * - * Copyright 2001, Pierangelo Masarati, All rights reserved. + * Copyright 1999-2005 The OpenLDAP Foundation. + * Portions Copyright 2001-2003 Pierangelo Masarati. + * Portions Copyright 1999-2003 Howard Chu. + * All rights reserved. * - * This work has been developed to fulfill the requirements - * of SysNet s.n.c. and it has been donated - * to the OpenLDAP Foundation in the hope that it may be useful - * to the Open Source community, but WITHOUT ANY WARRANTY. - * - * Permission is granted to anyone to use this software for any purpose - * on any computer system, and to alter it and redistribute it, subject - * to the following restrictions: - * - * 1. The author and SysNet s.n.c. are not responsible for the consequences - * of use of this software, no matter how awful, even if they arise from - * flaws in it. - * - * 2. The origin of this software must not be misrepresented, either by - * explicit claim or by omission. Since few users ever read sources, - * credits should appear in the documentation. - * - * 3. Altered versions must be plainly marked as such, and must not be - * misrepresented as being the original software. Since few users - * ever read sources, credits should appear in the documentation. - * SysNet s.n.c. cannot be responsible for the consequences of the - * alterations. - * - * 4. This notice may not be removed or altered. - * - * - * This software is based on the backend back-ldap, implemented - * by Howard Chu , and modified by Mark Valence - * , Pierangelo Masarati and other - * contributors. The contribution of the original software to the present - * implementation is acknowledged in this copyright statement. - * - * A special acknowledgement goes to Howard for the overall architecture - * (and for borrowing large pieces of code), and to Mark, who implemented - * from scratch the attribute/objectclass mapping. - * - * The original copyright statement follows. - * - * Copyright 1999, Howard Chu, All rights reserved. - * - * Permission is granted to anyone to use this software for any purpose - * on any computer system, and to alter it and redistribute it, subject - * to the following restrictions: - * - * 1. The author is not responsible for the consequences of use of this - * software, no matter how awful, even if they arise from flaws in it. - * - * 2. The origin of this software must not be misrepresented, either by - * explicit claim or by omission. Since few users ever read sources, - * credits should appear in the documentation. - * - * 3. Altered versions must be plainly marked as such, and must not be - * misrepresented as being the original software. Since few users - * ever read sources, credits should appear in the - * documentation. - * - * 4. This notice may not be removed or altered. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . */ #include "portable.h" #include +#include #include #include "slap.h" #include "../back-ldap/back-ldap.h" #include "back-meta.h" -#ifdef SLAPD_META_DYNAMIC - int -back_meta_LTX_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; +meta_back_open( + BackendInfo *bi +) +{ + bi->bi_controls = slap_known_controls; + return 0; } -#endif /* SLAPD_META_DYNAMIC */ - int meta_back_initialize( BackendInfo *bi ) { - bi->bi_open = 0; + bi->bi_open = meta_back_open; bi->bi_config = 0; bi->bi_close = 0; bi->bi_destroy = 0; @@ -118,8 +63,6 @@ meta_back_initialize( bi->bi_extended = 0; - bi->bi_acl_group = meta_back_group; - bi->bi_acl_attribute = meta_back_attribute; bi->bi_chk_referrals = 0; bi->bi_connection_init = 0; @@ -135,16 +78,25 @@ meta_back_db_init( { struct metainfo *li; + struct rewrite_info *rwinfo; + + rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT ); + if ( rwinfo == NULL ) { + return -1; + } + li = ch_calloc( 1, sizeof( struct metainfo ) ); if ( li == NULL ) { + rewrite_info_delete( &rwinfo ); return -1; } - + /* * At present the default is no default target; * this may change */ li->defaulttarget = META_DEFAULT_TARGET_NONE; + li->rwinfo = rwinfo; ldap_pvt_thread_mutex_init( &li->conn_mutex ); ldap_pvt_thread_mutex_init( &li->cache.mutex ); @@ -155,57 +107,71 @@ meta_back_db_init( static void conn_free( - struct metaconn *lc + void *v_lc ) { - struct metasingleconn **lsc; + struct metaconn *lc = v_lc; + struct metasingleconn *lsc; - for ( lsc = lc->conns; lsc[ 0 ] != NULL; lsc++ ) { - if ( lsc[ 0 ]->ld != NULL ) { - ldap_unbind( lsc[ 0 ]->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 ( !BER_BVISNULL( &lsc->msc_bound_ndn ) ) { + ber_memfree( lsc->msc_bound_ndn.bv_val ); } - if ( lsc[ 0 ]->bound_dn ) { - ber_bvfree( lsc[ 0 ]->bound_dn ); + 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( lsc[ 0 ] ); } - free( lc->conns ); + free( lc->mc_conns ); free( lc ); } +static void +mapping_free( void *v_mapping ) +{ + struct ldapmapping *mapping = v_mapping; + ch_free( mapping->src.bv_val ); + ch_free( mapping->dst.bv_val ); + ch_free( mapping ); +} + static void 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( <->mt_psuffix ) ) { + free( lt->mt_psuffix.bv_val ); } - if ( lt->suffix.bv_val ) { - free( lt->suffix.bv_val ); + if ( !BER_BVISNULL( <->mt_nsuffix ) ) { + free( lt->mt_nsuffix.bv_val ); } - if ( lt->binddn ) { - ber_bvfree( lt->binddn ); + if ( !BER_BVISNULL( <->mt_binddn ) ) { + free( lt->mt_binddn.bv_val ); } - if ( lt->bindpw ) { - ber_bvfree( lt->bindpw ); + if ( !BER_BVISNULL( <->mt_bindpw ) ) { + free( lt->mt_bindpw.bv_val ); } - if ( lt->pseudorootdn ) { - ber_bvfree( lt->pseudorootdn ); + if ( !BER_BVISNULL( <->mt_pseudorootdn ) ) { + free( lt->mt_pseudorootdn.bv_val ); } - if ( lt->pseudorootpw ) { - ber_bvfree( lt->pseudorootpw ); + if ( !BER_BVISNULL( <->mt_pseudorootpw ) ) { + free( lt->mt_pseudorootpw.bv_val ); } - if ( lt->rwinfo ) { - rewrite_info_delete( lt->rwinfo ); + if ( lt->mt_rwmap.rwm_rw ) { + rewrite_info_delete( <->mt_rwmap.rwm_rw ); } - avl_free( lt->oc_map.remap, NULL ); - avl_free( lt->oc_map.map, ( AVL_FREE )mapping_free ); - avl_free( lt->at_map.remap, NULL ); - avl_free( lt->at_map.map, ( AVL_FREE )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 @@ -226,13 +192,9 @@ meta_back_db_destroy( ldap_pvt_thread_mutex_lock( &li->conn_mutex ); if ( li->conntree ) { - avl_free( li->conntree, - ( AVL_FREE )conn_free ); + avl_free( li->conntree, conn_free ); } - ldap_pvt_thread_mutex_unlock( &li->cache.mutex ); - ldap_pvt_thread_mutex_destroy( &li->cache.mutex ); - /* * Destroy the per-target stuff (assuming there's at * least one ...) @@ -246,17 +208,25 @@ meta_back_db_destroy( ldap_pvt_thread_mutex_lock( &li->cache.mutex ); if ( li->cache.tree ) { - avl_free( li->cache.tree, - ( AVL_FREE )meta_dncache_free ); + avl_free( li->cache.tree, meta_dncache_free ); } ldap_pvt_thread_mutex_unlock( &li->cache.mutex ); ldap_pvt_thread_mutex_destroy( &li->cache.mutex ); - + ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); + ldap_pvt_thread_mutex_destroy( &li->conn_mutex ); } free( be->be_private ); 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 */ + +