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);
*/
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;
}
/* 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) */
/* 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) );
connections = NULL;
ldap_pvt_thread_mutex_destroy( &connections_mutex );
+ ldap_pvt_thread_mutex_destroy( &conn_nextid_mutex );
return 0;
}
#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;
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,
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 */
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 );
+}
+
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 ) {
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
}
void
-entry_free( Entry *e )
+entry_clean( Entry *e )
{
/* free an entry structure */
assert( e != NULL );
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 );
}
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
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 );
}
/*
* 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 ) */
/*
}
#if defined( LDAP_SLAPI )
- } /* modlist != NULL */
-
if ( pb != NULL && slapi_int_call_plugins( op->o_bd,
SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 )
{
Connection *conn,
Operation *op,
void *threadctx ));
+LDAP_SLAPD_F (void) connection_assign_nextid LDAP_P((Connection *));
/*
* cr.c
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 ));
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 ));
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
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)
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,
}
}
- 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) );
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,
}
}
- 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;
}