X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fdaemon.c;h=bd91a1a3501b4c9c16d9ae8c8d1bcb8cf3d79dcb;hb=62b6b326338d5162b0f570eaeb8a227fbc5a9c62;hp=349e9a7580ccfae4eff32b2baaea301be2d12e4a;hpb=782d1be0ad8f1c81583810de52f4c6ee3d64d0c6;p=openldap
diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c
index 349e9a7580..bd91a1a350 100644
--- a/servers/slapd/daemon.c
+++ b/servers/slapd/daemon.c
@@ -1,7 +1,26 @@
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2004 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
+ */
+/* Portions Copyright (c) 1995 Regents of the University of Michigan.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of Michigan at Ann Arbor. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
@@ -15,10 +34,9 @@
#include
#include
-#include "ldap_pvt.h"
+#include "slap.h"
#include "ldap_pvt_thread.h"
#include "lutil.h"
-#include "slap.h"
#include "ldap_rq.h"
@@ -47,6 +65,7 @@ int slap_inet4or6 = AF_INET;
/* globals */
time_t starttime;
ber_socket_t dtblsize;
+slap_ssf_t local_ssf = LDAP_PVT_SASL_LOCAL_SSF;
Listener **slap_listeners = NULL;
@@ -64,9 +83,6 @@ static int waking;
do { if (w) tcp_write( wake_sds[1], "0", 1 ); } while(0)
#endif
-#ifndef HAVE_WINSOCK
-static
-#endif
volatile sig_atomic_t slapd_shutdown = 0, slapd_gentle_shutdown = 0;
volatile sig_atomic_t slapd_abrupt_shutdown = 0;
@@ -98,6 +114,7 @@ static struct slap_daemon {
#define LDAPS_SRVTYPE_PREFIX "service:ldaps://"
static char** slapd_srvurls = NULL;
static SLPHandle slapd_hslp = 0;
+int slapd_register_slp = 0;
void slapd_slp_init( const char* urls ) {
int i;
@@ -221,17 +238,10 @@ static void slapd_add(ber_socket_t s, int isactive) {
FD_SET( s, &slap_daemon.sd_actives );
FD_SET( s, &slap_daemon.sd_readers );
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL1,
- "slapd_add: added %ld%s%s\n", (long)s,
- FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
- FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
-#else
Debug( LDAP_DEBUG_CONNS, "daemon: added %ld%s%s\n",
(long) s,
FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
-#endif
ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
}
@@ -245,17 +255,10 @@ void slapd_remove(ber_socket_t s, int wasactive, int wake) {
slap_daemon.sd_nactives--;
}
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL1,
- "slapd_remove: removing %ld%s%s\n", (long) s,
- FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
- FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
-#else
Debug( LDAP_DEBUG_CONNS, "daemon: removing %ld%s%s\n",
(long) s,
FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
-#endif
FD_CLR( s, &slap_daemon.sd_actives );
FD_CLR( s, &slap_daemon.sd_readers );
FD_CLR( s, &slap_daemon.sd_writers );
@@ -329,12 +332,8 @@ void slapd_set_read(ber_socket_t s, int wake) {
}
static void slapd_close(ber_socket_t s) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL1, "slapd_close: closing %ld\n", (long)s, 0, 0);
-#else
Debug( LDAP_DEBUG_CONNS, "daemon: closing %ld\n",
(long) s, 0, 0 );
-#endif
tcp_close(s);
}
@@ -459,15 +458,9 @@ static int slap_get_listener_addresses(
if ( strlen(host) >
(sizeof(((struct sockaddr_un *)*sap)->sun_path) - 1) ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_get_listener_addresses: domain socket path (%s) "
- "too long in URL\n", host, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: domain socket path (%s) too long in URL",
host, 0, 0);
-#endif
goto errexit;
}
@@ -489,14 +482,8 @@ static int slap_get_listener_addresses(
snprintf(serv, sizeof serv, "%d", port);
if ( (err = getaddrinfo(host, serv, &hints, &res)) ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_get_listener_addresses: getaddrinfo failed: %s\n",
- AC_GAI_STRERROR(err), 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY, "daemon: getaddrinfo failed: %s\n",
AC_GAI_STRERROR(err), 0, 0);
-#endif
return -1;
}
@@ -514,14 +501,8 @@ static int slap_get_listener_addresses(
for ( sai=res; sai; sai=sai->ai_next ) {
if( sai->ai_addr == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_get_listener_addresses: "
- "getaddrinfo ai_addr is NULL?\n", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY, "slap_get_listener_addresses: "
"getaddrinfo ai_addr is NULL?\n", 0, 0, 0 );
-#endif
freeaddrinfo(res);
goto errexit;
}
@@ -571,13 +552,8 @@ static int slap_get_listener_addresses(
} else if ( !inet_aton( host, &in ) ) {
he = gethostbyname( host );
if( he == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_get_listener_addresses: invalid host %s\n", host, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: invalid host %s", host, 0, 0);
-#endif
return -1;
}
for (n = 0; he->h_addr_list[n]; n++) ;
@@ -639,15 +615,9 @@ static int slap_open_listener(
rc = ldap_url_parse( url, &lud );
if( rc != LDAP_URL_SUCCESS ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slap_open_listener: listen URL \"%s\" parse error %d\n",
- url, rc , 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: listen URL \"%s\" parse error=%d\n",
url, rc, 0 );
-#endif
return rc;
}
@@ -656,14 +626,9 @@ static int slap_open_listener(
#ifndef HAVE_TLS
if( ldap_pvt_url_scheme2tls( lud->lud_scheme ) ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_open_listener: TLS is not supported (%s)\n", url, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: TLS not supported (%s)\n",
url, 0, 0 );
-#endif
ldap_free_urldesc( lud );
return -1;
}
@@ -692,13 +657,8 @@ static int slap_open_listener(
}
#else
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_open_listener: URL scheme is not supported: %s\n", url, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY, "daemon: URL scheme not supported: %s",
url, 0, 0);
-#endif
ldap_free_urldesc( lud );
return -1;
#endif
@@ -764,29 +724,17 @@ static int slap_open_listener(
l.sl_sd = socket( (*sal)->sa_family, socktype, 0);
if ( l.sl_sd == AC_SOCKET_INVALID ) {
int err = sock_errno();
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slap_open_listener: %s socket() failed errno=%d (%s)\n",
- af, err, sock_errstr(err) );
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: %s socket() failed errno=%d (%s)\n",
af, err, sock_errstr(err) );
-#endif
sal++;
continue;
}
#ifndef HAVE_WINSOCK
if ( l.sl_sd >= dtblsize ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slap_open_listener: listener descriptor %ld is too "
- "great %ld\n", (long)l.sl_sd, (long)dtblsize, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: listener descriptor %ld is too great %ld\n",
(long) l.sl_sd, (long) dtblsize, 0 );
-#endif
tcp_close( l.sl_sd );
sal++;
continue;
@@ -805,16 +753,9 @@ static int slap_open_listener(
(char *) &tmp, sizeof(tmp) );
if ( rc == AC_SOCKET_ERROR ) {
int err = sock_errno();
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_open_listener: setsockopt( %ld, SO_REUSEADDR ) "
- "failed errno %d (%s)\n", (long)l.sl_sd, err,
- sock_errstr(err) );
-#else
Debug( LDAP_DEBUG_ANY,
"slapd(%ld): setsockopt(SO_REUSEADDR) failed errno=%d (%s)\n",
(long) l.sl_sd, err, sock_errstr(err) );
-#endif
}
#endif
}
@@ -832,15 +773,9 @@ static int slap_open_listener(
(char *) &tmp, sizeof(tmp) );
if ( rc == AC_SOCKET_ERROR ) {
int err = sock_errno();
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_open_listener: setsockopt( %ld, IPV6_V6ONLY ) failed errno %d (%s)\n",
- (long)l.sl_sd, err, sock_errstr(err) );
-#else
Debug( LDAP_DEBUG_ANY,
"slapd(%ld): setsockopt(IPV6_V6ONLY) failed errno=%d (%s)\n",
(long) l.sl_sd, err, sock_errstr(err) );
-#endif
}
#endif
addrlen = sizeof(struct sockaddr_in6);
@@ -855,14 +790,8 @@ static int slap_open_listener(
if (bind(l.sl_sd, *sal, addrlen)) {
err = sock_errno();
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_open_listener: bind(%ld) failed errno=%d (%s)\n",
- (long)l.sl_sd, err, sock_errstr(err) );
-#else
Debug( LDAP_DEBUG_ANY, "daemon: bind(%ld) failed errno=%d (%s)\n",
(long) l.sl_sd, err, sock_errstr(err) );
-#endif
tcp_close( l.sl_sd );
sal++;
continue;
@@ -875,14 +804,8 @@ static int slap_open_listener(
#if 0 /* don't muck with socket perms */
if ( chmod( addr, l.sl_perms ) < 0 && crit ) {
int err = sock_errno();
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_open_listener: fchmod(%ld) failed errno=%d (%s)\n",
- (long)l.sl_sd, err, sock_errstr(err) );
-#else
Debug( LDAP_DEBUG_ANY, "daemon: fchmod(%ld) failed errno=%d (%s)",
(long) l.sl_sd, err, sock_errstr(err) );
-#endif
tcp_close( l.sl_sd );
slap_free_listener_addresses(psal);
return -1;
@@ -928,14 +851,8 @@ static int slap_open_listener(
#endif /* LDAP_PF_INET6 */
default:
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_open_listener: unsupported address family (%d)\n",
- (int)(*sal)->sa_family, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY, "daemon: unsupported address family (%d)\n",
(int) (*sal)->sa_family, 0, 0 );
-#endif
break;
}
@@ -953,24 +870,13 @@ static int slap_open_listener(
if ( l.sl_url.bv_val == NULL )
{
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, RESULTS,
- "slap_open_listener: failed on %s\n", url, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE,
"slap_open_listener: failed on %s\n", url, 0, 0 );
-#endif
return -1;
}
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, RESULTS,
- "slap_open_listener: daemon initialized %s\n",
- l.sl_url.bv_val, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE, "daemon: initialized %s\n",
l.sl_url.bv_val, 0, 0 );
-#endif
return 0;
}
@@ -982,13 +888,8 @@ int slapd_daemon_init( const char *urls )
int i, j, n, rc;
char **u;
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ARGS,
- "slapd_daemon_init: %s\n", urls ? urls : "", 0, 0 );
-#else
Debug( LDAP_DEBUG_ARGS, "daemon_init: %s\n",
urls ? urls : "", 0, 0 );
-#endif
if( (rc = sockinit()) != 0 ) {
return rc;
}
@@ -1013,13 +914,8 @@ int slapd_daemon_init( const char *urls )
* this byte arrives.
*/
if( (rc = lutil_pair( wake_sds )) < 0 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slap_daemon_init: lutil_pair() failed rc=%d\n", rc, 0, 0);
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: lutil_pair() failed rc=%d\n", rc, 0, 0 );
-#endif
return rc;
}
@@ -1033,45 +929,25 @@ int slapd_daemon_init( const char *urls )
u = ldap_str2charray( urls, " " );
if( u == NULL || u[0] == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slap_daemon_init: no urls (%s) provided.\n", urls, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY, "daemon_init: no urls (%s) provided.\n",
urls, 0, 0 );
-#endif
return -1;
}
for( i=0; u[i] != NULL; i++ ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL1,
- "slap_daemon_init: listen on %s\n", u[i], 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE, "daemon_init: listen on %s\n",
u[i], 0, 0 );
-#endif
}
if( i == 0 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_daemon_init: no listeners to open (%s)\n", urls, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY, "daemon_init: no listeners to open (%s)\n",
urls, 0, 0 );
-#endif
ldap_charray_free( u );
return -1;
}
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slap_daemon_init: %d listeners to open...\n", i, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners to open...\n",
i, 0, 0 );
-#endif
slap_listeners = ch_malloc( (i+1)*sizeof(Listener *) );
for(n = 0, j = 0; u[n]; n++ ) {
@@ -1082,17 +958,14 @@ int slapd_daemon_init( const char *urls )
}
slap_listeners[j] = NULL;
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL1,
- "slap_daemon_init: %d listeners opened\n", i, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners opened\n",
i, 0, 0 );
-#endif
#ifdef HAVE_SLP
- slapd_slp_init( urls );
- slapd_slp_reg();
+ if( slapd_register_slp ) {
+ slapd_slp_init( urls );
+ slapd_slp_reg();
+ }
#endif
ldap_charray_free( u );
@@ -1110,8 +983,10 @@ slapd_daemon_destroy(void)
sockdestroy();
#ifdef HAVE_SLP
- slapd_slp_dereg();
- slapd_slp_deinit();
+ if( slapd_register_slp ) {
+ slapd_slp_dereg();
+ slapd_slp_deinit();
+ }
#endif
return 0;
@@ -1209,14 +1084,9 @@ slapd_daemon_task(
if ( i < l ) {
/* We are already listening to in6addr_any */
-#ifdef NEW_LOGGING
- LDAP_LOG(CONNECTION, WARNING,
- "slapd_daemon_task: Attempt to listen to 0.0.0.0 failed, already listening on ::, assuming IPv4 included\n", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_CONNS,
"daemon: Attempt to listen to 0.0.0.0 failed, already listening on ::, assuming IPv4 included\n",
0, 0, 0 );
-#endif
slapd_close( slap_listeners[l]->sl_sd );
slap_listeners[l]->sl_sd = AC_SOCKET_INVALID;
continue;
@@ -1224,16 +1094,10 @@ slapd_daemon_task(
}
}
#endif
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slapd_daemon_task: listen( %s, 5 ) failed errno=%d (%s)\n",
- slap_listeners[l]->sl_url.bv_val, err, sock_errstr(err) );
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: listen(%s, 5) failed errno=%d (%s)\n",
slap_listeners[l]->sl_url.bv_val, err,
sock_errstr(err) );
-#endif
return( (void*)-1 );
}
@@ -1284,7 +1148,7 @@ slapd_daemon_task(
if( slapd_gentle_shutdown == 1 ) {
Debug( LDAP_DEBUG_ANY, "slapd gentle shutdown\n", 0, 0, 0 );
close_listeners( 1 );
- global_restrictops |= SLAP_RESTRICT_OP_WRITES;
+ frontendDB->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
slapd_gentle_shutdown = 2;
}
@@ -1383,17 +1247,10 @@ slapd_daemon_task(
slap_listeners[l]->sl_is_mute )
continue;
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL1,
- "slapd_daemon_task: select: listen=%d "
- "active_threads=%d tvp=%s\n",
- slap_listeners[l]->sl_sd, at, tvp == NULL ? "NULL" : "zero" );
-#else
Debug( LDAP_DEBUG_CONNS,
"daemon: select: listen=%d active_threads=%d tvp=%s\n",
slap_listeners[l]->sl_sd, at,
tvp == NULL ? "NULL" : "zero" );
-#endif
}
switch(ns = select( nfds, &readfds,
@@ -1419,15 +1276,9 @@ slapd_daemon_task(
}
if( err != EINTR ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slapd_daemon_task: select failed (%d): %s\n",
- err, sock_errstr(err), 0 );
-#else
Debug( LDAP_DEBUG_CONNS,
"daemon: select failed (%d): %s\n",
err, sock_errstr(err), 0 );
-#endif
slapd_shutdown = 2;
}
}
@@ -1435,13 +1286,8 @@ slapd_daemon_task(
case 0: /* timeout - let threads run */
ebadf = 0;
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL2,
- "slapd_daemon_task: select timeout - yielding\n", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_CONNS, "daemon: select timeout - yielding\n",
0, 0, 0 );
-#endif
ldap_pvt_thread_yield();
continue;
@@ -1450,13 +1296,8 @@ slapd_daemon_task(
if( slapd_shutdown ) continue;
ebadf = 0;
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL2,
- "slapd_daemon_task: activity on %d descriptors\n", ns, 0, 0 );
-#else
Debug( LDAP_DEBUG_CONNS, "daemon: activity on %d descriptors\n",
ns, 0, 0 );
-#endif
/* FALL THRU */
}
@@ -1474,7 +1315,7 @@ slapd_daemon_task(
socklen_t len = sizeof(from);
long id;
slap_ssf_t ssf = 0;
- char *authid = NULL;
+ struct berval authid = BER_BVNULL;
#ifdef SLAPD_RLOOKUPS
char hbuf[NI_MAXHOST];
#endif
@@ -1482,11 +1323,12 @@ slapd_daemon_task(
char *dnsname = NULL;
char *peeraddr = NULL;
#ifdef LDAP_PF_LOCAL
- char peername[MAXPATHLEN + sizeof("PATH=")];
+ char peername[MAXPATHLEN + sizeof("PATH=")];
#elif defined(LDAP_PF_INET6)
- char peername[sizeof("IP=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 65535")];
+ char peername[sizeof(
+ "IP=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 65535")];
#else
- char peername[sizeof("IP=255.255.255.255:65336")];
+ char peername[sizeof("IP=255.255.255.255:65336")];
#endif /* LDAP_PF_LOCAL */
peername[0] = '\0';
@@ -1504,10 +1346,10 @@ slapd_daemon_task(
* of the slapd.
*/
if ( slap_listeners[l]->sl_is_udp < 2 ) {
- id = connection_init(
- slap_listeners[l]->sl_sd,
- slap_listeners[l], "", "",
- CONN_IS_UDP, ssf, authid );
+ id = connection_init(
+ slap_listeners[l]->sl_sd,
+ slap_listeners[l], "", "",
+ CONN_IS_UDP, ssf, NULL );
slap_listeners[l]->sl_is_udp++;
}
continue;
@@ -1518,6 +1360,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 ) {
@@ -1539,17 +1386,10 @@ slapd_daemon_task(
ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
}
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slapd_daemon_task: accept(%ld) failed errno=%d (%s)\n",
- (long)slap_listeners[l]->sl_sd,
- err, sock_errstr(err) );
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: accept(%ld) failed errno=%d (%s)\n",
(long) slap_listeners[l]->sl_sd, err,
sock_errstr(err) );
-#endif
ldap_pvt_thread_yield();
continue;
}
@@ -1557,15 +1397,9 @@ slapd_daemon_task(
#ifndef HAVE_WINSOCK
/* make sure descriptor number isn't too great */
if ( s >= dtblsize ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slapd_daemon_task: %ld beyond descriptor table size %ld\n",
- (long)s, (long)dtblsize, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: %ld beyond descriptor table size %ld\n",
(long) s, (long) dtblsize, 0 );
-#endif
slapd_close(s);
ldap_pvt_thread_yield();
@@ -1599,16 +1433,9 @@ slapd_daemon_task(
(char *) &tmp, sizeof(tmp) );
if ( rc == AC_SOCKET_ERROR ) {
int err = sock_errno();
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slapd_daemon_task: setsockopt( %ld, SO_KEEPALIVE)"
- " failed errno=%d (%s)\n",
- (long)s, err, sock_errstr(err) );
-#else
Debug( LDAP_DEBUG_ANY,
"slapd(%ld): setsockopt(SO_KEEPALIVE) failed "
"errno=%d (%s)\n", (long) s, err, sock_errstr(err) );
-#endif
}
#endif
#ifdef TCP_NODELAY
@@ -1618,42 +1445,39 @@ slapd_daemon_task(
(char *)&tmp, sizeof(tmp) );
if ( rc == AC_SOCKET_ERROR ) {
int err = sock_errno();
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slapd_daemon_task: setsockopt( %ld, "
- "TCP_NODELAY) failed errno=%d (%s)\n",
- (long)s, err, sock_errstr(err) );
-#else
Debug( LDAP_DEBUG_ANY,
"slapd(%ld): setsockopt(TCP_NODELAY) failed "
"errno=%d (%s)\n", (long) s, err, sock_errstr(err) );
-#endif
}
#endif
}
#endif
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL1,
- "slapd_daemon_task: new connection on %ld\n", (long)s, 0, 0 );
-#else
Debug( LDAP_DEBUG_CONNS, "daemon: new connection on %ld\n",
(long) s, 0, 0 );
-#endif
switch ( from.sa_addr.sa_family ) {
# ifdef LDAP_PF_LOCAL
case AF_LOCAL:
+ /* FIXME: apparently accept doesn't fill
+ * the sun_path sun_path member */
+ if ( from.sa_un_addr.sun_path[0] == '\0' ) {
+ AC_MEMCPY( from.sa_un_addr.sun_path,
+ slap_listeners[l]->sl_sa.sa_un_addr.sun_path,
+ sizeof( from.sa_un_addr.sun_path ) );
+ }
+
sprintf( peername, "PATH=%s", from.sa_un_addr.sun_path );
- ssf = LDAP_PVT_SASL_LOCAL_SSF;
+ ssf = local_ssf;
{
uid_t uid;
gid_t gid;
if( getpeereid( s, &uid, &gid ) == 0 ) {
- authid = ch_malloc(
+ authid.bv_val = ch_malloc(
sizeof("uidnumber=4294967295+gidnumber=4294967295,"
- "cn=peercred,cn=external,cn=auth"));
- sprintf(authid, "uidnumber=%d+gidnumber=%d,"
+ "cn=peercred,cn=external,cn=auth"));
+ authid.bv_len = sprintf( authid.bv_val,
+ "uidnumber=%d+gidnumber=%d,"
"cn=peercred,cn=external,cn=auth",
(int) uid, (int) gid);
}
@@ -1742,26 +1566,17 @@ slapd_daemon_task(
0,
#endif
ssf,
- authid );
+ authid.bv_val ? &authid : NULL );
- if( authid ) ch_free(authid);
+ if( authid.bv_val ) ch_free(authid.bv_val);
if( id < 0 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, INFO,
- "slapd_daemon_task: "
- "connection_init(%ld, %s, %s) "
- "failed.\n",
- (long)s, peername,
- slap_listeners[l]->sl_name.bv_val );
-#else
Debug( LDAP_DEBUG_ANY,
"daemon: connection_init(%ld, %s, %s) "
"failed.\n",
(long) s,
peername,
slap_listeners[l]->sl_name.bv_val );
-#endif
slapd_close(s);
continue;
}
@@ -1778,30 +1593,15 @@ slapd_daemon_task(
}
#ifdef LDAP_DEBUG
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL2,
- "slapd_daemon_task: activity on ", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_CONNS, "daemon: activity on:", 0, 0, 0 );
-#endif
#ifdef HAVE_WINSOCK
for ( i = 0; i < readfds.fd_count; i++ ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL2,
- " %d%s", readfds.fd_array[i], "r", 0, 0 );
-#else
Debug( LDAP_DEBUG_CONNS, " %d%s",
readfds.fd_array[i], "r", 0 );
-#endif
}
for ( i = 0; i < writefds.fd_count; i++ ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL2,
- " %d%s", writefds.fd_array[i], "w" , 0 );
-#else
Debug( LDAP_DEBUG_CONNS, " %d%s",
writefds.fd_array[i], "w", 0 );
-#endif
}
#else
@@ -1811,21 +1611,12 @@ slapd_daemon_task(
r = FD_ISSET( i, &readfds );
w = FD_ISSET( i, &writefds );
if ( r || w ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL2,
- " %d%s%s", i, r ? "r" : "", w ? "w" : "" );
-#else
Debug( LDAP_DEBUG_CONNS, " %d%s%s", i,
r ? "r" : "", w ? "w" : "" );
-#endif
}
}
#endif
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL2, "\n", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
-#endif
#endif
@@ -1846,14 +1637,9 @@ slapd_daemon_task(
wd = i;
#endif
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL2,
- "slapd_daemon_task: write active on %d\n", wd, 0, 0 );
-#else
Debug( LDAP_DEBUG_CONNS,
"daemon: write active on %d\n",
wd, 0, 0 );
-#endif
/*
* NOTE: it is possible that the connection was closed
* and that the stream is now inactive.
@@ -1883,13 +1669,8 @@ slapd_daemon_task(
rd = i;
#endif
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, DETAIL2,
- "slapd_daemon_task: read activity on %d\n", rd, 0, 0 );
-#else
Debug ( LDAP_DEBUG_CONNS,
"daemon: read activity on %d\n", rd, 0, 0 );
-#endif
/*
* NOTE: it is possible that the connection was closed
* and that the stream is now inactive.
@@ -1905,47 +1686,24 @@ slapd_daemon_task(
}
if( slapd_shutdown == 1 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, CRIT,
- "slapd_daemon_task: shutdown requested and initiated.\n", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE,
"daemon: shutdown requested and initiated.\n",
0, 0, 0 );
-#endif
} else if ( slapd_shutdown == 2 ) {
#ifdef HAVE_NT_SERVICE_MANAGER
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, CRIT,
- "slapd_daemon_task: shutdown initiated by Service Manager.\n",
- 0, 0, 0);
-#else
Debug( LDAP_DEBUG_TRACE,
"daemon: shutdown initiated by Service Manager.\n",
0, 0, 0);
-#endif
#else /* !HAVE_NT_SERVICE_MANAGER */
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, CRIT,
- "slapd_daemon_task: abnormal condition, "
- "shutdown initiated.\n", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE,
"daemon: abnormal condition, shutdown initiated.\n",
0, 0, 0 );
-#endif
#endif /* !HAVE_NT_SERVICE_MANAGER */
} else {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, CRIT,
- "slapd_daemon_task: no active streams, shutdown initiated.\n",
- 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE,
"daemon: no active streams, shutdown initiated.\n",
0, 0, 0 );
-#endif
}
if( slapd_gentle_shutdown != 2 ) {
@@ -1960,15 +1718,9 @@ slapd_daemon_task(
connections_shutdown();
}
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, CRIT,
- "slapd_daemon_task: shutdown waiting for %d threads to terminate.\n",
- ldap_pvt_thread_pool_backload(&connection_pool), 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"slapd shutdown: waiting for %d threads to terminate\n",
ldap_pvt_thread_pool_backload(&connection_pool), 0, 0 );
-#endif
ldap_pvt_thread_pool_destroy(&connection_pool, 1);
return NULL;
@@ -1991,14 +1743,8 @@ int slapd_daemon( void )
0, slapd_daemon_task, NULL );
if ( rc != 0 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, ERR,
- "slapd_daemon: listener ldap_pvt_thread_create failed (%d).\n",
- rc, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"listener ldap_pvt_thread_create failed (%d)\n", rc, 0, 0 );
-#endif
return rc;
}
@@ -2067,12 +1813,7 @@ RETSIGTYPE
slap_sig_shutdown( int sig )
{
#if 0
-#ifdef NEW_LOGGING
- LDAP_LOG( CONNECTION, CRIT,
- "slap_sig_shutdown: signal %d\n", sig, 0, 0 );
-#else
Debug(LDAP_DEBUG_TRACE, "slap_sig_shutdown: signal %d\n", sig, 0, 0);
-#endif
#endif
/*
@@ -2116,3 +1857,8 @@ void slapd_add_internal(ber_socket_t s, int isactive) {
Listener ** slapd_get_listeners(void) {
return slap_listeners;
}
+
+void slap_wake_listener()
+{
+ WAKE_LISTENER(1);
+}