]> git.sur5r.net Git - openldap/commitdiff
Further harmonisation with Sun ONE SLAPI: extra PBlock parameters
authorLuke Howard <lukeh@openldap.org>
Tue, 21 Jan 2003 08:34:25 +0000 (08:34 +0000)
committerLuke Howard <lukeh@openldap.org>
Tue, 21 Jan 2003 08:34:25 +0000 (08:34 +0000)
on connections and operations

servers/slapd/slapi/slapi.h
servers/slapd/slapi/slapi_pblock.c
servers/slapd/slapi/slapi_utils.c

index e219e87182e15356507c0ae5a3a8af81a08bc9ea..7feb0c4585c36cfefadb4437a0c94751cd4b8d31 100644 (file)
@@ -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
index 4418f7eeb5e408640de54eb30115631d83f19c15..82fb0ee3e041c460a4fa61896b73effd5173b0a7 100644 (file)
@@ -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 );
index fdc5c85a2923f82dce2b03c6b820ffdd87b5eb30..10846816869de79ecb6931ebab01181a0bd25b9d 100644 (file)
@@ -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;