]> git.sur5r.net Git - openldap/commitdiff
Changed conn->c_cdn to struct berval.
authorHoward Chu <hyc@openldap.org>
Sun, 6 Jan 2002 03:26:09 +0000 (03:26 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 6 Jan 2002 03:26:09 +0000 (03:26 +0000)
servers/slapd/back-ldap/bind.c
servers/slapd/back-meta/conn.c
servers/slapd/bind.c
servers/slapd/connection.c
servers/slapd/slap.h

index a9be9a68d4ea8fee61c743023c44a2a60f920dc7..673a63be02954aa092c5ef00088333796d1882a2 100644 (file)
@@ -226,7 +226,7 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op)
                ( void )rewrite_session_init( li->rwinfo, conn );
 #endif /* ENABLE_REWRITE */
 
-               if ( lc->conn->c_cdn != NULL && lc->conn->c_cdn[0] != '\0' ) {
+               if ( lc->conn->c_cdn.bv_len != 0 ) {
                        
                        /*
                         * Rewrite the bind dn if needed
@@ -235,24 +235,23 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op)
                        lc->bound_dn.bv_val = NULL;
                        lc->bound_dn.bv_len = 0;
                        switch ( rewrite_session( li->rwinfo, "bindDn",
-                                               lc->conn->c_cdn, conn,
+                                               lc->conn->c_cdn.bv_val, conn,
                                                &lc->bound_dn.bv_val ) ) {
                        case REWRITE_REGEXEC_OK:
                                if ( lc->bound_dn.bv_val == NULL ) {
-                                       lc->bound_dn.bv_val = 
-                                               ch_strdup( lc->conn->c_cdn );
+                                       ber_dupbv( &lc->bound_dn, &lc->conn->c_cdn );
                                }
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
                                                "[rw] bindDn: \"%s\" ->"
                                                " \"%s\"\n%s",
-                                               lc->conn->c_cdn,
+                                               lc->conn->c_cdn.bv_val,
                                                lc->bound_dn.bv_val ));
 #else /* !NEW_LOGGING */
                                Debug( LDAP_DEBUG_ARGS,
                                                "rw> bindDn: \"%s\" ->"
                                                " \"%s\"\n%s",
-                                               lc->conn->c_cdn,
+                                               lc->conn->c_cdn.bv_val,
                                                lc->bound_dn.bv_val, "" );
 #endif /* !NEW_LOGGING */
                                break;
@@ -273,8 +272,11 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op)
                        }
 #else /* !ENABLE_REWRITE */
                        struct berval bv;
-                       ber_str2bv( lc->conn->c_cdn, 0, 0, &bv );
-                       ldap_back_dn_massage( li, &bv, &lc->bound_dn, 0, 1 );
+                       ldap_back_dn_massage( li, &lc->conn->c_cdn, &bv, 0, 1 );
+                       if ( bv.bv_val == lc->conn->c_cdn.bv_val )
+                               ber_dupbv( &lc->bound_dn, &bv );
+                       else
+                               lc->bound_dn = bv;
 #endif /* !ENABLE_REWRITE */
                } else {
                        lc->bound_dn.bv_val = NULL;
index c665a27165a94053aa30809ee2582edff99bcdc8..66f820c979a0f269e3c28f4d119bd0a8c402ca79 100644 (file)
@@ -275,27 +275,27 @@ init_one_conn(
        /*
         * If the connection dn is not null, an attempt to rewrite it is made
         */
-       if ( conn->c_cdn != 0 ) {
+       if ( conn->c_cdn.bv_len != 0 ) {
                
                /*
                 * Rewrite the bind dn if needed
                 */
                lsc->bound_dn.bv_val = NULL;
                switch ( rewrite_session( lt->rwinfo, "bindDn",
-                                       conn->c_cdn, conn, 
+                                       conn->c_cdn.bv_val, conn, 
                                        &lsc->bound_dn.bv_val ) ) {
                case REWRITE_REGEXEC_OK:
                        if ( lsc->bound_dn.bv_val == NULL ) {
-                               ber_str2bv( conn->c_cdn, 0, 1, &lsc->bound_dn );
+                               ber_dupbv( &lsc->bound_dn, &conn->c_cdn );
                        }
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
                                        "[rw] bindDn: \"%s\" -> \"%s\"\n",
-                                       conn->c_cdn, lsc->bound_dn.bv_val ));
+                                       conn->c_cdn.bv_val, lsc->bound_dn.bv_val ));
 #else /* !NEW_LOGGING */
                        Debug( LDAP_DEBUG_ARGS,
                                        "rw> bindDn: \"%s\" -> \"%s\"\n",
-                                       conn->c_cdn, lsc->bound_dn.bv_val, 0 );
+                                       conn->c_cdn.bv_val, lsc->bound_dn.bv_val, 0 );
 #endif /* !NEW_LOGGING */
                        break;
                        
index cafc4d286ae290fdbd72fcf02934151c647187c4..ac42ed06deb699ef856f6fb7d5173ae5c4cca6c0 100644 (file)
@@ -495,7 +495,7 @@ do_bind(
                        } else {
                                ber_dupbv( &conn->c_dn, &pdn );
                        }
-                       conn->c_cdn = pdn.bv_val;
+                       conn->c_cdn = pdn;
                        pdn.bv_val = NULL;
                        pdn.bv_len = 0;
 
@@ -512,11 +512,11 @@ do_bind(
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
                                "do_bind: conn %d  v%d bind: \"%s\" to \"%s\" \n",
-                               conn->c_connid, version, conn->c_cdn, conn->c_dn.bv_val ));
+                               conn->c_connid, version, conn->c_cdn.bv_val, conn->c_dn.bv_val ));
 #else
                        Debug( LDAP_DEBUG_TRACE,
                                "do_bind: v%d bind: \"%s\" to \"%s\"\n",
-                               version, conn->c_cdn, conn->c_dn.bv_val );
+                               version, conn->c_cdn.bv_val, conn->c_dn.bv_val );
 #endif
 
                        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
index 93ae38654d2b8c780ba0d4b32e339cf4aeb11aac..a8b897d6226996936ca684a6cb5751beff37a19c 100644 (file)
@@ -417,7 +417,8 @@ long connection_init(
                c->c_dn.bv_len = 0;
                c->c_ndn.bv_val = NULL;
                c->c_ndn.bv_len = 0;
-               c->c_cdn = NULL;
+               c->c_cdn.bv_val = NULL;
+               c->c_cdn.bv_len = 0;
                c->c_groups = NULL;
 
                c->c_listener_url = NULL;
@@ -455,7 +456,7 @@ long connection_init(
        assert( c->c_authmech == NULL );
     assert(    c->c_dn.bv_val == NULL );
     assert(    c->c_ndn.bv_val == NULL );
-    assert(    c->c_cdn == NULL );
+    assert(    c->c_cdn.bv_val == NULL );
     assert( c->c_groups == NULL );
     assert( c->c_listener_url == NULL );
     assert( c->c_peer_domain == NULL );
@@ -591,10 +592,11 @@ void connection2anonymous( Connection *c )
     }
     c->c_ndn.bv_len = 0;
 
-       if(c->c_cdn != NULL) {
-               free(c->c_cdn);
-               c->c_cdn = NULL;
+       if(c->c_cdn.bv_val != NULL) {
+               free(c->c_cdn.bv_val);
+               c->c_cdn.bv_val = NULL;
        }
+       c->c_cdn.bv_len = 0;
 
        c->c_authc_backend = NULL;
        c->c_authz_backend = NULL;
index daf702c58f247c88d91e967261c0cbb1076fe977..613936d15135c116e45781cfaf75c0c298a1d88a 100644 (file)
@@ -1351,7 +1351,7 @@ typedef struct slap_conn {
        /* only can be changed by binding thread */
        int             c_sasl_bind_in_progress;        /* multi-op bind in progress */
        char    *c_sasl_bind_mech;                      /* mech in progress */
-       char    *c_cdn;
+       struct berval   c_cdn;
 
        /* authentication backend */
        Backend *c_authc_backend;