Conform SLAPI to Netscape, iPlanet and Sun ONE Directory Server

behaviour:

1. Plugins never return LDAP result codes, instead they return a
   small integer (0 or -1, others for special cases)
2. Preoperation plugins can abort processing by returning a non-
   zero value to the frontend
3. Postoperation plugins never abort processing (all are called)
   and their return values are ignored
This commit is contained in:
Luke Howard 2003-01-20 23:18:11 +00:00
parent b5594b2750
commit d484a9781c
12 changed files with 119 additions and 140 deletions

View file

@ -234,19 +234,20 @@ do_add( Connection *conn, Operation *op )
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_ADD_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
if ( rc != 0 ) {
/*
* either there is no preOp (add) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
* A preoperation plugin failure will abort the
* entire operation.
*/
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_add: add preOps failed\n",
LDAP_LOG( OPERATION, INFO, "do_add: add preoperation plugin failed\n",
0, 0, 0);
#else
Debug(LDAP_DEBUG_TRACE, "do_add: add preOps failed.\n",
Debug(LDAP_DEBUG_TRACE, "do_add: add preoperation plugin failed.\n",
0, 0, 0);
if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 )
rc = LDAP_OPERATIONS_ERROR;
goto done;
#endif
}
#endif /* defined( LDAP_SLAPI ) */
@ -338,19 +339,16 @@ do_add( Connection *conn, Operation *op )
}
#if defined( LDAP_SLAPI )
rc = doPluginFNs( be, SLAPI_PLUGIN_POST_ADD_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
/*
* either there is no postOp (Add) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
*/
/*
* Postoperation errors are silently ignored; the work has
* been done.
*/
if ( doPluginFNs( be, SLAPI_PLUGIN_POST_ADD_FN, pb ) != 0) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_add: Add postOps failed\n",
LDAP_LOG( OPERATION, INFO, "do_add: Add postoperation plugins failed\n",
0, 0, 0);
#else
Debug(LDAP_DEBUG_TRACE, "do_add: Add postOps failed.\n",
Debug(LDAP_DEBUG_TRACE, "do_add: Add postoperation plugins failed.\n",
0, 0, 0);
#endif
}

View file

@ -702,20 +702,19 @@ backend_unbind(
slapi_pblock_set( pb, SLAPI_BACKEND, (void *)&backends[i] );
rc = doPluginFNs( &backends[i], SLAPI_PLUGIN_PRE_UNBIND_FN,
(Slapi_PBlock *)pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
if ( rc != 0 ) {
/*
* either there is no preOp (unbind) plugins
* or a plugin failed. Just log it.
*
* FIXME: is this correct?
* A preoperation plugin failure will abort the
* entire operation.
*/
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_bind: Unbind preOps "
LDAP_LOG( OPERATION, INFO, "do_bind: Unbind preoperation plugin "
"failed\n", 0, 0, 0);
#else
Debug(LDAP_DEBUG_TRACE, "do_bind: Unbind preOps "
Debug(LDAP_DEBUG_TRACE, "do_bind: Unbind preoperation plugin "
"failed.\n", 0, 0, 0);
#endif
return 0;
}
#endif /* defined( LDAP_SLAPI ) */
@ -724,20 +723,13 @@ backend_unbind(
}
#if defined( LDAP_SLAPI )
rc = doPluginFNs( &backends[i], SLAPI_PLUGIN_POST_UNBIND_FN,
(Slapi_PBlock *)pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
/*
* either there is no postOp (unbind) plugins
* or a plugin failed. Just log it.
*
* FIXME: is this correct?
*/
if ( doPluginFNs( &backends[i], SLAPI_PLUGIN_POST_UNBIND_FN,
(Slapi_PBlock *)pb ) != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_unbind: Unbind postOps "
LDAP_LOG( OPERATION, INFO, "do_unbind: Unbind postoperation plugins "
"failed\n", 0, 0, 0);
#else
Debug(LDAP_DEBUG_TRACE, "do_unbind: Unbind postOps "
Debug(LDAP_DEBUG_TRACE, "do_unbind: Unbind postoperation plugins "
"failed.\n", 0, 0, 0);
#endif
}

View file

@ -545,20 +545,22 @@ do_bind(
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_BIND_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
if ( rc != SLAPI_BIND_SUCCESS ) {
/* XXX: we should support SLAPI_BIND_ANONYMOUS being returned */
/*
* either there is no preOp (bind) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
* A preoperation plugin failure will abort the
* entire operation.
*/
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_bind: Bind preOps failed\n",
LDAP_LOG( OPERATION, INFO, "do_bind: Bind preoperation plugin failed\n",
0, 0, 0);
#else
Debug(LDAP_DEBUG_TRACE, "do_bind: Bind preOps failed.\n",
Debug(LDAP_DEBUG_TRACE, "do_bind: Bind preoperation plugin failed.\n",
0, 0, 0);
#endif
if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 )
rc = LDAP_OPERATIONS_ERROR;
goto cleanup;
}
#endif /* defined( LDAP_SLAPI ) */
@ -629,19 +631,12 @@ do_bind(
}
#if defined( LDAP_SLAPI )
rc = doPluginFNs( be, SLAPI_PLUGIN_POST_BIND_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
/*
* either there is no pretOp (bind) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
*/
if ( doPluginFNs( be, SLAPI_PLUGIN_POST_BIND_FN, pb ) != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_bind: Bind postOps failed\n",
LDAP_LOG( OPERATION, INFO, "do_bind: Bind postoperation plugins failed\n",
0, 0, 0);
#else
Debug(LDAP_DEBUG_TRACE, "do_bind: Bind postOps failed.\n",
Debug(LDAP_DEBUG_TRACE, "do_bind: Bind postoperation plugins failed.\n",
0, 0, 0);
#endif
}

View file

@ -281,20 +281,21 @@ do_compare(
slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&value );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_COMPARE_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
if ( rc != 0 ) {
/*
* either there is no preOp (compare) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
* A preoperation plugin failure will abort the
* entire operation.
*/
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_compare: compare preOps "
LDAP_LOG( OPERATION, INFO, "do_compare: compare preoperation plugin "
"failed\n", 0, 0, 0);
#else
Debug(LDAP_DEBUG_TRACE, "do_compare: compare preOps "
Debug(LDAP_DEBUG_TRACE, "do_compare: compare preoperation plugin "
"failed.\n", 0, 0, 0);
#endif
if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0)
rc = LDAP_OPERATIONS_ERROR;
goto cleanup;
}
#endif /* defined( LDAP_SLAPI ) */
@ -307,19 +308,12 @@ do_compare(
}
#if defined( LDAP_SLAPI )
rc = doPluginFNs( be, SLAPI_PLUGIN_POST_COMPARE_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
/*
* either there is no postOp (compare) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
*/
if ( doPluginFNs( be, SLAPI_PLUGIN_POST_COMPARE_FN, pb ) != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_compare: compare postOps "
LDAP_LOG( OPERATION, INFO, "do_compare: compare postoperation plugins "
"failed\n", 0, 0, 0 );
#else
Debug(LDAP_DEBUG_TRACE, "do_compare: compare postOps "
Debug(LDAP_DEBUG_TRACE, "do_compare: compare postoperation plugins "
"failed.\n", 0, 0, 0);
#endif
}

View file

@ -165,20 +165,21 @@ do_delete(
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_DELETE_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
if ( rc != 0 ) {
/*
* either there is no preOp (delete) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
* A preoperation plugin failure will abort the
* entire operation.
*/
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_delete: delete preOps "
LDAP_LOG( OPERATION, INFO, "do_delete: delete preoperation plugin "
"failed\n", 0, 0, 0 );
#else
Debug (LDAP_DEBUG_TRACE, "do_delete: delete preOps failed.\n",
Debug (LDAP_DEBUG_TRACE, "do_delete: delete preoperation plugin failed.\n",
0, 0, 0);
#endif
if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 )
rc = LDAP_OPERATIONS_ERROR;
goto cleanup;
}
#endif /* defined( LDAP_SLAPI ) */
@ -223,19 +224,12 @@ do_delete(
}
#if defined( LDAP_SLAPI )
rc = doPluginFNs( be, SLAPI_PLUGIN_POST_DELETE_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
/*
* either there is no postOp (delete) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
*/
if ( doPluginFNs( be, SLAPI_PLUGIN_POST_DELETE_FN, pb ) != 0) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_delete: delete postOps "
LDAP_LOG( OPERATION, INFO, "do_delete: delete postoperation plugins "
"failed\n", 0, 0, 0 );
#else
Debug(LDAP_DEBUG_TRACE, "do_delete: delete postOps "
Debug(LDAP_DEBUG_TRACE, "do_delete: delete postoperation plugins "
"failed.\n", 0, 0, 0);
#endif
}

View file

@ -348,20 +348,21 @@ do_modify(
slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
if ( rc != 0 ) {
/*
* either there is no preOp (modify) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
* A preoperation plugin failure will abort the
* entire operation.
*/
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_modify: modify preOps "
LDAP_LOG( OPERATION, INFO, "do_modify: modify preoperation plugin "
"failed\n", 0, 0, 0 );
#else
Debug(LDAP_DEBUG_TRACE, "do_modify: modify preOps failed.\n",
Debug(LDAP_DEBUG_TRACE, "do_modify: modify preoperation plugin failed.\n",
0, 0, 0);
#endif
if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0)
rc = LDAP_OPERATIONS_ERROR;
goto cleanup;
}
#endif /* defined( LDAP_SLAPI ) */
@ -443,19 +444,12 @@ do_modify(
}
#if defined( LDAP_SLAPI )
rc = doPluginFNs( be, SLAPI_PLUGIN_POST_MODIFY_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
/*
* either there is no postOp (modify) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
*/
if ( doPluginFNs( be, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_modify: modify postOps "
LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
"failed\n", 0, 0, 0 );
#else
Debug(LDAP_DEBUG_TRACE, "do_modify: modify postOps "
Debug(LDAP_DEBUG_TRACE, "do_modify: modify postoperation plugins "
"failed.\n", 0, 0, 0);
#endif
}

View file

@ -340,20 +340,21 @@ do_modrdn(
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_MODRDN_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
if ( rc != 0 ) {
/*
* either there is no preOp (modrdn) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
* A preoperation plugin failure will abort the
* entire operation.
*/
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn preOps "
LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn preoperation plugin "
"failed\n", 0, 0, 0 );
#else
Debug(LDAP_DEBUG_TRACE, "do_modrdn: modrdn preOps "
Debug(LDAP_DEBUG_TRACE, "do_modrdn: modrdn preoperation plugin "
"failed.\n", 0, 0, 0);
#endif
if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0)
rc = LDAP_OPERATIONS_ERROR;
goto cleanup;
}
#endif /* defined( LDAP_SLAPI ) */
@ -404,19 +405,12 @@ do_modrdn(
}
#if defined( LDAP_SLAPI )
rc = doPluginFNs( be, SLAPI_PLUGIN_POST_MODRDN_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
/*
* either there is no postOp (modrdn) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
*/
if ( doPluginFNs( be, SLAPI_PLUGIN_POST_MODRDN_FN, pb ) != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn postOps "
LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn postoperation plugins "
"failed\n", 0, 0, 0 );
#else
Debug(LDAP_DEBUG_TRACE, "do_modrdn: modrdn postOps "
Debug(LDAP_DEBUG_TRACE, "do_modrdn: modrdn postoperation plugins "
"failed.\n", 0, 0, 0);
#endif
}

View file

@ -240,7 +240,7 @@ send_ldap_response(
text, ref, resoid, resdata, sasldata, ctrls );
return;
}
ber_init_w_nullc( ber, LBER_USE_DER );
#ifdef NEW_LOGGING

View file

@ -354,21 +354,22 @@ do_search(
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_SEARCH_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
if ( rc != 0 ) {
/*
* either there is no preOp (search) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
* A preoperation plugin failure will abort the
* entire operation.
*/
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_search: search preOps "
LDAP_LOG( OPERATION, INFO, "do_search: search preoperation plugin "
"failed\n", 0, 0, 0 );
#else
Debug(LDAP_DEBUG_TRACE, "do_search: search preOps "
Debug(LDAP_DEBUG_TRACE, "do_search: search preoperation plugin "
"failed.\n", 0, 0, 0);
#endif
}
if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0)
rc = LDAP_OPERATIONS_ERROR;
return rc;
}
#endif /* defined( LDAP_SLAPI ) */
/* actually do the search and send the result(s) */
@ -383,22 +384,15 @@ do_search(
}
#if defined( LDAP_SLAPI )
rc = doPluginFNs( be, SLAPI_PLUGIN_POST_SEARCH_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
/*
* either there is no postOp (search) plugins
* or a plugin failed. Just log it
*
* FIXME: is this correct?
*/
if ( doPluginFNs( be, SLAPI_PLUGIN_POST_SEARCH_FN, pb ) != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_search: search postOps "
LDAP_LOG( OPERATION, INFO, "do_search: search postoperation plugins "
"failed\n", 0, 0, 0 );
#else
Debug(LDAP_DEBUG_TRACE, "do_search: search postOps "
Debug(LDAP_DEBUG_TRACE, "do_search: search postoperation plugins "
"failed.\n", 0, 0, 0);
#endif
}
}
#endif /* defined( LDAP_SLAPI ) */
return_results:;

View file

@ -50,6 +50,10 @@ LDAP_BEGIN_DECL
#define SLAPI_PLUGIN_EXTENDED_SENT_RESULT -1
#define SLAPI_PLUGIN_EXTENDED_NOT_HANDLED -2
#define SLAPI_BIND_SUCCESS 0
#define SLAPI_BIND_FAIL 2
#define SLAPI_BIND_ANONYMOUS 3
#define SLAPI_BACKEND 130
#define SLAPI_CONNECTION 131
#define SLAPI_OPERATION 132
@ -180,6 +184,10 @@ LDAP_BEGIN_DECL
#define SLAPI_PLUGIN_SYNTAX_FLAGS 707
#define SLAPI_PLUGIN_SYNTAX_COMPARE 708
#define SLAPI_RESULT_CODE 881
#define SLAPI_RESULT_TEXT 882
#define SLAPI_RESULT_MATCHED 883
#define SLAPI_PLUGIN_SYNTAX_FLAG_ORKEYS 1
#define SLAPI_PLUGIN_SYNTAX_FLAG_ORDERING 2

View file

@ -367,6 +367,18 @@ slapi_pblock_destroy( Slapi_PBlock* pb )
ch_free( str );
}
get( pb, SLAPI_RESULT_TEXT, (void **)&str );
if ( str != NULL ) {
ch_free( str );
str = NULL;
}
get( pb, SLAPI_RESULT_MATCHED, (void **)&str );
if ( str != NULL ) {
ch_free( str );
str = NULL;
}
ldap_pvt_thread_mutex_destroy( &pb->pblockMutex );
ch_free( pb );

View file

@ -705,6 +705,10 @@ slapi_send_ldap_result(
return;
}
slapi_pblock_set( pb, SLAPI_RESULT_CODE, (void *)err);
slapi_pblock_set( pb, SLAPI_RESULT_MATCHED, ( matched != NULL ) ? (void *)ch_strdup( matched ) : NULL );
slapi_pblock_set( pb, SLAPI_RESULT_TEXT, ( text != NULL ) ? (void *)ch_strdup( text ) : NULL );
send_ldap_result( conn, op, err, matched, text, NULL, NULL );
#endif /* defined(LDAP_SLAPI) */
}