#include <ac/socket.h>
#include <ac/errno.h>
-#include <ac/signal.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
c->c_dn.bv_len = 0;
c->c_ndn.bv_val = NULL;
c->c_ndn.bv_len = 0;
- c->c_cdn.bv_val = NULL;
- c->c_cdn.bv_len = 0;
c->c_groups = NULL;
c->c_listener_url.bv_val = NULL;
assert( c->c_authmech.bv_val == NULL );
assert( c->c_dn.bv_val == NULL );
assert( c->c_ndn.bv_val == NULL );
- assert( c->c_cdn.bv_val == NULL );
assert( c->c_groups == NULL );
assert( c->c_listener_url.bv_val == NULL );
assert( c->c_peer_domain.bv_val == NULL );
void connection2anonymous( Connection *c )
{
- assert( connections != NULL );
- assert( c != NULL );
+ assert( connections != NULL );
+ assert( c != NULL );
{
ber_len_t max = sockbuf_max_incoming;
}
c->c_authmech.bv_len = 0;
- if(c->c_dn.bv_val != NULL) {
- free(c->c_dn.bv_val);
- c->c_dn.bv_val = NULL;
- }
- c->c_dn.bv_len = 0;
- if(c->c_ndn.bv_val != NULL) {
- free(c->c_ndn.bv_val);
- c->c_ndn.bv_val = NULL;
- }
- c->c_ndn.bv_len = 0;
-
- if(c->c_cdn.bv_val != NULL) {
- free(c->c_cdn.bv_val);
- c->c_cdn.bv_val = NULL;
+ if(c->c_dn.bv_val != NULL) {
+ free(c->c_dn.bv_val);
+ c->c_dn.bv_val = NULL;
+ }
+ c->c_dn.bv_len = 0;
+ if(c->c_ndn.bv_val != NULL) {
+ free(c->c_ndn.bv_val);
+ c->c_ndn.bv_val = NULL;
}
- c->c_cdn.bv_len = 0;
+ c->c_ndn.bv_len = 0;
- c->c_authc_backend = NULL;
c->c_authz_backend = NULL;
-
- {
- GroupAssertion *g, *n;
- for (g = c->c_groups; g; g=n)
+
{
- n = g->ga_next;
- free(g);
+ GroupAssertion *g, *n;
+ for (g = c->c_groups; g; g=n) {
+ n = g->ga_next;
+ free(g);
+ }
+ c->c_groups = NULL;
}
- c->c_groups = NULL;
- }
-
}
static void
{
/* note: connections_mutex should be locked by caller */
ber_socket_t sd;
+ unsigned long connid;
assert( connections != NULL );
assert( c != NULL );
assert( c->c_conn_state != SLAP_C_INVALID );
assert( LDAP_STAILQ_EMPTY(&c->c_ops) );
+ /* only for stats (print -1 as "%lu" may give unexpected results ;) */
+ connid = c->c_connid;
+
backend_connection_destroy(c);
c->c_protocol = 0;
Statslog( LDAP_DEBUG_STATS,
"conn=%lu fd=%d closed\n",
- c->c_connid, sd, 0, 0, 0 );
+ connid, sd, 0, 0, 0 );
}
ber_sockbuf_free( c->c_sb );
Operation *o;
LDAP_STAILQ_FOREACH(o, &c->c_ops, o_next) {
- ldap_pvt_thread_mutex_lock( &o->o_abandonmutex );
o->o_abandon = 1;
- ldap_pvt_thread_mutex_unlock( &o->o_abandonmutex );
}
/* remove pending operations */
* calls the appropriate stub to handle it.
*/
+#ifdef SLAPD_MONITOR
+#define INCR_OP(var,index) \
+ do { \
+ ldap_pvt_thread_mutex_lock( &num_ops_mutex ); \
+ (var)[(index)]++; \
+ ldap_pvt_thread_mutex_unlock( &num_ops_mutex ); \
+ } while (0)
+#else /* !SLAPD_MONITOR */
+#define INCR_OP(var,index)
+#endif /* !SLAPD_MONITOR */
+
static void *
connection_operation( void *arg_v )
{
int rc;
struct co_arg *arg = arg_v;
ber_tag_t tag = arg->co_op->o_tag;
+#ifdef SLAPD_MONITOR
+ ber_tag_t oldtag = tag;
+#endif /* SLAPD_MONITOR */
Connection *conn = arg->co_conn;
ldap_pvt_thread_mutex_lock( &num_ops_mutex );
switch ( tag ) {
case LDAP_REQ_BIND:
+ INCR_OP(num_ops_initiated_, SLAP_OP_BIND);
rc = do_bind( conn, arg->co_op );
break;
case LDAP_REQ_UNBIND:
+ INCR_OP(num_ops_initiated_, SLAP_OP_UNBIND);
rc = do_unbind( conn, arg->co_op );
break;
case LDAP_REQ_ADD:
+ INCR_OP(num_ops_initiated_, SLAP_OP_ADD);
rc = do_add( conn, arg->co_op );
break;
case LDAP_REQ_DELETE:
+ INCR_OP(num_ops_initiated_, SLAP_OP_DELETE);
rc = do_delete( conn, arg->co_op );
break;
case LDAP_REQ_MODRDN:
+ INCR_OP(num_ops_initiated_, SLAP_OP_MODRDN);
rc = do_modrdn( conn, arg->co_op );
break;
case LDAP_REQ_MODIFY:
+ INCR_OP(num_ops_initiated_, SLAP_OP_MODIFY);
rc = do_modify( conn, arg->co_op );
break;
case LDAP_REQ_COMPARE:
+ INCR_OP(num_ops_initiated_, SLAP_OP_COMPARE);
rc = do_compare( conn, arg->co_op );
break;
case LDAP_REQ_SEARCH:
+ INCR_OP(num_ops_initiated_, SLAP_OP_SEARCH);
rc = do_search( conn, arg->co_op );
break;
case LDAP_REQ_ABANDON:
+ INCR_OP(num_ops_initiated_, SLAP_OP_ABANDON);
rc = do_abandon( conn, arg->co_op );
break;
case LDAP_REQ_EXTENDED:
+ INCR_OP(num_ops_initiated_, SLAP_OP_EXTENDED);
rc = do_extended( conn, arg->co_op );
break;
break;
}
+#ifdef SLAPD_MONITOR
+ oldtag = tag;
+#endif /* SLAPD_MONITOR */
if( rc == SLAPD_DISCONNECT ) tag = LBER_ERROR;
operations_error:
ldap_pvt_thread_mutex_lock( &num_ops_mutex );
num_ops_completed++;
+#ifdef SLAPD_MONITOR
+ switch (oldtag) {
+ case LDAP_REQ_BIND:
+ num_ops_completed_[SLAP_OP_BIND]++;
+ break;
+ case LDAP_REQ_UNBIND:
+ num_ops_completed_[SLAP_OP_UNBIND]++;
+ break;
+ case LDAP_REQ_ADD:
+ num_ops_completed_[SLAP_OP_ADD]++;
+ break;
+ case LDAP_REQ_DELETE:
+ num_ops_completed_[SLAP_OP_DELETE]++;
+ break;
+ case LDAP_REQ_MODRDN:
+ num_ops_completed_[SLAP_OP_MODRDN]++;
+ break;
+ case LDAP_REQ_MODIFY:
+ num_ops_completed_[SLAP_OP_MODIFY]++;
+ break;
+ case LDAP_REQ_COMPARE:
+ num_ops_completed_[SLAP_OP_COMPARE]++;
+ break;
+ case LDAP_REQ_SEARCH:
+ num_ops_completed_[SLAP_OP_SEARCH]++;
+ break;
+ case LDAP_REQ_ABANDON:
+ num_ops_completed_[SLAP_OP_ABANDON]++;
+ break;
+ case LDAP_REQ_EXTENDED:
+ num_ops_completed_[SLAP_OP_EXTENDED]++;
+ break;
+ }
+#endif /* SLAPD_MONITOR */
ldap_pvt_thread_mutex_unlock( &num_ops_mutex );
ldap_pvt_thread_mutex_lock( &conn->c_mutex );
} else if ( rc == 0 ) {
void *ssl;
- char *authid;
+ struct berval authid = { 0, NULL };
c->c_needs_tls_accept = 0;
/* we need to let SASL know */
- ssl = (void *)ldap_pvt_tls_sb_ctx( c->c_sb );
+ ssl = ldap_pvt_tls_sb_ctx( c->c_sb );
c->c_tls_ssf = (slap_ssf_t) ldap_pvt_tls_get_strength( ssl );
if( c->c_tls_ssf > c->c_ssf ) {
c->c_ssf = c->c_tls_ssf;
}
- authid = (char *)ldap_pvt_tls_get_peer( ssl );
- slap_sasl_external( c, c->c_tls_ssf, authid );
+ rc = dnX509peerNormalize( ssl, &authid );
+ if ( rc != LDAP_SUCCESS ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
+ "connection_read: conn %lu unable to get TLS client DN, error %d\n",
+ c->c_connid, rc));
+#else
+ Debug( LDAP_DEBUG_TRACE,
+ "connection_read(%d): unable to get TLS client DN "
+ "error=%d id=%lu\n",
+ s, rc, c->c_connid );
+#endif
+ }
+ slap_sasl_external( c, c->c_tls_ssf, authid.bv_val );
+ if ( authid.bv_val ) free( authid.bv_val );
}
connection_return( c );
ldap_pvt_thread_mutex_unlock( &connections_mutex );
op = slap_op_alloc( ber, msgid, tag, conn->c_n_ops_received++ );
+ op->vrFilter = NULL;
+
op->o_pagedresults_state = conn->c_pagedresults_state;
#ifdef LDAP_CONNECTIONLESS