fix dynamically registered controls check; NOTE: controls registered by global overlays don't work yet; better leave Kurt's kludge in place right now

This commit is contained in:
Pierangelo Masarati 2005-01-25 19:39:56 +00:00
parent 0bd2dafd53
commit 5b193c218f
8 changed files with 107 additions and 4 deletions

View File

@ -541,6 +541,16 @@ ldap_chain_db_init(
return rc;
}
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
static int
ldap_chain_db_open(
BackendDB *be
)
{
return overlay_register_control( be, LDAP_CONTROL_X_CHAINING_BEHAVIOR );
}
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
static int
ldap_chain_db_destroy(
BackendDB *be
@ -694,7 +704,7 @@ chain_init( void )
int rc;
rc = register_supported_control( LDAP_CONTROL_X_CHAINING_BEHAVIOR,
SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE, NULL,
SLAP_CTRL_FRONTEND|SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE, NULL,
ldap_chain_parse_ctrl, &sc_chainingBehavior );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "Failed to register chaining behavior control: %d\n", rc );
@ -704,6 +714,9 @@ chain_init( void )
ldapchain.on_bi.bi_type = "chain";
ldapchain.on_bi.bi_db_init = ldap_chain_db_init;
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
ldapchain.on_bi.bi_db_open = ldap_chain_db_open;
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
ldapchain.on_bi.bi_db_config = ldap_chain_db_config;
ldapchain.on_bi.bi_db_destroy = ldap_chain_db_destroy;

View File

@ -410,6 +410,9 @@ int backend_destroy(void)
free( bd->be_rootpw.bv_val );
}
acl_destroy( bd->be_acl, frontendDB->be_acl );
if ( bd->be_controls ) {
ldap_charray_free( bd->be_controls );
}
}
free( backendDB );
@ -500,6 +503,11 @@ backend_db_init(
be = &backends[nbackends++];
be->bd_info = bi;
if ( bi->bi_controls ) {
be->be_controls = ldap_charray_dup( bi->bi_controls );
}
be->be_def_limit = frontendDB->be_def_limit;
be->be_dfltaccess = frontendDB->be_dfltaccess;

View File

@ -467,6 +467,66 @@ overlay_is_inst( BackendDB *be, const char *over_type )
return 0;
}
#if 0
int
overlay_is_global( BackendDB *be )
{
BackendInfo *frontendBI;
if ( !overlay_is_over( be ) ) {
return 0;
}
frontendBI = frontendDB->bd_info;
if ( overlay_is_over( frontendDB ) ) {
frontendBI = ((slap_overinfo *)frontendBI->bi_private)->oi_orig;
}
return ((slap_overinfo *)be->bd_info->bi_private)->oi_orig == frontendBI;
}
#endif
int
overlay_register_control( BackendDB *be, const char *oid )
{
int rc = 0;
int gotit = 0;
#if 0
if ( overlay_is_global( be ) ) {
int i;
/* add to all backends... */
for ( i = 0; i < nBackendDB; i++ ) {
BackendDB *bd = &backendDB[i];
if ( be == bd ) {
gotit = 1;
}
if ( bd->be_controls == NULL ||
!ldap_charray_inlist( bd->be_controls, oid ) )
{
rc = ldap_charray_add( &be->be_controls, oid );
if ( rc ) {
break;
}
}
}
}
#endif
if ( rc == 0 && !gotit && !ldap_charray_inlist( be->be_controls, oid ) ) {
rc = ldap_charray_add( &be->be_controls, oid );
if ( rc ) {
return rc;
}
}
return rc;
}
/* add an overlay to a particular backend. */
int
overlay_config( BackendDB *be, const char *ov )

View File

@ -42,8 +42,8 @@
#include "slapi/slapi.h"
#endif
BackendInfo slap_frontendInfo;
BackendDB slap_frontendDB;
static BackendInfo slap_frontendInfo;
static BackendDB slap_frontendDB;
BackendDB *frontendDB;
int
@ -87,6 +87,7 @@ frontend_init( void )
/* known controls */
frontendDB->bd_info->bi_controls = slap_known_controls;
frontendDB->be_controls = ldap_charray_dup( slap_known_controls );
/* calls */
frontendDB->bd_info->bi_op_abandon = fe_op_abandon;

View File

@ -1706,6 +1706,14 @@ ppolicy_db_init(
return 0;
}
static int
ppolicy_db_open(
BackendDB *be
)
{
return overlay_register_control( be, LDAP_CONTROL_PASSWORDPOLICYREQUEST );
}
static int
ppolicy_close(
BackendDB *be
@ -1813,6 +1821,7 @@ int ppolicy_init()
ppolicy.on_bi.bi_type = "ppolicy";
ppolicy.on_bi.bi_db_init = ppolicy_db_init;
ppolicy.on_bi.bi_db_open = ppolicy_db_open;
ppolicy.on_bi.bi_db_config = ppolicy_config;
ppolicy.on_bi.bi_db_close = ppolicy_close;

View File

@ -2012,6 +2012,11 @@ syncprov_db_open(
Attribute *a;
int rc;
rc = overlay_register_control( be, LDAP_CONTROL_SYNC );
if ( rc ) {
return rc;
}
connection_fake_init( &conn, op, thrctx );
op->o_bd = be;
op->o_dn = be->be_rootdn;

View File

@ -315,6 +315,9 @@ LDAP_SLAPD_F (slap_overinst *) overlay_next LDAP_P(( slap_overinst *on ));
LDAP_SLAPD_F (slap_overinst *) overlay_find LDAP_P(( const char *name ));
LDAP_SLAPD_F (int) overlay_is_over LDAP_P(( BackendDB *be ));
LDAP_SLAPD_F (int) overlay_is_inst LDAP_P(( BackendDB *be, const char *name ));
LDAP_SLAPD_F (int) overlay_register_control LDAP_P((
BackendDB *be,
const char *oid ));
/*
* ch_malloc.c

View File

@ -1564,7 +1564,11 @@ struct slap_backend_db {
*/
#define be_has_subordinates bd_info->bi_has_subordinates
#define be_controls bd_info->bi_controls
/* supported controls */
/* NOTE: this stores a duplicate of the control OIDs as listed
* in bd_info->bi_controls at database startup; later on,
* controls may be added run-time, e.g. by overlays */
char **be_controls;
#define be_connection_init bd_info->bi_connection_init
#define be_connection_destroy bd_info->bi_connection_destroy