From: Luke Howard Date: Tue, 21 Jan 2003 08:34:25 +0000 (+0000) Subject: Further harmonisation with Sun ONE SLAPI: extra PBlock parameters X-Git-Tag: NO_SLAP_OP_BLOCKS~573 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=313d3633e3924f2febb1afd2378cb5983e7145b1;p=openldap Further harmonisation with Sun ONE SLAPI: extra PBlock parameters on connections and operations --- diff --git a/servers/slapd/slapi/slapi.h b/servers/slapd/slapi/slapi.h index e219e87182..7feb0c4585 100644 --- a/servers/slapd/slapi/slapi.h +++ b/servers/slapd/slapi/slapi.h @@ -77,12 +77,16 @@ LDAP_BEGIN_DECL #define SLAPI_BE_TYPE 135 #define SLAPI_BE_READONLY 136 #define SLAPI_BE_LASTMOD 137 +#define SLAPI_OPERATION_PARAMETERS 138 #define SLAPI_CONN_ID 139 #define SLAPI_OPINITIATED_TIME 140 #define SLAPI_REQUESTOR_DN 141 #define SLAPI_REQUESTOR_ISUPDATEDN 142 +#define SLAPI_IS_REPLICATED_OPERATION SLAPI_REQUESTOR_ISUPDATEDN #define SLAPI_CONN_DN 143 +#define SLAPI_CONN_CLIENTIP 145 +#define SLAPI_CONN_SERVERIP 146 #define SLAPI_CONN_AUTHTYPE 144 #define SLAPD_AUTH_NONE "none" @@ -164,6 +168,8 @@ LDAP_BEGIN_DECL #define SLAPI_PLUGIN_POST_REFERRAL_FN 511 #define SLAPI_PLUGIN_POST_RESULT_FN 512 +#define SLAPI_OPERATION_TYPE 590 + #define SLAPI_PLUGIN_MR_FILTER_CREATE_FN 600 #define SLAPI_PLUGIN_MR_INDEXER_CREATE_FN 601 #define SLAPI_PLUGIN_MR_FILTER_MATCH_FN 602 @@ -199,6 +205,11 @@ LDAP_BEGIN_DECL #define SLAPI_PLUGIN_SYNTAX_FLAGS 707 #define SLAPI_PLUGIN_SYNTAX_COMPARE 708 +#define SLAPI_OPERATION_AUTHTYPE 741 +#define SLAPI_OPERATION_ID 742 +#define SLAPI_CONN_CERT 743 +#define SLAPI_CONN_AUTHMETHOD 746 + #define SLAPI_RESULT_CODE 881 #define SLAPI_RESULT_TEXT 882 #define SLAPI_RESULT_MATCHED 883 diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index 4418f7eeb5..82fb0ee3e0 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -22,6 +22,10 @@ isOkNetscapeParam( int param ) case SLAPI_BACKEND: case SLAPI_CONNECTION: case SLAPI_OPERATION: + case SLAPI_OPERATION_PARAMETERS: + case SLAPI_OPERATION_TYPE: + case SLAPI_OPERATION_ID: + case SLAPI_OPERATION_AUTHTYPE: case SLAPI_REQUESTOR_ISROOT: case SLAPI_BE_MONITORDN: case SLAPI_BE_TYPE: @@ -32,7 +36,11 @@ isOkNetscapeParam( int param ) case SLAPI_REQUESTOR_DN: case SLAPI_REQUESTOR_ISUPDATEDN: case SLAPI_CONN_DN: + case SLAPI_CONN_CLIENTIP: + case SLAPI_CONN_SERVERIP: case SLAPI_CONN_AUTHTYPE: + case SLAPI_CONN_AUTHMETHOD: + case SLAPI_CONN_CERT: case SLAPI_IBM_CONN_DN_ALT: case SLAPI_IBM_CONN_DN_ORIG: case SLAPI_IBM_GSSAPI_CONTEXT: @@ -185,6 +193,9 @@ isOkNetscapeParam( int param ) case SLAPI_CHANGENUMBER: case SLAPI_LOG_OPERATION: case SLAPI_DBSIZE: + case SLAPI_RESULT_CODE: + case SLAPI_RESULT_TEXT: + case SLAPI_RESULT_MATCHED: return LDAP_SUCCESS; default: return INVALID_PARAM; @@ -350,12 +361,24 @@ slapi_pblock_destroy( Slapi_PBlock* pb ) str = NULL; } + get( pb, SLAPI_OPERATION_AUTHTYPE, (void **)&str ); + if ( str != NULL ) { + ch_free( str ); + str = NULL; + } + get( pb, SLAPI_CONN_AUTHTYPE, (void **)&str ); if ( str != NULL ) { ch_free( str ); str = NULL; } + get( pb, SLAPI_CONN_AUTHMETHOD, (void **)&str ); + if ( str != NULL ) { + ch_free( str ); + str = NULL; + } + get( pb, SLAPI_IBM_CONN_DN_ALT, (void **)&str ); if ( str != NULL ) { ch_free( str ); diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index fdc5c85a29..1084681686 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -1136,12 +1136,12 @@ int slapi_x_backend_set_pb( Slapi_PBlock *pb, Backend *be ) #if defined(LDAP_SLAPI) int rc; - rc = slapi_pblock_set(pb, SLAPI_BACKEND, (void *)be); - if (rc != LDAP_SUCCESS) + rc = slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be ); + if ( rc != LDAP_SUCCESS ) return rc; - rc = slapi_pblock_set(pb, SLAPI_BE_TYPE, (void *)be->bd_info->bi_type); - if (rc != LDAP_SUCCESS) + rc = slapi_pblock_set( pb, SLAPI_BE_TYPE, (void *)be->bd_info->bi_type ); + if ( rc != LDAP_SUCCESS ) return rc; return LDAP_SUCCESS; @@ -1150,55 +1150,81 @@ int slapi_x_backend_set_pb( Slapi_PBlock *pb, Backend *be ) #endif /* defined(LDAP_SLAPI) */ } -/* - * Internal API to prime a Slapi_PBlock with a Connection. - */ -int slapi_x_connection_set_pb( Slapi_PBlock *pb, Connection *conn ) -{ #if defined(LDAP_SLAPI) - char *connAuthType; +static char *Authorization2AuthType( AuthorizationInformation *authz, int is_tls ) +{ size_t len; - int rc; - - rc = slapi_pblock_set(pb, SLAPI_CONNECTION, (void *)conn); - if (rc != LDAP_SUCCESS) - return rc; - - rc = slapi_pblock_set(pb, SLAPI_CONN_ID, (void *)conn->c_connid); - if (rc != LDAP_SUCCESS) - return rc; + char *authType; - switch (conn->c_authz.sai_method) { + switch ( authz->sai_method ) { case LDAP_AUTH_SASL: - len = sizeof(SLAPD_AUTH_SASL) + conn->c_authz.sai_mech.bv_len; - connAuthType = slapi_ch_malloc(len); - snprintf(connAuthType, len, "%s%s", SLAPD_AUTH_SASL, conn->c_authz.sai_mech.bv_val); + len = sizeof(SLAPD_AUTH_SASL) + authz->sai_mech.bv_len; + authType = slapi_ch_malloc( len ); + snprintf( authType, len, "%s%s", SLAPD_AUTH_SASL, authz->sai_mech.bv_val ); break; case LDAP_AUTH_SIMPLE: - connAuthType = slapi_ch_strdup(SLAPD_AUTH_SIMPLE); + authType = slapi_ch_strdup( SLAPD_AUTH_SIMPLE ); break; case LDAP_AUTH_NONE: - connAuthType = slapi_ch_strdup(SLAPD_AUTH_NONE); + authType = slapi_ch_strdup( SLAPD_AUTH_NONE ); break; default: - connAuthType = NULL; + authType = NULL; break; } - if (conn->c_is_tls && connAuthType == NULL) { - connAuthType = slapi_ch_strdup(SLAPD_AUTH_SSL); + if ( is_tls && authType == NULL ) { + authType = slapi_ch_strdup( SLAPD_AUTH_SSL ); } - if (connAuthType != NULL) { + + return authType; +} +#endif + +/* + * Internal API to prime a Slapi_PBlock with a Connection. + */ +int slapi_x_connection_set_pb( Slapi_PBlock *pb, Connection *conn ) +{ +#if defined(LDAP_SLAPI) + char *connAuthType; + int rc; + + rc = slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn ); + if ( rc != LDAP_SUCCESS ) + return rc; + + if ( strncmp( conn->c_peer_name.bv_val, "IP=", 3 ) == 0 ) { + rc = slapi_pblock_set( pb, SLAPI_CONN_CLIENTIP, (void *)&conn->c_peer_name.bv_val[3] ); + if ( rc != LDAP_SUCCESS ) + return rc; + } + + if ( strncmp( conn->c_sock_name.bv_val, "IP=", 3 ) == 0 ) { + rc = slapi_pblock_set( pb, SLAPI_CONN_SERVERIP, (void *)&conn->c_sock_name.bv_val[3] ); + if ( rc != LDAP_SUCCESS ) + return rc; + } + + rc = slapi_pblock_set( pb, SLAPI_CONN_ID, (void *)conn->c_connid ); + if ( rc != LDAP_SUCCESS ) + return rc; + + connAuthType = Authorization2AuthType( &conn->c_authz, conn->c_is_tls ); + if ( connAuthType != NULL ) { rc = slapi_pblock_set(pb, SLAPI_CONN_AUTHTYPE, (void *)connAuthType); - if (rc != LDAP_SUCCESS) + if ( rc != LDAP_SUCCESS ) + return rc; + + rc = slapi_pblock_set(pb, SLAPI_CONN_AUTHMETHOD, (void *)connAuthType); + if ( rc != LDAP_SUCCESS ) return rc; } - if (conn->c_authz.sai_dn.bv_val != NULL) { + if ( conn->c_authz.sai_dn.bv_val != NULL ) { char *connDn = slapi_ch_strdup(conn->c_authz.sai_dn.bv_val); rc = slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)connDn); - if (rc != LDAP_SUCCESS) + if ( rc != LDAP_SUCCESS ) return rc; } - return LDAP_SUCCESS; #else return -1; #endif /* defined(LDAP_SLAPI) */ @@ -1214,39 +1240,55 @@ int slapi_x_operation_set_pb( Slapi_PBlock *pb, Operation *op ) int isUpdateDn = 0; int rc; Backend *be; + char *opAuthType; - if (slapi_pblock_get(pb, SLAPI_BACKEND, (void *)&be) != 0) { + if ( slapi_pblock_get(pb, SLAPI_BACKEND, (void *)&be ) != 0 ) { be = NULL; } if (be != NULL) { - isRoot = be_isroot(be, &op->o_ndn); - isUpdateDn = be_isupdate(be, &op->o_ndn); + isRoot = be_isroot( be, &op->o_ndn ); + isUpdateDn = be_isupdate( be, &op->o_ndn ); } - rc = slapi_pblock_set(pb, SLAPI_OPERATION, (void *)op); - if (rc != LDAP_SUCCESS) + rc = slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op ); + if ( rc != LDAP_SUCCESS ) + return rc; + + rc = slapi_pblock_set( pb, SLAPI_OPINITIATED_TIME, (void *)op->o_time ); + if ( rc != LDAP_SUCCESS ) return rc; - rc = slapi_pblock_set(pb, SLAPI_OPINITIATED_TIME, (void *)op->o_time); - if (rc != LDAP_SUCCESS) + rc = slapi_pblock_set( pb, SLAPI_OPERATION_ID, (void *)op->o_opid ); + if ( rc != LDAP_SUCCESS ) return rc; - rc = slapi_pblock_set(pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot); - if (rc != LDAP_SUCCESS) + rc = slapi_pblock_set( pb, SLAPI_OPERATION_TYPE, (void *)op->o_tag ); + if ( rc != LDAP_SUCCESS ) return rc; - rc = slapi_pblock_set(pb, SLAPI_REQUESTOR_ISUPDATEDN, (void *)isUpdateDn); - if (rc != LDAP_SUCCESS) + rc = slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot ); + if ( rc != LDAP_SUCCESS ) return rc; - rc = slapi_pblock_set(pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls); - if (rc != LDAP_SUCCESS) + rc = slapi_pblock_set( pb, SLAPI_REQUESTOR_ISUPDATEDN, (void *)isUpdateDn ); + if ( rc != LDAP_SUCCESS ) return rc; - rc = slapi_pblock_set(pb, SLAPI_REQUESTOR_DN, (void *)op->o_ndn.bv_val); - if (rc != LDAP_SUCCESS) + rc = slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls ); + if ( rc != LDAP_SUCCESS) return rc; + rc = slapi_pblock_set( pb, SLAPI_REQUESTOR_DN, (void *)op->o_ndn.bv_val ); + if ( rc != LDAP_SUCCESS ) + return rc; + + opAuthType = Authorization2AuthType( &op->o_authz, op->o_conn->c_is_tls ); + if (opAuthType != NULL) { + rc = slapi_pblock_set( pb, SLAPI_OPERATION_AUTHTYPE, (void *)opAuthType ); + if ( rc != LDAP_SUCCESS ) + return rc; + } + return LDAP_SUCCESS; #else return -1;