From: Luke Howard Date: Mon, 20 Jan 2003 23:18:11 +0000 (+0000) Subject: Conform SLAPI to Netscape, iPlanet and Sun ONE Directory Server X-Git-Tag: NO_SLAP_OP_BLOCKS~581 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d484a9781ce05cf15b6c2a8fcfcfec28238b5908;p=openldap 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 --- diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 46de08c935..0db53d78f4 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -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 } diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index d990ac2da5..ee8b3809d3 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -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 } diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index b264c46607..9c9b9f8f9e 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -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 } diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index c1f3db3f9c..f50c58c380 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -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 } diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index acab86bba6..012a1d71c2 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -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 } diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 9cc0f0d00b..cf06590296 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -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 } diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 1238050cb1..d2f53ad977 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -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 } diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 0fe739a732..97abca094e 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -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 diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 8a1cac660b..151505f708 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -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:; diff --git a/servers/slapd/slapi/slapi.h b/servers/slapd/slapi/slapi.h index 4e5ea29add..ad8ecec046 100644 --- a/servers/slapd/slapi/slapi.h +++ b/servers/slapd/slapi/slapi.h @@ -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 diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index 2df1f3bd4e..4418f7eeb5 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -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 ); diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index cc4fa53af1..db1907b956 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -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) */ }