mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-24 13:24:56 +08:00
More SLAPI cleanups
This commit is contained in:
parent
bb04c4eb9d
commit
1254419f16
@ -30,15 +30,8 @@ LDAP_SLAPI_F (LDAPMod **) slapi_int_modifications2ldapmods LDAP_P(( Modification
|
||||
LDAP_SLAPI_F (Modifications *) slapi_int_ldapmods2modifications LDAP_P(( LDAPMod **, void *ctx ));
|
||||
LDAP_SLAPI_F (void) slapi_int_free_ldapmods LDAP_P(( LDAPMod ** ));
|
||||
LDAP_SLAPI_F (int) slapi_int_count_controls LDAP_P(( LDAPControl **ctrls ));
|
||||
|
||||
LDAP_SLAPI_F (int) slapi_int_access_allowed LDAP_P((Operation *op,
|
||||
Entry *entry,
|
||||
AttributeDescription *desc,
|
||||
struct berval *val,
|
||||
slap_access_t access,
|
||||
AccessControlState *state ));
|
||||
|
||||
LDAP_SLAPI_F (char **) slapi_get_supported_extended_ops LDAP_P((void));
|
||||
LDAP_SLAPI_F (int) slapi_int_access_allowed LDAP_P((Operation *op, Entry *entry, AttributeDescription *desc, struct berval *val, slap_access_t access, AccessControlState *state ));
|
||||
|
||||
/* slapi_ops.c */
|
||||
LDAP_SLAPI_F (int) slapi_int_response LDAP_P(( Slapi_Operation *op, SlapReply *rs ));
|
||||
@ -53,10 +46,14 @@ LDAP_SLAPI_F (void) slapi_int_mods_free( Modifications *ml );
|
||||
LDAP_SLAPI_F (int) slapi_int_pblock_get_first LDAP_P(( Backend *be, Slapi_PBlock **pb ));
|
||||
LDAP_SLAPI_F (int) slapi_int_pblock_get_next LDAP_P(( Slapi_PBlock **pb ));
|
||||
|
||||
#define PBLOCK_ASSERT_OP( _pb, _tag ) do { \
|
||||
#define PBLOCK_ASSERT_CONN( _pb ) do { \
|
||||
assert( (_pb) != NULL ); \
|
||||
assert( (_pb)->pop != NULL ); \
|
||||
assert( (_pb)->pconn != NULL ); \
|
||||
} while (0)
|
||||
|
||||
#define PBLOCK_ASSERT_OP( _pb, _tag ) do { \
|
||||
PBLOCK_ASSERT_CONN( _pb ); \
|
||||
assert( (_pb)->pop != NULL ); \
|
||||
if ( _tag != 0 ) \
|
||||
assert( (_pb)->pop->o_tag == (_tag)); \
|
||||
} while (0)
|
||||
|
@ -127,14 +127,7 @@ struct slapi_pblock {
|
||||
|
||||
#define SLAPI_PLUGIN_IS_POST_FN(x) ((x) >= SLAPI_PLUGIN_POST_BIND_FN && (x) <= SLAPI_PLUGIN_BE_POST_DELETE_FN)
|
||||
|
||||
#define SLAPI_OPERATION_PARAMETERS 138
|
||||
|
||||
#define SLAPI_PLUGIN_DB_TEST_FN 227
|
||||
#define SLAPI_PLUGIN_DB_NO_ACL 250
|
||||
|
||||
/* DS 5.x Computed Attribute Callbacks (not exposed) */
|
||||
#define SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN 1200
|
||||
#define SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN 1201
|
||||
#define SLAPI_IBM_PBLOCK -3
|
||||
|
||||
#define SLAPI_ENTRY_PRE_OP 52
|
||||
#define SLAPI_ENTRY_POST_OP 53
|
||||
@ -144,6 +137,8 @@ struct slapi_pblock {
|
||||
|
||||
#define SLAPI_ABANDON_MSGID 120
|
||||
|
||||
#define SLAPI_OPERATION_PARAMETERS 138
|
||||
|
||||
#define SLAPI_SEQ_TYPE 150
|
||||
#define SLAPI_SEQ_ATTRNAME 151
|
||||
#define SLAPI_SEQ_VAL 152
|
||||
@ -167,7 +162,13 @@ struct slapi_pblock {
|
||||
|
||||
#define SLAPI_DBSIZE 199
|
||||
|
||||
/* really private stuff */
|
||||
#define SLAPI_PLUGIN_DB_TEST_FN 227
|
||||
#define SLAPI_PLUGIN_DB_NO_ACL 250
|
||||
|
||||
/* OpenLDAP private parametrs */
|
||||
#define SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN 1200
|
||||
#define SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN 1201
|
||||
|
||||
#define SLAPI_X_CONFIG_ARGV 1400
|
||||
#define SLAPI_X_INTOP_FLAGS 1401
|
||||
#define SLAPI_X_INTOP_RESULT_CALLBACK 1402
|
||||
@ -176,8 +177,6 @@ struct slapi_pblock {
|
||||
#define SLAPI_X_INTOP_CALLBACK_DATA 1405
|
||||
#define SLAPI_X_OLD_RESCONTROLS 1406
|
||||
|
||||
#define SLAPI_IBM_PBLOCK -3
|
||||
|
||||
LDAP_SLAPI_V (ldap_pvt_thread_mutex_t) slapi_hn_mutex;
|
||||
LDAP_SLAPI_V (ldap_pvt_thread_mutex_t) slapi_time_mutex;
|
||||
LDAP_SLAPI_V (ldap_pvt_thread_mutex_t) slapi_printmessage_mutex;
|
||||
|
@ -30,10 +30,11 @@
|
||||
#include <ac/ctype.h>
|
||||
#include <ac/unistd.h>
|
||||
|
||||
#ifdef LDAP_SLAPI
|
||||
|
||||
#include <slap.h>
|
||||
#include <slapi.h>
|
||||
|
||||
#ifdef LDAP_SLAPI
|
||||
/*
|
||||
* Object extensions
|
||||
*
|
||||
@ -134,7 +135,6 @@ static void free_extension(struct slapi_extension_block *eblock, int objecttype,
|
||||
|
||||
void *slapi_get_object_extension(int objecttype, void *object, int extensionhandle)
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
struct slapi_extension_block *eblock;
|
||||
void *parent;
|
||||
|
||||
@ -147,14 +147,10 @@ void *slapi_get_object_extension(int objecttype, void *object, int extensionhand
|
||||
}
|
||||
|
||||
return NULL;
|
||||
#else
|
||||
return NULL;
|
||||
#endif /* LDAP_SLAPI */
|
||||
}
|
||||
|
||||
void slapi_set_object_extension(int objecttype, void *object, int extensionhandle, void *extension)
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
struct slapi_extension_block *eblock;
|
||||
void *parent;
|
||||
|
||||
@ -169,7 +165,6 @@ void slapi_set_object_extension(int objecttype, void *object, int extensionhandl
|
||||
/* constructed by caller */
|
||||
eblock->extensions[extensionhandle] = extension;
|
||||
}
|
||||
#endif /* LDAP_SLAPI */
|
||||
}
|
||||
|
||||
int slapi_register_object_extension(
|
||||
@ -180,7 +175,6 @@ int slapi_register_object_extension(
|
||||
int *objecttype,
|
||||
int *extensionhandle)
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
int rc;
|
||||
slapi_extension_t type;
|
||||
struct slapi_registered_extension *re;
|
||||
@ -228,14 +222,10 @@ int slapi_register_object_extension(
|
||||
ldap_pvt_thread_mutex_unlock( ®istered_extensions.mutex );
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return -1;
|
||||
#endif /* LDAP_SLAPI */
|
||||
}
|
||||
|
||||
int slapi_int_create_object_extensions(int objecttype, void *object)
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
int i;
|
||||
struct slapi_extension_block *eblock;
|
||||
void **peblock;
|
||||
@ -281,14 +271,10 @@ int slapi_int_create_object_extensions(int objecttype, void *object)
|
||||
*peblock = eblock;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int slapi_int_free_object_extensions(int objecttype, void *object)
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
int i;
|
||||
struct slapi_extension_block *eblock;
|
||||
void **peblock;
|
||||
@ -321,15 +307,11 @@ int slapi_int_free_object_extensions(int objecttype, void *object)
|
||||
slapi_ch_free( peblock );
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* for reusable object types */
|
||||
int slapi_int_clear_object_extensions(int objecttype, void *object)
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
int i;
|
||||
struct slapi_extension_block *eblock;
|
||||
void *parent;
|
||||
@ -352,14 +334,10 @@ int slapi_int_clear_object_extensions(int objecttype, void *object)
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int slapi_int_init_object_extensions(void)
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
memset( ®istered_extensions, 0, sizeof( registered_extensions ) );
|
||||
|
||||
if ( ldap_pvt_thread_mutex_init( ®istered_extensions.mutex ) != 0 ) {
|
||||
@ -367,7 +345,6 @@ int slapi_int_init_object_extensions(void)
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* LDAP_SLAPI */
|
||||
|
@ -459,7 +459,7 @@ pblock_get( Slapi_PBlock *pb, int param, void **value )
|
||||
*((slap_ssf_t *)value) = pb->pconn->c_ssf;
|
||||
break;
|
||||
case SLAPI_X_CONN_SASL_CONTEXT:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
if ( pb->pconn->c_sasl_authctx != NULL )
|
||||
*value = pb->pconn->c_sasl_authctx;
|
||||
else
|
||||
@ -479,7 +479,7 @@ pblock_get( Slapi_PBlock *pb, int param, void **value )
|
||||
break;
|
||||
case SLAPI_CONN_AUTHTYPE:
|
||||
case SLAPI_CONN_AUTHMETHOD: /* XXX should return SASL mech */
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
*((char **)value) = pblock_get_authtype( &pb->pconn->c_authz,
|
||||
#ifdef HAVE_TLS
|
||||
pb->pconn->c_is_tls
|
||||
@ -489,7 +489,7 @@ pblock_get( Slapi_PBlock *pb, int param, void **value )
|
||||
);
|
||||
break;
|
||||
case SLAPI_X_CONN_IS_UDP:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
*((int *)value) = pb->pconn->c_is_udp;
|
||||
#else
|
||||
@ -497,36 +497,36 @@ pblock_get( Slapi_PBlock *pb, int param, void **value )
|
||||
#endif
|
||||
break;
|
||||
case SLAPI_CONN_ID:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
*((unsigned long *)value) = pb->pconn->c_connid;
|
||||
break;
|
||||
case SLAPI_CONN_DN:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
*((char **)value) = pb->pconn->c_dn.bv_val;
|
||||
break;
|
||||
case SLAPI_CONN_CLIENTIP:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
if ( strncmp( pb->pconn->c_peer_name.bv_val, "IP=", 3 ) == 0 )
|
||||
*((char **)value) = &pb->pconn->c_peer_name.bv_val[3];
|
||||
else
|
||||
*value = NULL;
|
||||
break;
|
||||
case SLAPI_X_CONN_CLIENTPATH:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
if ( strncmp( pb->pconn->c_peer_name.bv_val, "PATH=", 3 ) == 0 )
|
||||
*((char **)value) = &pb->pconn->c_peer_name.bv_val[5];
|
||||
else
|
||||
*value = NULL;
|
||||
break;
|
||||
case SLAPI_CONN_SERVERIP:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
if ( strncmp( pb->pconn->c_peer_name.bv_val, "IP=", 3 ) == 0 )
|
||||
*((char **)value) = &pb->pconn->c_sock_name.bv_val[3];
|
||||
else
|
||||
*value = NULL;
|
||||
break;
|
||||
case SLAPI_X_CONN_SERVERPATH:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
if ( strncmp( pb->pconn->c_peer_name.bv_val, "PATH=", 3 ) == 0 )
|
||||
*((char **)value) = &pb->pconn->c_sock_name.bv_val[5];
|
||||
else
|
||||
@ -691,6 +691,12 @@ pblock_get( Slapi_PBlock *pb, int param, void **value )
|
||||
else
|
||||
*value = NULL;
|
||||
break;
|
||||
case SLAPI_ABANDON_MSGID:
|
||||
if ( pb->pop->o_tag == LDAP_REQ_ABANDON )
|
||||
*((int *)value) = pb->pop->orn_msgid;
|
||||
else
|
||||
*((int *)value) = 0;
|
||||
break;
|
||||
default:
|
||||
rc = pblock_get_default( pb, param, value );
|
||||
break;
|
||||
@ -801,13 +807,13 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
|
||||
pb->pconn = (Connection *)value;
|
||||
break;
|
||||
case SLAPI_X_CONN_SSF:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
PBLOCK_LOCK_CONN( pb );
|
||||
pb->pconn->c_ssf = (slap_ssf_t)value;
|
||||
PBLOCK_UNLOCK_CONN( pb );
|
||||
break;
|
||||
case SLAPI_X_CONN_SASL_CONTEXT:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
PBLOCK_LOCK_CONN( pb );
|
||||
pb->pconn->c_sasl_authctx = value;
|
||||
PBLOCK_UNLOCK_CONN( pb );
|
||||
@ -817,13 +823,13 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
|
||||
rc = pblock_set_dn( value, &pb->pop->o_req_dn, &pb->pop->o_req_ndn, pb->pop->o_tmpmemctx );
|
||||
break;
|
||||
case SLAPI_CONN_ID:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
PBLOCK_LOCK_CONN( pb );
|
||||
pb->pconn->c_connid = (unsigned long)value;
|
||||
PBLOCK_UNLOCK_CONN( pb );
|
||||
break;
|
||||
case SLAPI_CONN_DN:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_ASSERT_CONN( pb );
|
||||
PBLOCK_LOCK_CONN( pb );
|
||||
rc = pblock_set_dn( value, &pb->pconn->c_dn, &pb->pconn->c_ndn, NULL );
|
||||
PBLOCK_UNLOCK_CONN( pb );
|
||||
@ -963,11 +969,10 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
|
||||
break;
|
||||
case SLAPI_SEARCH_FILTER:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
if ( pb->pop->o_tag == LDAP_REQ_SEARCH ) {
|
||||
if ( pb->pop->o_tag == LDAP_REQ_SEARCH )
|
||||
pb->pop->ors_filter = (Slapi_Filter *)value;
|
||||
} else {
|
||||
else
|
||||
rc = PBLOCK_ERROR;
|
||||
}
|
||||
break;
|
||||
case SLAPI_SEARCH_STRFILTER:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
@ -1097,11 +1102,19 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_VALIDATE_IS_INTOP( pb );
|
||||
|
||||
if ( pb->pop->o_tag == LDAP_REQ_COMPARE ) {
|
||||
if ( pb->pop->o_tag == LDAP_REQ_COMPARE )
|
||||
pb->pop->orc_ava->aa_value = *((struct berval *)value);
|
||||
} else {
|
||||
else
|
||||
rc = PBLOCK_ERROR;
|
||||
break;
|
||||
case SLAPI_ABANDON_MSGID:
|
||||
PBLOCK_ASSERT_OP( pb, 0 );
|
||||
PBLOCK_VALIDATE_IS_INTOP( pb );
|
||||
|
||||
if ( pb->pop->o_tag == LDAP_REQ_ABANDON)
|
||||
pb->pop->orn_msgid = *((int *)value);
|
||||
else
|
||||
rc = PBLOCK_ERROR;
|
||||
}
|
||||
break;
|
||||
case SLAPI_REQUESTOR_ISROOT:
|
||||
case SLAPI_REQUESTOR_ISUPDATEDN:
|
||||
@ -1112,6 +1125,7 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
|
||||
case SLAPI_X_CONN_CLIENTPATH:
|
||||
case SLAPI_CONN_SERVERIP:
|
||||
case SLAPI_X_CONN_SERVERPATH:
|
||||
/* These parameters cannot be set */
|
||||
rc = PBLOCK_ERROR;
|
||||
break;
|
||||
default:
|
||||
@ -1180,40 +1194,44 @@ slapi_pblock_new(void)
|
||||
return pb;
|
||||
}
|
||||
|
||||
void
|
||||
slapi_pblock_destroy( Slapi_PBlock* pb )
|
||||
static void
|
||||
pblock_destroy( Slapi_PBlock *pb )
|
||||
{
|
||||
LDAPControl **controls = NULL;
|
||||
LDAPMod **mods = NULL;
|
||||
char **attrs = NULL;
|
||||
|
||||
assert( pb != NULL );
|
||||
|
||||
if ( pb->internal_op ) {
|
||||
slapi_int_connection_done_pb( pb );
|
||||
} else {
|
||||
LDAPMod **mods = NULL;
|
||||
char **attrs = NULL;
|
||||
|
||||
pblock_get_default( pb, SLAPI_MODIFY_MODS, (void **)&mods );
|
||||
|
||||
if ( mods != NULL )
|
||||
slapi_int_free_ldapmods( mods );
|
||||
|
||||
pblock_get_default( pb, SLAPI_SEARCH_ATTRS, (void **)&attrs );
|
||||
|
||||
if ( attrs != NULL )
|
||||
pb->pop->o_tmpfree( attrs, pb->pop->o_tmpmemctx );
|
||||
}
|
||||
|
||||
pblock_get_default( pb, SLAPI_RESCONTROLS, (void **)&controls );
|
||||
if ( controls != NULL ) {
|
||||
ldap_controls_free( controls );
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_destroy( &pb->pblockMutex );
|
||||
if ( pb->internal_op ) {
|
||||
slapi_int_connection_done_pb( pb );
|
||||
} else {
|
||||
pblock_get_default( pb, SLAPI_MODIFY_MODS, (void **)&mods );
|
||||
if ( mods != NULL )
|
||||
slapi_int_free_ldapmods( mods );
|
||||
|
||||
pblock_get_default( pb, SLAPI_SEARCH_ATTRS, (void **)&attrs );
|
||||
if ( attrs != NULL )
|
||||
pb->pop->o_tmpfree( attrs, pb->pop->o_tmpmemctx );
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_destroy( &pb->pblockMutex );
|
||||
slapi_ch_free( (void **)&pb );
|
||||
}
|
||||
|
||||
void
|
||||
slapi_pblock_destroy( Slapi_PBlock *pb )
|
||||
{
|
||||
if ( pb != NULL ) {
|
||||
pblock_destroy( pb );
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value )
|
||||
{
|
||||
|
@ -665,7 +665,6 @@ slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value)
|
||||
return slapi_entry_delete_values_sv( e, type, vals );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals )
|
||||
{
|
||||
@ -3331,7 +3330,7 @@ LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared )
|
||||
|
||||
void slapi_ldap_unbind( LDAP *ld )
|
||||
{
|
||||
ldap_unbind( ld );
|
||||
ldap_unbind_ext_s( ld, NULL, NULL );
|
||||
}
|
||||
|
||||
int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags )
|
||||
|
Loading…
Reference in New Issue
Block a user