#include <ac/signal.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h>
#include "ldap_pvt.h"
#include "lutil.h"
assert( c->c_conn_state != SLAP_C_INVALID );
assert( sd != AC_SOCKET_INVALID );
- c->c_activitytime = slap_get_time();
+#ifdef SLAPD_MONITOR
+ c->c_activitytime = slap_get_time();
+#else
+ if( global_idletimeout > 0 ) {
+ c->c_activitytime = slap_get_time();
+ }
+#endif
}
return c;
c->c_authmech = NULL;
c->c_dn = NULL;
c->c_cdn = NULL;
+ c->c_groups = NULL;
c->c_listener_url = NULL;
c->c_peer_domain = NULL;
assert( c->c_authmech == NULL );
assert( c->c_dn == NULL );
assert( c->c_cdn == NULL );
+ assert( c->c_groups == NULL );
assert( c->c_listener_url == NULL );
assert( c->c_peer_domain == NULL );
assert( c->c_peer_name == NULL );
/* set to zero until bind, implies LDAP_VERSION3 */
c->c_protocol = 0;
- c->c_activitytime = c->c_starttime = slap_get_time();
+#ifdef SLAPD_MONITOR
+ c->c_activitytime = c->c_starttime = slap_get_time();
+#else
+ if( global_idletimeout > 0 ) {
+ c->c_activitytime = c->c_starttime = slap_get_time();
+ }
+#endif
#ifdef LDAP_CONNECTIONLESS
c->c_is_udp = 0;
c->c_authc_backend = NULL;
c->c_authz_backend = NULL;
+
+ {
+ GroupAssertion *g, *n;
+ for (g = c->c_groups; g; g=n)
+ {
+ n = g->next;
+ free(g);
+ }
+ c->c_groups = NULL;
+ }
+
}
static void
if ( c->c_is_tls && c->c_needs_tls_accept ) {
rc = ldap_pvt_tls_accept( c->c_sb, NULL );
if ( rc < 0 ) {
+#if 0 /* required by next #if 0 */
struct timeval tv;
fd_set rfd;
+#endif
#ifdef NEW_LOGGING
LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
char peername[sizeof("IP=255.255.255.255:65336")];
len = ber_int_sb_read(conn->c_sb, &peeraddr,
sizeof(struct sockaddr));
+ if (len != sizeof(struct sockaddr))
+ return 1;
sprintf( peername, "IP=%s:%d",
inet_ntoa( peeraddr.sa_in_addr.sin_addr ),
(unsigned) ntohs( peeraddr.sa_in_addr.sin_port ) );
ber_free( ber, 1 );
return -1;
}
-#ifdef LDAP_CONNECTIONLESS
- if (conn->c_is_udp) {
- tag = ber_get_stringa( ber, &cdn );
- }
-#endif
if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) {
/* log, close and send error */
}
#ifdef LDAP_CONNECTIONLESS
- if (conn->c_is_udp && (tag != LDAP_REQ_ABANDON &&
- tag != LDAP_REQ_SEARCH))
- {
+ if (conn->c_is_udp) {
+ if (tag == LBER_OCTETSTRING) {
+ ber_get_stringa( ber, &cdn );
+ tag = ber_peek_tag(ber, &len);
+ }
+ if (tag != LDAP_REQ_ABANDON && tag != LDAP_REQ_SEARCH) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
- "connection_input: conn %d invalid req for UDP 0x%lx.\n",
- conn->c_connid, tag ));
+ LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
+ "connection_input: conn %d invalid req for UDP 0x%lx.\n",
+ conn->c_connid, tag ));
#else
- Debug( LDAP_DEBUG_ANY, "invalid req for UDP 0x%lx\n", tag, 0,
- 0 );
+ Debug( LDAP_DEBUG_ANY, "invalid req for UDP 0x%lx\n", tag, 0,
+ 0 );
#endif
- ber_free( ber, 1 );
- return 0;
+ ber_free( ber, 1 );
+ return 0;
+ }
}
#endif
if(tag == LDAP_REQ_BIND) {
#ifdef LDAP_CONNECTIONLESS
op->o_peeraddr = peeraddr;
- op->o_dn = cdn;
+ if (cdn) {
+ op->o_dn = cdn;
+ op->o_protocol = LDAP_VERSION2;
+ }
#endif
if ( conn->c_conn_state == SLAP_C_BINDING
|| conn->c_conn_state == SLAP_C_CLOSING )
arg->co_op->o_authmech = conn->c_authmech != NULL
? ch_strdup( conn->c_authmech ) : NULL;
- arg->co_op->o_protocol = conn->c_protocol
+ if (!arg->co_op->o_protocol) {
+ arg->co_op->o_protocol = conn->c_protocol
? conn->c_protocol : LDAP_VERSION3;
+ }
arg->co_op->o_connid = conn->c_connid;
slap_op_add( &conn->c_ops, arg->co_op );