Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.4
openldap2.import4093
0011-Fix-exposure-of-SSS-VLV-controls-ITS-6647-dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0011-Fix-exposure-of-SSS-VLV-controls-ITS-6647-dif of Package openldap2.import4093
From 829dc9ac421c3a69e20b016f405d93ff263f124f Mon Sep 17 00:00:00 2001 From: ralf <ralf> Date: Fri, 22 Jan 2010 17:01:25 +0000 Subject: Fix exposure of SSS/VLV controls (ITS#6647) Fixes bnc#648479 Contains the following upstream commits: - plugged one time memory leak (found with valgrind) - Quit send loops if slapd is shutting down - make sure so is correctly initialized (spotted by valgrind, possibly related to ITS#6649) - do not expose control until sssvlv overlay is actually instantiated at least once (ITS#6647) - ITS#6685 fix result code tag - Unregister VLV control as well when last overlay instance is removed (additional fix for ITS#6647) diff --git a/servers/slapd/overlays/sssvlv.c b/servers/slapd/overlays/sssvlv.c index 10dde1f..38e9e2d 100644 --- a/servers/slapd/overlays/sssvlv.c +++ b/servers/slapd/overlays/sssvlv.c @@ -198,7 +198,7 @@ static int pack_vlv_response_control( ber_init2( ber, NULL, LBER_USE_DER ); ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx ); - rc = ber_printf( ber, "{iii", so->so_vlv_target, so->so_nentries, + rc = ber_printf( ber, "{iie", so->so_vlv_target, so->so_nentries, so->so_vlv_rc ); if ( rc != -1 && so->so_vcontext ) { @@ -801,9 +801,9 @@ static int sssvlv_op_search( op->o_tmpmemctx ); /* Install serversort response callback to handle a new search */ if ( ps || vc ) { - so = ch_malloc( sizeof(sort_op)); + so = ch_calloc( 1, sizeof(sort_op)); } else { - so = op->o_tmpalloc( sizeof(sort_op), op->o_tmpmemctx ); + so = op->o_tmpcalloc( 1, sizeof(sort_op), op->o_tmpmemctx ); } sort_conns[op->o_conn->c_conn_idx] = so; @@ -1158,6 +1158,38 @@ static int sssvlv_db_init( { slap_overinst *on = (slap_overinst *)be->bd_info; sssvlv_info *si; + + if ( ov_count == 0 ) { + int rc; + + rc = register_supported_control2( LDAP_CONTROL_SORTREQUEST, + SLAP_CTRL_SEARCH, + NULL, + sss_parseCtrl, + 1 /* replace */, + &sss_cid ); + if ( rc != LDAP_SUCCESS ) { + Debug( LDAP_DEBUG_ANY, "Failed to register Sort Request control '%s' (%d)\n", + LDAP_CONTROL_SORTREQUEST, rc, 0 ); + return rc; + } + + rc = register_supported_control2( LDAP_CONTROL_VLVREQUEST, + SLAP_CTRL_SEARCH, + NULL, + vlv_parseCtrl, + 1 /* replace */, + &vlv_cid ); + if ( rc != LDAP_SUCCESS ) { + Debug( LDAP_DEBUG_ANY, "Failed to register VLV Request control '%s' (%d)\n", + LDAP_CONTROL_VLVREQUEST, rc, 0 ); +#ifdef SLAP_CONFIG_DELETE + overlay_unregister_control( be, LDAP_CONTROL_SORTREQUEST ); + unregister_supported_control( LDAP_CONTROL_SORTREQUEST ); +#endif /* SLAP_CONFIG_DELETE */ + return rc; + } + } si = (sssvlv_info *)ch_malloc(sizeof(sssvlv_info)); on->on_bi.bi_private = si; @@ -1183,14 +1215,23 @@ static int sssvlv_db_destroy( { slap_overinst *on = (slap_overinst *)be->bd_info; sssvlv_info *si = (sssvlv_info *)on->on_bi.bi_private; - + ov_count--; if ( !ov_count && sort_conns) { sort_conns--; ch_free(sort_conns); ldap_pvt_thread_mutex_destroy( &sort_conns_mutex ); } - + +#ifdef SLAP_CONFIG_DELETE + overlay_unregister_control( be, LDAP_CONTROL_SORTREQUEST ); + overlay_unregister_control( be, LDAP_CONTROL_VLVREQUEST ); + if ( ov_count == 0 ) { + unregister_supported_control( LDAP_CONTROL_SORTREQUEST ); + unregister_supported_control( LDAP_CONTROL_VLVREQUEST ); + } +#endif /* SLAP_CONFIG_DELETE */ + if ( si ) { ch_free( si ); on->on_bi.bi_private = NULL; @@ -1217,30 +1258,9 @@ int sssvlv_initialize() if ( rc ) return rc; - rc = register_supported_control2( LDAP_CONTROL_SORTREQUEST, - SLAP_CTRL_SEARCH, - NULL, - sss_parseCtrl, - 1 /* replace */, - &sss_cid ); - - if ( rc == LDAP_SUCCESS ) { - rc = register_supported_control2( LDAP_CONTROL_VLVREQUEST, - SLAP_CTRL_SEARCH, - NULL, - vlv_parseCtrl, - 1 /* replace */, - &vlv_cid ); - } - - if ( rc == LDAP_SUCCESS ) { - rc = overlay_register( &sssvlv ); - if ( rc != LDAP_SUCCESS ) { - Debug( LDAP_DEBUG_ANY, "Failed to register server side sort overlay\n", 0, 0, 0 ); - } - } - else { - Debug( LDAP_DEBUG_ANY, "Failed to register control %d\n", rc, 0, 0 ); + rc = overlay_register( &sssvlv ); + if ( rc != LDAP_SUCCESS ) { + Debug( LDAP_DEBUG_ANY, "Failed to register server side sort overlay\n", 0, 0, 0 ); } return rc; -- 1.7.3.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor