]> git.sur5r.net Git - openldap/commitdiff
First round of changes from HEAD
authorKurt Zeilenga <kurt@openldap.org>
Mon, 30 Aug 2004 17:44:19 +0000 (17:44 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 30 Aug 2004 17:44:19 +0000 (17:44 +0000)
backglue syncrepl context csn initialization
SLAPI/syncrepl nextid interaction fix
bind referrals fix
ldapi:// sun_path fix
add dnIsOneLevelRDN (this seems oldly named, RDNs only have one level)
add entry_clean()
SLAPI modify fix

servers/slapd/backglue.c
servers/slapd/bind.c
servers/slapd/connection.c
servers/slapd/daemon.c
servers/slapd/dn.c
servers/slapd/entry.c
servers/slapd/modify.c
servers/slapd/proto-slap.h
servers/slapd/value.c

index 2626862742fe8fbc0851616ad348e8734aa709a8..f65ee40f477a2e8eece49722a5d3c4b9bc896ae1 100644 (file)
@@ -139,6 +139,7 @@ glue_back_db_open (
 
        gi->gi_bd.be_acl = be->be_acl;
        gi->gi_bd.be_pending_csn_list = be->be_pending_csn_list;
+       gi->gi_bd.be_context_csn = be->be_context_csn;
 
        if (gi->gi_bd.bd_info->bi_db_open)
                rc = gi->gi_bd.bd_info->bi_db_open(&gi->gi_bd);
index 6a6698558743e492b47c8362edb7dbfa06af8092..8cd108a304e122e0d808cfae777a2de8e38f3cde 100644 (file)
@@ -519,22 +519,10 @@ do_bind(
         */
 
        if ( (op->o_bd = select_backend( &op->o_req_ndn, 0, 0 )) == NULL ) {
-               if ( default_referral ) {
-                       rs->sr_ref = referral_rewrite( default_referral,
-                               NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
-                       if (!rs->sr_ref) rs->sr_ref = default_referral;
-
-                       rs->sr_err = LDAP_REFERRAL;
-                       send_ldap_result( op, rs );
-
-                       if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
-
-               } else {
-                       /* noSuchObject is not allowed to be returned by bind */
-                       rs->sr_err = LDAP_INVALID_CREDENTIALS;
-                       send_ldap_result( op, rs );
-               }
-
+               /* don't return referral for bind requests */
+               /* noSuchObject is not allowed to be returned by bind */
+               rs->sr_err = LDAP_INVALID_CREDENTIALS;
+               send_ldap_result( op, rs );
                goto cleanup;
        }
 
index 0309b877c8909ff50aae2b015d87ce53a48a306b..d7a87ee02725d06a39163bd85e0298830e617aee 100644 (file)
@@ -45,6 +45,8 @@
 /* protected by connections_mutex */
 static ldap_pvt_thread_mutex_t connections_mutex;
 static Connection *connections = NULL;
+
+static ldap_pvt_thread_mutex_t conn_nextid_mutex;
 static unsigned long conn_nextid = 0;
 
 /* structure state (protected by connections_mutex) */
@@ -109,6 +111,7 @@ int connections_init(void)
 
        /* should check return of every call */
        ldap_pvt_thread_mutex_init( &connections_mutex );
+       ldap_pvt_thread_mutex_init( &conn_nextid_mutex );
 
        connections = (Connection *) ch_calloc( dtblsize, sizeof(Connection) );
 
@@ -176,6 +179,7 @@ int connections_destroy(void)
        connections = NULL;
 
        ldap_pvt_thread_mutex_destroy( &connections_mutex );
+       ldap_pvt_thread_mutex_destroy( &conn_nextid_mutex );
        return 0;
 }
 
@@ -607,7 +611,9 @@ long connection_init(
 #endif
        }
 
+       ldap_pvt_thread_mutex_lock( &conn_nextid_mutex );
        id = c->c_connid = conn_nextid++;
+       ldap_pvt_thread_mutex_unlock( &conn_nextid_mutex );
 
        c->c_conn_state = SLAP_C_INACTIVE;
        c->c_struct_state = SLAP_C_USED;
@@ -1187,7 +1193,7 @@ operations_error:
        return NULL;
 }
 
-static const Listener dummy_list = { {0, ""}, {0, ""} };
+static const Listener dummy_list = { BER_BVC(""), BER_BVC("") };
 
 int connection_client_setup(
        ber_socket_t s,
@@ -1892,6 +1898,7 @@ connection_fake_init(
        conn->c_send_search_entry = slap_send_search_entry;
        conn->c_send_search_reference = slap_send_search_reference;
        conn->c_listener = (Listener *)&dummy_list;
+       conn->c_peer_domain = slap_empty_bv;
        conn->c_peer_name = slap_empty_bv;
 
        /* set memory context */
@@ -1904,3 +1911,12 @@ connection_fake_init(
 
        op->o_time = slap_get_time();
 }
+
+void
+connection_assign_nextid( Connection *conn )
+{
+       ldap_pvt_thread_mutex_lock( &conn_nextid_mutex );
+       conn->c_connid = conn_nextid++;
+       ldap_pvt_thread_mutex_unlock( &conn_nextid_mutex );
+}
+
index 084e4394dbedf4ad95fc97845776741127ba3ca8..6a2e8e5c2a7353d7dc407f34aee8c542550488e8 100644 (file)
@@ -1535,6 +1535,11 @@ slapd_daemon_task(
                        FD_CLR( slap_listeners[l]->sl_sd, &readfds );
                        FD_CLR( slap_listeners[l]->sl_sd, &writefds );
 
+#  ifdef LDAP_PF_LOCAL
+                       /* FIXME: apparently accept doesn't fill
+                        * the sun_path sun_path member */
+                       from.sa_un_addr.sun_path[0] = '\0';
+#  endif /* LDAP_PF_LOCAL */
                        s = accept( slap_listeners[l]->sl_sd,
                                (struct sockaddr *) &from, &len );
                        if ( s == AC_SOCKET_INVALID ) {
index 67c9f52a78378ce75f212a954f1d80a6c8d9c7ed..f00cfacdc20aab47ac18e38ad5259e7e22d246f1 100644 (file)
@@ -895,6 +895,19 @@ dnIsSuffix(
        return( strcmp( dn->bv_val + d, suffix->bv_val ) == 0 );
 }
 
+int
+dnIsOneLevelRDN( struct berval *rdn )
+{
+       ber_len_t       len = rdn->bv_len;
+       for ( ; len--; ) {
+               if ( DN_SEPARATOR( rdn->bv_val[ len ] ) ) {
+                       return 0;
+               }
+       }
+
+       return 1;
+}
+
 #ifdef HAVE_TLS
 /*
  * Convert an X.509 DN into a normalized LDAP DN
index 04873fd68717988719737aaa0050f6ea54e36f20..cc1eeccdf8fd56a0a251648d37f003e6c6f95c44 100644 (file)
@@ -395,7 +395,7 @@ entry2str(
 }
 
 void
-entry_free( Entry *e )
+entry_clean( Entry *e )
 {
        /* free an entry structure */
        assert( e != NULL );
@@ -405,23 +405,29 @@ entry_free( Entry *e )
        e->e_private = NULL;
 
        /* free DNs */
-       if ( e->e_dn != NULL ) {
-               free( e->e_dn );
-               e->e_dn = NULL;
+       if ( !BER_BVISNULL( &e->e_name ) ) {
+               free( e->e_name.bv_val );
+               BER_BVZERO( &e->e_name );
        }
-       if ( e->e_ndn != NULL ) {
-               free( e->e_ndn );
-               e->e_ndn = NULL;
+       if ( !BER_BVISNULL( &e->e_nname ) ) {
+               free( e->e_nname.bv_val );
+               BER_BVZERO( &e->e_nname );
        }
 
-       if ( e->e_bv.bv_val != NULL ) {
+       if ( !BER_BVISNULL( &e->e_bv ) ) {
                free( e->e_bv.bv_val );
-               e->e_bv.bv_val = NULL;
+               BER_BVZERO( &e->e_bv );
        }
 
        /* free attributes */
        attrs_free( e->e_attrs );
        e->e_attrs = NULL;
+}
+
+void
+entry_free( Entry *e )
+{
+       entry_clean( e );
 
        free( e );
 }
index 08f484a00db0fc2622d5064e30ced1ea0b186946..d4856338600d49d59c439f8c673dfab01a72903b 100644 (file)
@@ -398,6 +398,18 @@ do_modify(
 
                rs->sr_err = slapi_int_call_plugins( op->o_bd,
                        SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
+
+               /*
+                * It's possible that the preoperation plugin changed the
+                * modification array, so we need to convert it back to
+                * a Modification list.
+                *
+                * Calling slapi_int_modifications2ldapmods() destroyed modlist so
+                * we don't need to free it.
+                */
+               slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
+               modlist = slapi_int_ldapmods2modifications( modv );
+
                if ( rs->sr_err < 0 ) {
                        /*
                         * A preoperation plugin failure will abort the
@@ -421,17 +433,6 @@ do_modify(
                        modv = NULL;
                        goto cleanup;
                }
-
-               /*
-                * It's possible that the preoperation plugin changed the
-                * modification array, so we need to convert it back to
-                * a Modification list.
-                *
-                * Calling slapi_int_modifications2ldapmods() destroyed modlist so
-                * we don't need to free it.
-                */
-               slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
-               modlist = slapi_int_ldapmods2modifications( modv );
        }
 
        /*
@@ -445,10 +446,6 @@ do_modify(
         * However, the post-operation plugin should still be 
         * called.
         */
-       if ( modlist == NULL ) {
-               rs->sr_err = LDAP_SUCCESS;
-               send_ldap_result( op, rs );
-       } else {
 #endif /* defined( LDAP_SLAPI ) */
 
        /*
@@ -535,8 +532,6 @@ do_modify(
        }
 
 #if defined( LDAP_SLAPI )
-       } /* modlist != NULL */
-
        if ( pb != NULL && slapi_int_call_plugins( op->o_bd,
                SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 )
        {
index a6f349bf3249d97a56f4423b1580f9e3deba1b51..f8111756d0f011eb2760846e039f2397f16a5a3a 100644 (file)
@@ -379,6 +379,7 @@ LDAP_SLAPD_F (void) connection_fake_init LDAP_P((
        Connection *conn,
        Operation *op,
        void *threadctx ));
+LDAP_SLAPD_F (void) connection_assign_nextid LDAP_P((Connection *));
 
 /*
  * cr.c
@@ -463,6 +464,8 @@ LDAP_SLAPD_F (int) dnMatch LDAP_P((
 LDAP_SLAPD_F (int) dnIsSuffix LDAP_P((
        const struct berval *dn, const struct berval *suffix ));
 
+LDAP_SLAPD_F (int) dnIsOneLevelRDN LDAP_P(( struct berval *rdn ));
+
 LDAP_SLAPD_F (int) dnExtractRdn LDAP_P((
        struct berval *dn, struct berval *rdn, void *ctx ));
 
@@ -504,6 +507,7 @@ LDAP_SLAPD_F (void) entry_flatsize LDAP_P((
 LDAP_SLAPD_F (int) entry_decode LDAP_P(( struct berval *bv, Entry **e ));
 LDAP_SLAPD_F (int) entry_encode LDAP_P(( Entry *e, struct berval *bv ));
 
+LDAP_SLAPD_F (void) entry_clean LDAP_P(( Entry *e ));
 LDAP_SLAPD_F (void) entry_free LDAP_P(( Entry *e ));
 LDAP_SLAPD_F (int) entry_cmp LDAP_P(( Entry *a, Entry *b ));
 LDAP_SLAPD_F (int) entry_dn_cmp LDAP_P(( const void *v_a, const void *v_b ));
@@ -949,6 +953,7 @@ LDAP_SLAPD_F (int) slap_read_controls LDAP_P(( Operation *op, SlapReply *rs,
 LDAP_SLAPD_F (int) str2result LDAP_P(( char *s,
        int *code, char **matched, char **info ));
 LDAP_SLAPD_F (int) slap_map_api2result LDAP_P(( SlapReply *rs ));
+LDAP_SLAPD_F (slap_mask_t) slap_attr_flags LDAP_P(( AttributeName *an ));
 
 /*
  * root_dse.c
index 3a71d10514fd4f190bfb188681da8ecf20516862..7911714c27fea32b8d13e786126e4ad2a1bcf882 100644 (file)
 
 int
 value_add( 
-    BerVarray *vals,
-    BerVarray addvals )
+    BerVarray  *vals,
+    BerVarray  addvals )
 {
-       int     n, nn;
-       BerVarray v2;
+       int             n, nn = 0;
+       BerVarray       v2;
 
-       for ( nn = 0; addvals != NULL && addvals[nn].bv_val != NULL; nn++ )
-               ;       /* NULL */
+       if ( addvals != NULL ) {
+               for ( ; !BER_BVISNULL( &addvals[nn] ); nn++ )
+                       ;       /* NULL */
+       }
 
        if ( *vals == NULL ) {
                *vals = (BerVarray) SLAP_MALLOC( (nn + 1)
@@ -63,8 +65,9 @@ value_add(
                        return LBER_ERROR_MEMORY;
                }
                n = 0;
+
        } else {
-               for ( n = 0; (*vals)[n].bv_val != NULL; n++ ) {
+               for ( n = 0; !BER_BVISNULL( &(*vals)[n] ); n++ ) {
                        ;       /* Empty */
                }
                *vals = (BerVarray) SLAP_REALLOC( (char *) *vals,
@@ -81,24 +84,23 @@ value_add(
                }
        }
 
-       v2 = *vals + n;
-       for ( ; addvals->bv_val; v2++, addvals++ ) {
-               ber_dupbv(v2, addvals);
-               if (v2->bv_val == NULL) break;
+       v2 = &(*vals)[n];
+       for ( ; !BER_BVISNULL( addvals ); v2++, addvals++ ) {
+               ber_dupbv( v2, addvals );
+               if ( BER_BVISNULL( v2 ) ) break;
        }
-       v2->bv_val = NULL;
-       v2->bv_len = 0;
+       BER_BVZERO( v2 );
 
        return LDAP_SUCCESS;
 }
 
 int
 value_add_one( 
-    BerVarray *vals,
-    struct berval *addval )
+    BerVarray          *vals,
+    struct berval      *addval )
 {
-       int     n;
-       BerVarray v2;
+       int             n;
+       BerVarray       v2;
 
        if ( *vals == NULL ) {
                *vals = (BerVarray) SLAP_MALLOC( 2 * sizeof(struct berval) );
@@ -113,8 +115,9 @@ value_add_one(
                        return LBER_ERROR_MEMORY;
                }
                n = 0;
+
        } else {
-               for ( n = 0; (*vals)[n].bv_val != NULL; n++ ) {
+               for ( n = 0; !BER_BVISNULL( &(*vals)[n] ); n++ ) {
                        ;       /* Empty */
                }
                *vals = (BerVarray) SLAP_REALLOC( (char *) *vals,
@@ -131,12 +134,11 @@ value_add_one(
                }
        }
 
-       v2 = *vals + n;
+       v2 = &(*vals)[n];
        ber_dupbv(v2, addval);
 
        v2++;
-       v2->bv_val = NULL;
-       v2->bv_len = 0;
+       BER_BVZERO( v2 );
 
        return LDAP_SUCCESS;
 }