From: Gary Williams Date: Mon, 15 Jan 2001 19:17:29 +0000 (+0000) Subject: More new logging (Behind NEW_LOGGING) X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1595 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ffcdc6d11d7e86260be64e47229ca75bc7b7ac20;p=openldap More new logging (Behind NEW_LOGGING) --- diff --git a/servers/slapd/ava.c b/servers/slapd/ava.c index 1b57254f6b..61564158f4 100644 --- a/servers/slapd/ava.c +++ b/servers/slapd/ava.c @@ -43,7 +43,12 @@ get_ava( rc = ber_scanf( ber, "{oo}", &type, &value ); if( rc == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + "get_ava: ber_scanf failure\n" )); +#else Debug( LDAP_DEBUG_ANY, " get_ava ber_scanf\n", 0, 0, 0 ); +#endif *text = "Error decoding attribute value assertion"; return SLAPD_DISCONNECT; } diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 5020b4509d..9256f5600c 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -118,11 +118,18 @@ static void slapd_add(ber_socket_t s) { FD_SET( s, &slap_daemon.sd_actives ); FD_SET( s, &slap_daemon.sd_readers ); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_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 ); } @@ -132,11 +139,18 @@ static void slapd_add(ber_socket_t s) { void slapd_remove(ber_socket_t s, int wake) { ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex ); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_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 ); @@ -188,8 +202,13 @@ void slapd_set_read(ber_socket_t s, int wake) { } static void slapd_close(ber_socket_t s) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, + "slapd_close: closing %ld\n", (long)s )); +#else Debug( LDAP_DEBUG_CONNS, "daemon: closing %ld\n", (long) s, 0, 0 ); +#endif tcp_close(s); } @@ -227,8 +246,14 @@ static int slap_get_listener_addresses( hints.ai_family = AF_LOCAL; /* host specifies a service in this case */ if (err = getaddrinfo(NULL, host, &hints, &res)) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slap_get_listener_addresses: getaddrinfo failed: %s\n", + AC_GAI_STRERROR(err) )); +#else Debug( LDAP_DEBUG_ANY, "daemon: getaddrinfo failed: %s\n", AC_GAI_STRERROR(err), 0, 0); +#endif return -1; } } else @@ -239,8 +264,14 @@ static int slap_get_listener_addresses( snprintf(serv, sizeof serv, "%d", port); hints.ai_family = AF_UNSPEC; if (err = getaddrinfo(host, serv, &hints, &res)) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slap_get_listener_addresses: getaddrinfo failed: %s\n", + AC_GAI_STRERROR(err) )); +#else Debug( LDAP_DEBUG_ANY, "daemon: getaddrinfo failed: %s\n", AC_GAI_STRERROR(err), 0, 0); +#endif return -1; } } @@ -316,9 +347,15 @@ static int slap_get_listener_addresses( (*sap)->sa_family = AF_LOCAL; if ( strlen(host) > (sizeof(((struct sockaddr_un *)*sal)->sun_path) - 1) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slap_get_listener_addresses: domain socket path (%s) too long in URL\n", + host )); +#else Debug( LDAP_DEBUG_ANY, "daemon: domain socket path (%s) too long in URL", host, 0, 0); +#endif goto errexit; } strcpy( ((struct sockaddr_un *)*sap)->sun_path, host ); @@ -333,8 +370,14 @@ static int slap_get_listener_addresses( } else if ( !inet_aton( host, &in ) ) { struct hostent *he = gethostbyname( host ); if( he == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slap_get_listener_addresses: invalid host %s\n", + host )); +#else Debug( LDAP_DEBUG_ANY, "daemon: invalid host %s", host, 0, 0); +#endif return -1; } AC_MEMCPY( &in, he->h_addr, sizeof( in ) ); @@ -381,17 +424,29 @@ static Listener * slap_open_listener( rc = ldap_url_parse( url, &lud ); if( rc != LDAP_URL_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + "slap_open_listener: listen URL \"%s\" parse error %d\n", + url, rc )); +#else Debug( LDAP_DEBUG_ANY, "daemon: listen URL \"%s\" parse error=%d\n", url, rc, 0 ); +#endif return NULL; } #ifndef HAVE_TLS if( ldap_pvt_url_scheme2tls( lud->lud_scheme ) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slap_open_listener: TLS is not supported (%s)\n", + url )); +#else Debug( LDAP_DEBUG_ANY, "daemon: TLS not supported (%s)\n", url, 0, 0 ); +#endif ldap_free_urldesc( lud ); return NULL; } @@ -418,8 +473,15 @@ static Listener * slap_open_listener( err = slap_get_listener_addresses(lud->lud_host, 0, &sal); } #else + +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slap_open_listener: URL scheme is not supported: %s\n", + url )); +#else Debug( LDAP_DEBUG_ANY, "daemon: URL scheme not supported: %s", url, 0, 0); +#endif ldap_free_urldesc( lud ); return NULL; #endif @@ -456,17 +518,29 @@ static Listener * slap_open_listener( l.sl_sd = socket( (*sal)->sa_family, SOCK_STREAM, 0); if ( l.sl_sd == AC_SOCKET_INVALID ) { int err = sock_errno(); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + "slap_open_listener: socket() failed errno=%d (%s)\n", + err, sock_errstr(err) )); +#else Debug( LDAP_DEBUG_ANY, "daemon: socket() failed errno=%d (%s)\n", err, sock_errstr(err), 0 ); +#endif sal++; continue; } #ifndef HAVE_WINSOCK if ( l.sl_sd >= dtblsize ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + "slap_open_listener: listener descriptor %ld is too great %ld\n", + (long)l.sl_sd, (long)dtblsize )); +#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; @@ -485,9 +559,15 @@ static Listener * slap_open_listener( (char *) &tmp, sizeof(tmp) ); if ( rc == AC_SOCKET_ERROR ) { int err = sock_errno(); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_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 } @@ -511,15 +591,26 @@ static Listener * slap_open_listener( if (!bind(l.sl_sd, *sal, addrlen)) break; err = sock_errno(); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_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++; } /* while ( *sal != NULL ) */ if ( *sal == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slap_open_listener: bind(%ld) failed.\n", (long)l.sl_sd )); +#else Debug( LDAP_DEBUG_ANY, "daemon: bind(%ld) failed\n", (long) l.sl_sd, 0, 0 ); +#endif slap_free_listener_addresses(psal); return NULL; } @@ -530,8 +621,14 @@ static Listener * slap_open_listener( char *addr = ((struct sockaddr_un *)*sal)->sun_path; if ( chmod( addr, S_IRWXU ) < 0 ) { int err = sock_errno(); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_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 NULL; @@ -567,8 +664,14 @@ static Listener * slap_open_listener( #endif /* LDAP_PF_INET6 */ default: +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slap_open_listener: unsupported address family (%d)\n", + (int)(*sal)->sa_family )); +#else Debug( LDAP_DEBUG_ANY, "daemon: unsupported address family (%d)\n", (int) (*sal)->sa_family, 0, 0 ); +#endif break; } @@ -578,9 +681,13 @@ static Listener * slap_open_listener( li = ch_malloc( sizeof( Listener ) ); *li = l; +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_RESULTS, + "slap_open_listener: daemon initialzed %s\n", l.sl_url )); +#else Debug( LDAP_DEBUG_TRACE, "daemon: initialized %s\n", l.sl_url, 0, 0 ); - +#endif return li; } @@ -592,9 +699,14 @@ int slapd_daemon_init( const char *urls ) int i, rc; char **u; +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_ARGS, + "slapd_daemon_init: %s\n", + urls ? urls : "" )); +#else Debug( LDAP_DEBUG_ARGS, "daemon_init: %s\n", urls ? urls : "", 0, 0 ); - +#endif if( (rc = sockinit()) != 0 ) { return rc; } @@ -619,8 +731,13 @@ int slapd_daemon_init( const char *urls ) * this byte arrives. */ if( (rc = lutil_pair( wake_sds )) < 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + "slap_daemon_init: lutil_pair() failed rc=%d\n", rc )); +#else Debug( LDAP_DEBUG_ANY, "daemon: lutil_pair() failed rc=%d\n", rc, 0, 0 ); +#endif return rc; } @@ -634,27 +751,45 @@ int slapd_daemon_init( const char *urls ) u = str2charray( urls, " " ); if( u == NULL || u[0] == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + "slap_daemon_init: no urls (%s) provided.\n", urls )); +#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", LDAP_LEVEL_DETAIL1, + "slap_daemon_init: listen on %s\n.", u[i] )); +#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", LDAP_LEVEL_INFO, + "slap_daemon_init: no listeners to open (%s)\n", urls )); +#else Debug( LDAP_DEBUG_ANY, "daemon_init: no listeners to open (%s)\n", urls, 0, 0 ); +#endif charray_free( u ); return -1; } +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slap_daemon_init: %d listeners to open...\n", i )); +#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(i = 0; u[i] != NULL; i++ ) { @@ -667,9 +802,13 @@ int slapd_daemon_init( const char *urls ) } slap_listeners[i] = NULL; +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1, + "slap_daemon_init: %d listeners opened\n", i )); +#else Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners opened\n", i, 0, 0 ); - +#endif charray_free( u ); ldap_pvt_thread_mutex_init( &slap_daemon.sd_mutex ); return !i; @@ -702,10 +841,16 @@ slapd_daemon_task( if ( listen( slap_listeners[l]->sl_sd, SLAPD_LISTEN ) == -1 ) { int err = sock_errno(); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + "slapd_daemon_task: listen( %s, 5 ) failed errno=%d (%s)\n", + slap_listeners[l]->sl_url, err, sock_errstr(err) )); +#else Debug( LDAP_DEBUG_ANY, "daemon: listen(%s, 5) failed errno=%d (%s)\n", slap_listeners[l]->sl_url, err, sock_errstr(err) ); +#endif return( (void*)-1 ); } @@ -799,10 +944,16 @@ slapd_daemon_task( if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID ) continue; +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_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, @@ -828,10 +979,15 @@ slapd_daemon_task( } if( err != EINTR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slapd_daemon_task: select failed (%d): %s\n", + err, sock_errstr(err) )); +#else Debug( LDAP_DEBUG_CONNS, "daemon: select failed (%d): %s\n", err, sock_errstr(err), 0 ); - +#endif slapd_shutdown = -1; } } @@ -839,8 +995,13 @@ slapd_daemon_task( case 0: /* timeout - let threads run */ ebadf = 0; +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, + "slapd_daemon_task: select timeout - yielding\n" )); +#else Debug( LDAP_DEBUG_CONNS, "daemon: select timeout - yielding\n", 0, 0, 0 ); +#endif ldap_pvt_thread_yield(); continue; @@ -848,8 +1009,13 @@ slapd_daemon_task( if( slapd_shutdown ) continue; ebadf = 0; +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, + "slapd_daemon_task: activity on %d descriptors\n", ns )); +#else Debug( LDAP_DEBUG_CONNS, "daemon: activity on %d descriptors\n", ns, 0, 0 ); +#endif /* FALL THRU */ } @@ -891,19 +1057,31 @@ slapd_daemon_task( (struct sockaddr *) &from, &len ); if ( s == AC_SOCKET_INVALID ) { int err = sock_errno(); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_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 continue; } #ifndef HAVE_WINSOCK /* make sure descriptor number isn't too great */ if ( s >= dtblsize ) { +#ifdef NEW_LGGING + LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + "slapd_daemon_task: %ld beyond descriptor table size %ld\n", + (long)s, (long)dtblsize )); +#else Debug( LDAP_DEBUG_ANY, "daemon: %ld beyond descriptor table size %ld\n", (long) s, (long) dtblsize, 0 ); +#endif slapd_close(s); continue; } @@ -935,9 +1113,15 @@ slapd_daemon_task( (char *) &tmp, sizeof(tmp) ); if ( rc == AC_SOCKET_ERROR ) { int err = sock_errno(); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_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 @@ -947,17 +1131,27 @@ slapd_daemon_task( (char *)&tmp, sizeof(tmp) ); if ( rc == AC_SOCKET_ERROR ) { int err = sock_errno(); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_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", LDAP_LEVEL_DETAIL1, + "slapd_daemon_task: new connection on %ld\n", (long)s )); +#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: @@ -1055,11 +1249,17 @@ slapd_daemon_task( if( authid ) ch_free(authid); if( id < 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slapd_daemon_task: connection_init(%ld, %s, %s) failed.\n", + (long)s, peername, slap_listeners[l]->sl_name )); +#else Debug( LDAP_DEBUG_ANY, "daemon: connection_init(%ld, %s, %s) failed.\n", (long) s, peername, slap_listeners[l]->sl_name ); +#endif slapd_close(s); continue; } @@ -1076,16 +1276,32 @@ slapd_daemon_task( } #ifdef LDAP_DEBUG +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, + "slapd_daemon_task: activity on " )); +#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", LDAP_LEVEL_DETAIL2, + " %d%s", readfs.fd_array[i], "r", 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", LDAP_LEVEL_DETAIL2, + " %d%s", writefds.fd_array[i], "w" )); +#else Debug( LDAP_DEBUG_CONNS, " %d%s", writefds.fd_array[i], "w", 0 ); +#endif } + #else for ( i = 0; i < nfds; i++ ) { int r, w; @@ -1103,12 +1319,23 @@ slapd_daemon_task( r = FD_ISSET( i, &readfds ); w = FD_ISSET( i, &writefds ); if ( r || w ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_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", LDAP_LEVEL_DETAIL2, "\n" )); +#else Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 ); +#endif + #endif /* loop through the writers */ @@ -1138,10 +1365,14 @@ slapd_daemon_task( if ( is_listener ) { continue; } +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, + "slapd_daemon_task: write active on %d\n", wd )); +#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. @@ -1183,9 +1414,13 @@ slapd_daemon_task( continue; } +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, + "slapd_daemon_task: read activity on %d\n", rd )); +#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. @@ -1201,25 +1436,45 @@ slapd_daemon_task( } if( slapd_shutdown > 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, + "slapd_daemon_task: shutdown requested and initiated.\n")); +#else Debug( LDAP_DEBUG_TRACE, "daemon: shutdown requested and initiated.\n", 0, 0, 0 ); +#endif } else if ( slapd_shutdown < 0 ) { #ifdef HAVE_NT_SERVICE_MANAGER if (slapd_shutdown == -1) +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, + "slapd_daemon_task: shutdown initiated by Service Manager.\n")); +#else Debug( LDAP_DEBUG_TRACE, "daemon: shutdown initiated by Service Manager.\n", 0, 0, 0); +#endif else #endif +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, + "slapd_daemon_task: abnormal condition, shutdown initiated.\n" )); +#else Debug( LDAP_DEBUG_TRACE, "daemon: abnormal condition, shutdown initiated.\n", 0, 0, 0 ); +#endif } else { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, + "slapd_daemon_task: no active streams, shutdown initiated.\n" )); +#else Debug( LDAP_DEBUG_TRACE, "daemon: no active streams, shutdown initiated.\n", 0, 0, 0 ); +#endif } for ( l = 0; slap_listeners[l] != NULL; l++ ) { @@ -1234,10 +1489,15 @@ slapd_daemon_task( } } +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, + "slapd_daemon_task: shutdown waiting for %d threads to terminate.\n", + ldap_pvt_thread_pool_backload(&connection_pool) )); +#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; @@ -1260,8 +1520,13 @@ int slapd_daemon( void ) 0, slapd_daemon_task, NULL ); if ( rc != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_ERR, + "slapd_daemon: listener ldap_pvt_thread_create failed (%d).\n", rc )); +#else Debug( LDAP_DEBUG_ANY, "listener ldap_pvt_thread_create failed (%d)\n", rc, 0, 0 ); +#endif return rc; } @@ -1329,7 +1594,12 @@ int sockdestroy(void) RETSIGTYPE slap_sig_shutdown( int sig ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, + "slap_sig_shutdown: signal %d\n", sig )); +#else Debug(LDAP_DEBUG_TRACE, "slap_sig_shutdown: signal %d\n", sig, 0, 0); +#endif /* * If the NT Service Manager is controlling the server, we don't @@ -1339,8 +1609,13 @@ slap_sig_shutdown( int sig ) #if HAVE_NT_SERVICE_MANAGER && SIGBREAK if (is_NT_Service && sig == SIGBREAK) +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, + "slap_sig_shutdown: SIGBREAK ignored.\n" )); +#else Debug(LDAP_DEBUG_TRACE, "slap_sig_shutdown: SIGBREAK ignored.\n", 0, 0, 0); +#endif else #endif slapd_shutdown = sig; diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index c253949f7b..e102698c67 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -37,7 +37,12 @@ do_delete( int rc; int manageDSAit; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "do_delete: conn %d\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 ); +#endif /* * Parse the delete request. It looks like this: @@ -46,28 +51,48 @@ do_delete( */ if ( ber_scanf( op->o_ber, "a", &dn ) == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_delete: conn: %d ber_scanf failed\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 ); +#endif send_ldap_disconnect( conn, op, LDAP_PROTOCOL_ERROR, "decoding error" ); return SLAPD_DISCONNECT; } if( ( rc = get_ctrls( conn, op, 1 ) ) != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "oepration", LDAP_LEVEL_ERR, + "do_delete: conn %d get_ctrls failed\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_ANY, "do_delete: get_ctrls failed\n", 0, 0, 0 ); +#endif goto cleanup; } ndn = ch_strdup( dn ); if( dn_normalize( ndn ) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_delete: conn %d invalid dn (%s).\n", conn->c_connid, dn )); +#else Debug( LDAP_DEBUG_ANY, "do_delete: invalid dn (%s)\n", dn, 0, 0 ); +#endif send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, "invalid DN", NULL, NULL ); goto cleanup; } if( ndn == '\0' ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "do_delete: conn %d Attempt to delete root DSE.\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_ANY, "do_delete: root dse!\n", 0, 0, 0 ); +#endif /* protocolError would likely be a more appropriate error */ send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL, "cannot delete the root DSE", NULL, NULL ); diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index f8d4e59d0c..0f6937168a 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -235,8 +235,14 @@ dn_validate( char *dn_in ) default: dn = NULL; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "dn_validate: unknown state %d for dn \"%s\".\n", + state, dn_in )); +#else Debug( LDAP_DEBUG_ANY, "dn_validate - unknown state %d\n", state, 0, 0 ); +#endif break; } diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 21f8796db8..720fa5c7e5 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -58,16 +58,26 @@ str2entry( char *s ) * or newline. */ +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + "str2entry: \"%s\"\n", s ? s : "NULL" )); +#else Debug( LDAP_DEBUG_TRACE, "=> str2entry\n", s ? s : "NULL", 0, 0 ); +#endif /* initialize reader/writer lock */ e = (Entry *) ch_malloc( sizeof(Entry) ); if( e == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "str2entry: entry allocation failed.\n" )); +#else Debug( LDAP_DEBUG_ANY, "<= str2entry NULL (entry allocation failed)\n", 0, 0, 0 ); +#endif return( NULL ); } @@ -89,8 +99,13 @@ str2entry( char *s ) } if ( ldif_parse_line( s, &type, &value.bv_val, &value.bv_len ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "str2entry: NULL (parse_line)\n" )); +#else Debug( LDAP_DEBUG_TRACE, "<= str2entry NULL (parse_line)\n", 0, 0, 0 ); +#endif continue; } @@ -98,10 +113,16 @@ str2entry( char *s ) free( type ); if ( e->e_dn != NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "str2entry: entry %ld has multiple dns \"%s\" and \"%s\" (second ignored)\n", + e->e_id, e->e_dn, value.bv_val != NULL ? value.bv_val : "" )); +#else Debug( LDAP_DEBUG_ANY, "str2entry: entry %ld has multiple dns \"%s\" and \"%s\" (second ignored)\n", e->e_id, e->e_dn, value.bv_val != NULL ? value.bv_val : "" ); +#endif if( value.bv_val != NULL ) free( value.bv_val ); continue; } @@ -114,10 +135,14 @@ str2entry( char *s ) rc = slap_str2ad( type, &ad, &text ); if( rc != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "str2entry: str2ad(%s): %s\n", type, text )); +#else Debug( slapMode & SLAP_TOOL_MODE ? LDAP_DEBUG_ANY : LDAP_DEBUG_TRACE, "<= str2entry: str2ad(%s): %s\n", type, text, 0 ); - +#endif if( slapMode & SLAP_TOOL_MODE ) { entry_free( e ); free( value.bv_val ); @@ -128,9 +153,14 @@ str2entry( char *s ) rc = slap_str2undef_ad( type, &ad, &text ); if( rc != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "str2entry: str2undef_ad(%s): %s\n", type, text )); +#else Debug( LDAP_DEBUG_ANY, "<= str2entry: str2undef_ad(%s): %s\n", type, text, 0 ); +#endif entry_free( e ); free( value.bv_val ); free( type ); @@ -143,9 +173,15 @@ str2entry( char *s ) ad->ad_type->sat_syntax->ssyn_validate; if( !validate ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "str2entry: no validator for syntax %s\n", + ad->ad_type->sat_syntax->ssyn_oid )); +#else Debug( LDAP_DEBUG_ANY, "str2entry: no validator for syntax %s\n", ad->ad_type->sat_syntax->ssyn_oid, 0, 0 ); +#endif entry_free( e ); free( value.bv_val ); free( type ); @@ -158,9 +194,15 @@ str2entry( char *s ) rc = validate( ad->ad_type->sat_syntax, &value ); if( rc != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "str2entry: invalid value for syntax %s\n", + ad->ad_type->sat_syntax->ssyn_oid )); +#else Debug( LDAP_DEBUG_ANY, "str2entry: invalid value for syntax %s\n", ad->ad_type->sat_syntax->ssyn_oid, 0, 0 ); +#endif entry_free( e ); free( value.bv_val ); free( type ); @@ -173,8 +215,13 @@ str2entry( char *s ) ad_free( ad, 1 ); if( rc != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "str2entry: NULL (attr_merge)\n" )); +#else Debug( LDAP_DEBUG_ANY, "<= str2entry NULL (attr_merge)\n", 0, 0, 0 ); +#endif entry_free( e ); free( value.bv_val ); free( type ); @@ -187,8 +234,13 @@ str2entry( char *s ) /* check to make sure there was a dn: line */ if ( e->e_dn == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "str2entry: entry %ld has no dn.\n", e->e_id )); +#else Debug( LDAP_DEBUG_ANY, "str2entry: entry %ld has no dn\n", e->e_id, 0, 0 ); +#endif entry_free( e ); return( NULL ); } @@ -197,9 +249,13 @@ str2entry( char *s ) e->e_ndn = ch_strdup( e->e_dn ); (void) dn_normalize( e->e_ndn ); +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL2, + "str2entry(%s) -> 0x%lx\n", e->e_dn, (unsigned long)e )); +#else Debug(LDAP_DEBUG_TRACE, "<= str2entry(%s) -> 0x%lx\n", e->e_dn, (unsigned long) e, 0 ); - +#endif return( e ); } @@ -343,9 +399,14 @@ int entry_decode( struct berval *bv, Entry **entry ) ber = ber_init( bv ); if( ber == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "entry_decode: ber_init failed\n" )); +#else Debug( LDAP_DEBUG_ANY, "<= entry_decode: ber_init failed\n", 0, 0, 0 ); +#endif return LDAP_LOCAL_ERROR; } @@ -353,9 +414,14 @@ int entry_decode( struct berval *bv, Entry **entry ) e = (Entry *) ch_malloc( sizeof(Entry) ); if( e == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "entry_decode: entry allocation failed.\n" )); +#else Debug( LDAP_DEBUG_ANY, "<= entry_decode: entry allocation failed\n", 0, 0, 0 ); +#endif return LDAP_LOCAL_ERROR; } @@ -372,10 +438,14 @@ int entry_decode( struct berval *bv, Entry **entry ) return LDAP_PROTOCOL_ERROR; } +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL2, + "entry_decode: \"%s\"\n", e->e_dn )); +#else Debug( LDAP_DEBUG_TRACE, "entry_decode: \"%s\"\n", e->e_dn, 0, 0 ); - +#endif /* get the attrs */ for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; @@ -389,14 +459,24 @@ int entry_decode( struct berval *bv, Entry **entry ) tag = ber_scanf( ber, "{O{V}}", &type, &vals ); if ( tag == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "entry_decode: decoding error (%s)\n", e->e_dn )); +#else Debug( LDAP_DEBUG_ANY, "entry_decode: decoding error\n", 0, 0, 0 ); +#endif entry_free( e ); return LDAP_PROTOCOL_ERROR; } if ( vals == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "entry_decode: no values for type %s\n", type )); +#else Debug( LDAP_DEBUG_ANY, "entry_decode: no values for type %s\n", type, 0, 0 ); +#endif ber_bvfree( type ); entry_free( e ); return LDAP_PROTOCOL_ERROR; @@ -406,15 +486,24 @@ int entry_decode( struct berval *bv, Entry **entry ) rc = slap_bv2ad( type, &ad, &text ); if( rc != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "entry_decode: str2ad(%s): %s\n", type, text )); +#else Debug( LDAP_DEBUG_TRACE, "<= entry_decode: str2ad(%s): %s\n", type, text, 0 ); - +#endif rc = slap_bv2undef_ad( type, &ad, &text ); if( rc != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "entry_decode: str2undef_ad(%s): %s\n", type, text)); +#else Debug( LDAP_DEBUG_ANY, "<= entry_decode: str2undef_ad(%s): %s\n", type, text, 0 ); +#endif ber_bvfree( type ); ber_bvecfree( vals ); entry_free( e ); @@ -426,8 +515,13 @@ int entry_decode( struct berval *bv, Entry **entry ) ad_free( ad, 1 ); if( rc != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "entry_decode: attr_merge failed\n")); +#else Debug( LDAP_DEBUG_ANY, "<= entry_decode: attr_merge failed\n", 0, 0, 0 ); +#endif ber_bvfree( type ); ber_bvecfree( vals ); entry_free( e ); @@ -444,8 +538,13 @@ int entry_decode( struct berval *bv, Entry **entry ) return LDAP_PROTOCOL_ERROR; } +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "entry_decode: %s\n", e->e_dn )); +#else Debug(LDAP_DEBUG_TRACE, "<= entry_decode(%s)\n", e->e_dn, 0, 0 ); +#endif *entry = e; return LDAP_SUCCESS; @@ -459,9 +558,14 @@ int entry_encode( Attribute *a; BerElement *ber; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "entry_encode: id: 0x%08lx \"%s\"\n", + e->e_id, e->e_dn )); +#else Debug( LDAP_DEBUG_TRACE, "=> entry_encode(0x%08lx): %s\n", e->e_id, e->e_dn, 0 ); - +#endif ber = ber_alloc_t( LBER_USE_DER ); if( ber == NULL ) { goto done; @@ -491,8 +595,13 @@ int entry_encode( done: ber_free( ber, 1 ); if( rc ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "entry_encode: id=0x%08lx failed (%d)\n", e->e_id, rc )); +#else Debug( LDAP_DEBUG_ANY, "=> entry_encode(0x%08lx): failed (%d)\n", e->e_id, rc, 0 ); +#endif } return rc; } diff --git a/servers/slapd/extended.c b/servers/slapd/extended.c index 1660aaa914..748bced658 100644 --- a/servers/slapd/extended.c +++ b/servers/slapd/extended.c @@ -93,14 +93,23 @@ do_extended( struct berval *rspdata; LDAPControl **rspctrls; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "do_extended: conn %s\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_TRACE, "do_extended\n", 0, 0, 0 ); - +#endif reqoid = NULL; reqdata = NULL; if( op->o_protocol < LDAP_VERSION3 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_extended: protocol version (%d) too low.\n", op->o_protocol )); +#else Debug( LDAP_DEBUG_ANY, "do_extended: protocol version (%d) too low\n", op->o_protocol, 0 ,0 ); +#endif send_ldap_disconnect( conn, op, LDAP_PROTOCOL_ERROR, "requires LDAPv3" ); rc = -1; @@ -108,7 +117,12 @@ do_extended( } if ( ber_scanf( op->o_ber, "{a" /*}*/, &reqoid ) == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_extended: conn %d ber_scanf failed\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 ); +#endif send_ldap_disconnect( conn, op, LDAP_PROTOCOL_ERROR, "decoding error" ); rc = -1; @@ -116,8 +130,14 @@ do_extended( } if( !(ext = find_extop(supp_ext_list, reqoid)) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_extended: conn %d unsupported operation \"%s\"\n", + conn->c_connid, reqoid )); +#else Debug( LDAP_DEBUG_ANY, "do_extended: unsupported operation \"%s\"\n", reqoid, 0 ,0 ); +#endif send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL, "unsupported extended operation", NULL, NULL ); goto done; @@ -127,7 +147,12 @@ do_extended( if( ber_peek_tag( op->o_ber, &len ) == LDAP_TAG_EXOP_REQ_VALUE ) { if( ber_scanf( op->o_ber, "O", &reqdata ) == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_extended: conn %d ber_scanf failed\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 ); +#endif send_ldap_disconnect( conn, op, LDAP_PROTOCOL_ERROR, "decoding error" ); rc = -1; @@ -136,12 +161,21 @@ do_extended( } if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_extended: conn %d get_ctrls failed\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_ANY, "do_extended: get_ctrls failed\n", 0, 0 ,0 ); +#endif return rc; } +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "do_extended: conn %d oid=%d\n.", conn->c_connid, reqoid )); +#else Debug( LDAP_DEBUG_ARGS, "do_extended: oid=%s\n", reqoid, 0 ,0 ); - +#endif rspoid = NULL; rspdata = NULL; rspctrls = NULL; @@ -243,4 +277,4 @@ find_extop( extop_list_t *list, char *oid ) return(ext); } return(NULL); -} \ No newline at end of file +} diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index a29539d07d..66ea86a81e 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -47,8 +47,12 @@ get_filter( char *ftmp = NULL; struct berval escaped; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, "get_filter: conn %d\n", + conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "begin get_filter\n", 0, 0, 0 ); - +#endif /* * A filter looks like this coming in: * Filter ::= CHOICE { @@ -98,8 +102,12 @@ get_filter( switch ( f->f_choice ) { case LDAP_FILTER_EQUALITY: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL2, + "get_filter: conn %d EQUALITY\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 ); - +#endif err = get_ava( ber, &f->f_ava, SLAP_MR_EQUALITY, text ); if ( err != LDAP_SUCCESS ) { break; @@ -121,13 +129,22 @@ get_filter( break; case LDAP_FILTER_SUBSTRINGS: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_filter: conn %d SUBSTRINGS\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "SUBSTRINGS\n", 0, 0, 0 ); +#endif err = get_substring_filter( conn, ber, f, fstr, text ); break; case LDAP_FILTER_GE: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_filter: conn %d GE\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 ); - +#endif err = get_ava( ber, &f->f_ava, SLAP_MR_ORDERING, text ); if ( err != LDAP_SUCCESS ) { break; @@ -147,8 +164,12 @@ get_filter( break; case LDAP_FILTER_LE: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_filter: conn %d LE\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 ); - +#endif err = get_ava( ber, &f->f_ava, SLAP_MR_ORDERING, text ); if ( err != LDAP_SUCCESS ) { break; @@ -171,8 +192,12 @@ get_filter( case LDAP_FILTER_PRESENT: { struct berval type; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_filter: conn %d PRESENT\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "PRESENT\n", 0, 0, 0 ); - +#endif if ( ber_scanf( ber, "o", &type ) == LBER_ERROR ) { err = SLAPD_DISCONNECT; *text = "error decoding filter"; @@ -197,8 +222,12 @@ get_filter( } break; case LDAP_FILTER_APPROX: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_filter: conn %d APPROX\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 ); - +#endif err = get_ava( ber, &f->f_ava, SLAP_MR_EQUALITY_APPROX, text ); if ( err != LDAP_SUCCESS ) { break; @@ -218,7 +247,12 @@ get_filter( break; case LDAP_FILTER_AND: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_filter: conn %d AND\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "AND\n", 0, 0, 0 ); +#endif err = get_filter_list( conn, ber, &f->f_and, &ftmp, text ); if ( err != LDAP_SUCCESS ) { break; @@ -230,7 +264,12 @@ get_filter( break; case LDAP_FILTER_OR: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_filter: conn %d OR\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "OR\n", 0, 0, 0 ); +#endif err = get_filter_list( conn, ber, &f->f_and, &ftmp, text ); if ( err != LDAP_SUCCESS ) { break; @@ -242,7 +281,12 @@ get_filter( break; case LDAP_FILTER_NOT: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_filter: conn %d NOT\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "NOT\n", 0, 0, 0 ); +#endif (void) ber_skip_tag( ber, &len ); err = get_filter( conn, ber, &f->f_not, &ftmp, text ); if ( err != LDAP_SUCCESS ) { @@ -255,7 +299,12 @@ get_filter( break; case LDAP_FILTER_EXT: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_filter: conn %d EXTENSIBLE\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "EXTENSIBLE\n", 0, 0, 0 ); +#endif err = get_mra( ber, &f->f_mra, text ); if ( err != LDAP_SUCCESS ) { @@ -283,8 +332,14 @@ get_filter( default: (void) ber_skip_tag( ber, &len ); +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + "get_filter: conn %d unknown filter type=%lu\n", + conn->c_connid, f->f_choice )); +#else Debug( LDAP_DEBUG_ANY, "get_filter: unknown filter type=%lu\n", f->f_choice, 0, 0 ); +#endif f->f_choice = SLAPD_FILTER_COMPUTED; f->f_result = SLAPD_COMPARE_UNDEFINED; *fstr = ch_strdup( "(undefined)" ); @@ -313,7 +368,12 @@ get_filter( *filt = f; } +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL2, + "get_filter: conn %d exit\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "end get_filter %d\n", err, 0, 0 ); +#endif return( err ); } @@ -328,8 +388,12 @@ get_filter_list( Connection *conn, BerElement *ber, ber_len_t len; char *last, *ftmp; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "get_filter_list: conn %d start\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "begin get_filter_list\n", 0, 0, 0 ); - +#endif *fstr = NULL; new = f; for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; @@ -351,7 +415,12 @@ get_filter_list( Connection *conn, BerElement *ber, } *new = NULL; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "get_filter_list: conn %d exit\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "end get_filter_list\n", 0, 0, 0 ); +#endif return( LDAP_SUCCESS ); } @@ -374,8 +443,12 @@ get_substring_filter( struct berval *nvalue; *text = "error decoding filter"; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "get_substring_filter: conn %d begin\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 ); - +#endif if ( ber_scanf( ber, "{o" /*}*/, &type ) == LBER_ERROR ) { return SLAPD_DISCONNECT; } @@ -438,10 +511,15 @@ get_substring_filter( default: rc = LDAP_PROTOCOL_ERROR; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + "get_filter_substring: conn %d unknown substring choice=%ld\n", + conn->c_connid, (long)tag )); +#else Debug( LDAP_DEBUG_FILTER, " unknown substring choice=%ld\n", (long) tag, 0, 0 ); - +#endif ber_bvfree( value ); goto return_error; } @@ -459,7 +537,13 @@ get_substring_filter( switch ( tag ) { case LDAP_SUBSTRING_INITIAL: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_substring_filter: conn %d INITIAL\n", + conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); +#endif if ( f->f_sub_initial != NULL ) { ber_bvfree( value ); goto return_error; @@ -477,7 +561,13 @@ get_substring_filter( break; case LDAP_SUBSTRING_ANY: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_substring_filter: conn %d ANY\n", + conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); +#endif if( ber_bvecadd( &f->f_sub_any, value ) < 0 ) { ber_bvfree( value ); goto return_error; @@ -494,7 +584,13 @@ get_substring_filter( break; case LDAP_SUBSTRING_FINAL: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "get_substring_filter: conn %d FINAL\n", + conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); +#endif if ( f->f_sub_final != NULL ) { ber_bvfree( value ); goto return_error; @@ -512,16 +608,27 @@ get_substring_filter( break; default: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_INFO, + "get_substring_filter: conn %d unknown substring type %ld\n", + conn->c_connid, (long)tag )); +#else Debug( LDAP_DEBUG_FILTER, " unknown substring type=%ld\n", (long) tag, 0, 0 ); +#endif ber_bvfree( value ); return_error: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_INFO, + "get_substring_filter: conn %d error %ld\n", + conn->c_connid, (long)rc )); +#else Debug( LDAP_DEBUG_FILTER, " error=%ld\n", (long) rc, 0, 0 ); - +#endif if( fstr ) { free( *fstr ); *fstr = NULL; @@ -544,7 +651,12 @@ return_error: strcat( *fstr, /*(*/ ")" ); } +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "get_substring_filter: conn %d exit\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_FILTER, "end get_substring_filter\n", 0, 0, 0 ); +#endif return( LDAP_SUCCESS ); } @@ -593,8 +705,13 @@ filter_free( Filter *f ) break; default: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ERR, + "filter_free: unknown filter type %lu\n", f->f_choice )); +#else Debug( LDAP_DEBUG_ANY, "filter_free: unknown filter type=%lu\n", f->f_choice, 0, 0 ); +#endif break; } diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index 551f21c3d7..7190c7bf4a 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -55,26 +55,55 @@ test_filter( { int rc; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "test_filter: begin\n" )); +#else Debug( LDAP_DEBUG_FILTER, "=> test_filter\n", 0, 0, 0 ); +#endif + switch ( f->f_choice ) { case SLAPD_FILTER_COMPUTED: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "test_filter: COMPUTED %s (%d)\n", + f->f_result == LDAP_COMPARE_FALSE ? "false" : + f->f_result == LDAP_COMPARE_TRUE ? "true" : + f->f_result == SLAPD_COMPARE_UNDEFINED ? "undefined" : + "error", + f->f_result )); +#else Debug( LDAP_DEBUG_FILTER, " COMPUTED %s (%d)\n", f->f_result == LDAP_COMPARE_FALSE ? "false" : f->f_result == LDAP_COMPARE_TRUE ? "true" : f->f_result == SLAPD_COMPARE_UNDEFINED ? "undefined" : "error", f->f_result, 0 ); +#endif + rc = f->f_result; break; case LDAP_FILTER_EQUALITY: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "test_filter: EQUALITY\n" )); +#else Debug( LDAP_DEBUG_FILTER, " EQUALITY\n", 0, 0, 0 ); +#endif + rc = test_ava_filter( be, conn, op, e, f->f_ava, LDAP_FILTER_EQUALITY ); break; case LDAP_FILTER_SUBSTRINGS: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "test_filter SUBSTRINGS\n" )); +#else Debug( LDAP_DEBUG_FILTER, " SUBSTRINGS\n", 0, 0, 0 ); +#endif + rc = test_substrings_filter( be, conn, op, e, f ); break; @@ -89,28 +118,57 @@ test_filter( break; case LDAP_FILTER_PRESENT: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "test_filter: PRESENT\n" )); +#else Debug( LDAP_DEBUG_FILTER, " PRESENT\n", 0, 0, 0 ); +#endif + rc = test_presence_filter( be, conn, op, e, f->f_desc ); break; case LDAP_FILTER_APPROX: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "test_filter: APPROX\n" )); +#else Debug( LDAP_DEBUG_FILTER, " APPROX\n", 0, 0, 0 ); +#endif rc = test_ava_filter( be, conn, op, e, f->f_ava, LDAP_FILTER_APPROX ); break; case LDAP_FILTER_AND: - Debug( LDAP_DEBUG_FILTER, " AND\n", 0, 0, 0 ); +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "test_filter: AND\n" )); +#else + Debug( LDAP_DEBUG_FILTER, " AND\n", 0, 0, 0 ); +#endif + rc = test_filter_and( be, conn, op, e, f->f_and ); break; case LDAP_FILTER_OR: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "test_filter: OR\n" )); +#else Debug( LDAP_DEBUG_FILTER, " OR\n", 0, 0, 0 ); +#endif + rc = test_filter_or( be, conn, op, e, f->f_or ); break; case LDAP_FILTER_NOT: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "test_filter: NOT\n" )); +#else Debug( LDAP_DEBUG_FILTER, " NOT\n", 0, 0, 0 ); +#endif + rc = test_filter( be, conn, op, e, f->f_not ); switch( rc ) { @@ -125,18 +183,37 @@ test_filter( #ifdef SLAPD_EXT_FILTERS case LDAP_FILTER_EXT: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "test_filter: EXT\n" )); +#else Debug( LDAP_DEBUG_FILTER, " EXT\n", 0, 0, 0 ); +#endif + rc = test_mra_filter( be, conn, op, e, f->f_mra ); break; #endif default: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_INFO, + "test_filter: unknown filter type %lu\n", + f->f_choice )); +#else Debug( LDAP_DEBUG_ANY, " unknown filter type %lu\n", f->f_choice, 0, 0 ); +#endif + rc = LDAP_PROTOCOL_ERROR; } +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "test_filter: return=%d\n", rc )); +#else Debug( LDAP_DEBUG_FILTER, "<= test_filter %d\n", rc, 0, 0 ); +#endif + return( rc ); } @@ -262,7 +339,13 @@ test_filter_and( Filter *f; int rtn = LDAP_COMPARE_TRUE; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "test_filter_and: begin\n" )); +#else Debug( LDAP_DEBUG_FILTER, "=> test_filter_and\n", 0, 0, 0 ); +#endif + for ( f = flist; f != NULL; f = f->f_next ) { int rc = test_filter( be, conn, op, e, f ); @@ -276,7 +359,13 @@ test_filter_and( } } +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "test_filter_and: rc=%d\n", rtn )); +#else Debug( LDAP_DEBUG_FILTER, "<= test_filter_and %d\n", rtn, 0, 0 ); +#endif + return rtn; } @@ -292,7 +381,13 @@ test_filter_or( Filter *f; int rtn = LDAP_COMPARE_FALSE; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "test_filter_or: begin\n" )); +#else Debug( LDAP_DEBUG_FILTER, "=> test_filter_or\n", 0, 0, 0 ); +#endif + for ( f = flist; f != NULL; f = f->f_next ) { int rc = test_filter( be, conn, op, e, f ); @@ -306,7 +401,13 @@ test_filter_or( } } +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "test_filter_or: result=%d\n", rtn )); +#else Debug( LDAP_DEBUG_FILTER, "<= test_filter_or %d\n", rtn, 0, 0 ); +#endif + return rtn; } @@ -322,7 +423,13 @@ test_substrings_filter( { Attribute *a; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "test_substrings_filter: begin\n" )); +#else Debug( LDAP_DEBUG_FILTER, "begin test_substrings_filter\n", 0, 0, 0 ); +#endif + if ( be != NULL && ! access_allowed( be, conn, op, e, f->f_sub_desc, NULL, ACL_SEARCH ) ) @@ -360,6 +467,12 @@ test_substrings_filter( } } +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "test_substrings_filter: return FALSE\n" )); +#else Debug( LDAP_DEBUG_FILTER, "end test_substrings_filter 1\n", 0, 0, 0 ); +#endif + return LDAP_COMPARE_FALSE; } diff --git a/servers/slapd/init.c b/servers/slapd/init.c index fe57be4c20..0b0fea9181 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -74,9 +74,16 @@ slap_init( int mode, const char *name ) assert( mode ); if( slapMode != SLAP_UNDEFINED_MODE ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, + "init: %s init called twice (old=%d, new=%d)\n", + name, slapMode, mode )); +#else Debug( LDAP_DEBUG_ANY, "%s init: init called twice (old=%d, new=%d)\n", name, slapMode, mode ); +#endif + return 1; } @@ -85,10 +92,17 @@ slap_init( int mode, const char *name ) switch ( slapMode & SLAP_MODE ) { case SLAP_SERVER_MODE: case SLAP_TOOL_MODE: +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "init: %s initiation, initiated %s.\n", + name, (mode & SLAP_MODE) == SLAP_TOOL_MODE ? "tool" : "server" )); +#else Debug( LDAP_DEBUG_TRACE, "%s init: initiated %s.\n", name, (mode & SLAP_MODE) == SLAP_TOOL_MODE ? "tool" : "server", 0 ); +#endif + slap_name = name; @@ -115,8 +129,14 @@ slap_init( int mode, const char *name ) break; default: +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "init: %s init, undefined mode (%d).\n", name, mode )); +#else Debug( LDAP_DEBUG_ANY, "%s init: undefined mode (%d).\n", name, mode, 0 ); +#endif + rc = 1; break; } @@ -128,9 +148,15 @@ int slap_startup( Backend *be ) { int rc; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, + "slap_startup: %s started\n", slap_name )); +#else Debug( LDAP_DEBUG_TRACE, "%s startup: initiated.\n", slap_name, 0, 0 ); +#endif + rc = backend_startup( be ); @@ -141,9 +167,15 @@ int slap_shutdown( Backend *be ) { int rc; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, + "slap_shutdown: %s shutdown initiated.\n", slap_name)); +#else Debug( LDAP_DEBUG_TRACE, "%s shutdown: initiated\n", slap_name, 0, 0 ); +#endif + slap_sasl_destroy(); @@ -157,9 +189,16 @@ int slap_destroy(void) { int rc; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "slap_destroy: %s freeing system resources.\n", + slap_name )); +#else Debug( LDAP_DEBUG_TRACE, "%s shutdown: freeing system resources.\n", slap_name, 0, 0 ); +#endif + rc = backend_destroy(); diff --git a/servers/slapd/lock.c b/servers/slapd/lock.c index 14f0315dca..2b006232ea 100644 --- a/servers/slapd/lock.c +++ b/servers/slapd/lock.c @@ -30,7 +30,13 @@ lock_fopen( const char *fname, const char *type, FILE **lfp ) strcpy( buf, fname ); strcat( buf, ".lock" ); if ( (*lfp = fopen( buf, "w" )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "lock_fopen: could not open lock file \"%s\".\n", buf )); +#else Debug( LDAP_DEBUG_ANY, "could not open \"%s\"\n", buf, 0, 0 ); +#endif + return( NULL ); } @@ -39,7 +45,13 @@ lock_fopen( const char *fname, const char *type, FILE **lfp ) /* open the log file */ if ( (fp = fopen( fname, type )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "lock_fopen: could not open log file \"%s\".\n", buf )); +#else Debug( LDAP_DEBUG_ANY, "could not open \"%s\"\n", fname, 0, 0 ); +#endif + ldap_unlockf( fileno(*lfp) ); fclose( *lfp ); *lfp = NULL; diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 81f545eda9..3933792bf8 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -175,7 +175,12 @@ int main( int argc, char **argv ) if ( i != NULL ) { slap_debug = *i; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "main: new debug level from registry is: %d\n", slap_debug )); +#else Debug( LDAP_DEBUG_ANY, "new debug level from registry is: %d\n", slap_debug, 0, 0 ); +#endif } newUrls = (char *) getRegParam(regService, "Urls"); @@ -185,15 +190,27 @@ int main( int argc, char **argv ) ch_free(urls); urls = ch_strdup(newUrls); +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "main: new urls from registry: %s\n", urls )); +#else Debug(LDAP_DEBUG_ANY, "new urls from registry: %s\n", urls, 0, 0); +#endif + } newConfigFile = (char*)getRegParam( regService, "ConfigFile" ); if ( newConfigFile != NULL ) { configfile = newConfigFile; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "main: new config file from registry is: %s\n", configfile )); +#else Debug ( LDAP_DEBUG_ANY, "new config file from registry is: %s\n", configfile, 0, 0 ); +#endif + } } #endif @@ -283,7 +300,13 @@ int main( int argc, char **argv ) ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &slap_debug); ldif_debug = slap_debug; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "%s", Versionstr )); +#else Debug( LDAP_DEBUG_TRACE, "%s", Versionstr, 0, 0 ); +#endif + if( serverName == NULL ) { if ( (serverName = strrchr( argv[0], *LDAP_DIRSEP )) == NULL ) { @@ -343,9 +366,15 @@ int main( int argc, char **argv ) } if ( schema_init( ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, + "main: schema initialization error\n" )); +#else Debug( LDAP_DEBUG_ANY, "schema initialization error\n", 0, 0, 0 ); +#endif + goto destroy; } @@ -356,9 +385,15 @@ int main( int argc, char **argv ) } if ( schema_prep( ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, + "main: schema prep error\n")); +#else Debug( LDAP_DEBUG_ANY, "schema prep error\n", 0, 0, 0 ); +#endif + goto destroy; } @@ -408,7 +443,13 @@ int main( int argc, char **argv ) { FILE *fp; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "main: slapd starting.\n" )); +#else Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 ); +#endif + if (( slapd_pid_file != NULL ) && (( fp = fopen( slapd_pid_file, "w" )) != NULL )) @@ -461,7 +502,13 @@ stop: LogSlapdStoppedEvent( serverName ); #endif +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, + "main: slapd stopped.\n" )); +#else Debug( LDAP_DEBUG_ANY, "slapd stopped.\n", 0, 0, 0 ); +#endif + #ifdef HAVE_NT_SERVICE_MANAGER ReportSlapdShutdownComplete(); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 99e31fe033..fe11260bfd 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -47,7 +47,13 @@ do_modify( const char *text; int manageDSAit; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "do_modify: enter\n" )); +#else Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 ); +#endif + /* * Parse the modify request. It looks like this: @@ -69,13 +75,25 @@ do_modify( */ if ( ber_scanf( op->o_ber, "{a" /*}*/, &dn ) == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modify: ber_scanf failed\n" )); +#else Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 ); +#endif + send_ldap_disconnect( conn, op, LDAP_PROTOCOL_ERROR, "decoding error" ); return SLAPD_DISCONNECT; } +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + "do_modify: dn (%s)\n", dn )); +#else Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn, 0, 0 ); +#endif + /* collect modifications & save for later */ @@ -100,9 +118,16 @@ do_modify( switch( mop ) { case LDAP_MOD_ADD: if ( (*modtail)->ml_bvalues == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modify: modify/add operation (%ld) requires values\n", + (long)mop )); +#else Debug( LDAP_DEBUG_ANY, "do_modify: modify/add operation (%ld) requires values\n", (long) mop, 0, 0 ); +#endif + send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "modify/add operation requires values", NULL, NULL ); @@ -117,9 +142,16 @@ do_modify( break; default: { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modify: invalid modify operation (%ld)\n", + (long)mop )); +#else Debug( LDAP_DEBUG_ANY, "do_modify: invalid modify operation (%ld)\n", (long) mop, 0, 0 ); +#endif + send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "unrecognized modify operation", NULL, NULL ); rc = LDAP_PROTOCOL_ERROR; @@ -133,33 +165,65 @@ do_modify( *modtail = NULL; if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modify: get_ctrls failed\n" )); +#else Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 ); +#endif + goto cleanup; } ndn = ch_strdup( dn ); if( dn_normalize( ndn ) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modify: invalid dn (%s)\n", dn )); +#else Debug( LDAP_DEBUG_ANY, "do_modify: invalid dn (%s)\n", dn, 0, 0 ); +#endif + send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, "invalid DN", NULL, NULL ); goto cleanup; } if( ndn == '\0' ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modify: attempt to modify root DSE.\n" )); +#else Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 ); +#endif + send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL, "modify upon the root DSE not supported", NULL, NULL ); goto cleanup; } #ifdef LDAP_DEBUG +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "do_modify: modifications:\n" )); +#else Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 ); +#endif + for ( tmp = modlist; tmp != NULL; tmp = tmp->ml_next ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "\t%s: %s\n", tmp->ml_op == LDAP_MOD_ADD ? + "add" : (tmp->ml_op == LDAP_MOD_DELETE ? + "delete" : "replace"), tmp->ml_type )); +#else Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n", tmp->ml_op == LDAP_MOD_ADD ? "add" : (tmp->ml_op == LDAP_MOD_DELETE ? "delete" : "replace"), tmp->ml_type, 0 ); +#endif + } #endif @@ -342,9 +406,16 @@ int slap_modlist2mods( ad->ad_type->sat_syntax->ssyn_validate; if( !validate ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "modlist2mods: no validator for syntax %S\n", + ad->ad_type->sat_syntax->ssyn_oid )); +#else Debug( LDAP_DEBUG_TRACE, "modlist2mods: no validator for syntax %s\n", ad->ad_type->sat_syntax->ssyn_oid, 0, 0 ); +#endif + slap_mods_free( mod ); *text = "no validator for syntax"; return LDAP_INVALID_SYNTAX; diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 7bcf98ecf6..055da42715 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -56,7 +56,13 @@ do_modrdn( const char *text; int manageDSAit; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "do_modrdn: begin\n" )); +#else Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 ); +#endif + /* * Parse the modrdn request. It looks like this: @@ -71,7 +77,13 @@ do_modrdn( if ( ber_scanf( op->o_ber, "{aab", &dn, &newrdn, &deloldrdn ) == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modrdn: ber_scanf failed\n" )); +#else Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 ); +#endif + send_ldap_disconnect( conn, op, LDAP_PROTOCOL_ERROR, "decoding error" ); return SLAPD_DISCONNECT; @@ -84,9 +96,15 @@ do_modrdn( /* Conection record indicates v2 but field * newSuperior is present: report error. */ +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modrdn: (v2) invalid field newSuperior.\n" )); +#else Debug( LDAP_DEBUG_ANY, "modrdn(v2): invalid field newSuperior!\n", 0, 0, 0 ); +#endif + send_ldap_disconnect( conn, op, LDAP_PROTOCOL_ERROR, "newSuperior requires LDAPv3" ); rc = SLAPD_DISCONNECT; @@ -96,8 +114,14 @@ do_modrdn( if ( ber_scanf( op->o_ber, "a", &newSuperior ) == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modrdn: ber_scanf(\"a\") failed\n" )); +#else Debug( LDAP_DEBUG_ANY, "ber_scanf(\"a\") failed\n", 0, 0, 0 ); +#endif + send_ldap_disconnect( conn, op, LDAP_PROTOCOL_ERROR, "decoding error" ); rc = SLAPD_DISCONNECT; @@ -107,8 +131,14 @@ do_modrdn( nnewSuperior = ch_strdup( newSuperior ); if( dn_normalize( nnewSuperior ) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modrdn: invalid new superior (%s)\n", newSuperior )); +#else Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid new superior (%s)\n", newSuperior, 0, 0 ); +#endif + send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, "invalid new superior DN", NULL, NULL ); goto cleanup; @@ -116,13 +146,26 @@ do_modrdn( } +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + "do_modrdn: dn (%s) newrdn (%s) newsuperior(%s)\n", + dn, newrdn, newSuperior != NULL ? newSuperior : "" )); +#else Debug( LDAP_DEBUG_ARGS, "do_modrdn: dn (%s) newrdn (%s) newsuperior (%s)\n", dn, newrdn, newSuperior != NULL ? newSuperior : "" ); +#endif + if ( ber_scanf( op->o_ber, /*{*/ "}") == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modrdn: ber_scanf failed\n" )); +#else Debug( LDAP_DEBUG_ANY, "do_modrdn: ber_scanf failed\n", 0, 0, 0 ); +#endif + send_ldap_disconnect( conn, op, LDAP_PROTOCOL_ERROR, "decoding error" ); rc = SLAPD_DISCONNECT; @@ -130,7 +173,13 @@ do_modrdn( } if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modrdn: get_ctrls failed\n" )); +#else Debug( LDAP_DEBUG_ANY, "do_modrdn: get_ctrls failed\n", 0, 0, 0 ); +#endif + /* get_ctrls has sent results. Now clean up. */ goto cleanup; } @@ -138,21 +187,39 @@ do_modrdn( ndn = ch_strdup( dn ); if( dn_normalize( ndn ) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modrdn: invalid dn (%s)\n", dn )); +#else Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid dn (%s)\n", dn, 0, 0 ); +#endif + send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, "invalid DN", NULL, NULL ); goto cleanup; } if( !rdn_validate( newrdn ) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modrdn: invalid rdn (%s).\n", newrdn )); +#else Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid rdn (%s)\n", newrdn, 0, 0 ); +#endif + send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, "invalid RDN", NULL, NULL ); goto cleanup; } if( ndn == '\0' ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "do_modrdn: attempt to modify root DSE.\n" )); +#else Debug( LDAP_DEBUG_ANY, "do_modrdn: root dse!\n", 0, 0, 0 ); +#endif + send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL, "cannot rename the root DSE", NULL, NULL ); goto cleanup; diff --git a/servers/slapd/module.c b/servers/slapd/module.c index 4559be0e0c..6fa4ad38ab 100644 --- a/servers/slapd/module.c +++ b/servers/slapd/module.c @@ -40,7 +40,13 @@ int module_init (void) { if (lt_dlinit()) { const char *error = lt_dlerror(); +#ifdef NEW_LOGGING + LDAP_LOG(( "module", LDAP_LEVEL_CRIT, + "module_init: lt_ldinit failed: %s\n", error )); +#else Debug(LDAP_DEBUG_ANY, "lt_dlinit failed: %s\n", error, 0, 0); +#endif + return -1; } return 0; @@ -55,7 +61,13 @@ int module_kill (void) if (lt_dlexit()) { const char *error = lt_dlerror(); +#ifdef NEW_LOGGING + LDAP_LOG(( "module", LDAP_LEVEL_CRIT, + "module_kill: lt_dlexit failed: %s\n", error )); +#else Debug(LDAP_DEBUG_ANY, "lt_dlexit failed: %s\n", error, 0, 0); +#endif + return -1; } return 0; @@ -70,8 +82,14 @@ int module_load(const char* file_name, int argc, char *argv[]) module = (module_loaded_t *)ch_calloc(1, sizeof(module_loaded_t)); if (module == NULL) { +#ifdef NEW_LOGGING + LDAP_LOG(( "module", LDAP_LEVEL_CRIT, + "module_load: (%s) out of memory.\n", file_name )); +#else Debug(LDAP_DEBUG_ANY, "module_load failed: (%s) out of memory\n", file_name, 0, 0); +#endif + return -1; } @@ -82,17 +100,37 @@ int module_load(const char* file_name, int argc, char *argv[]) */ if ((module->lib = lt_dlopen(file_name)) == NULL) { error = lt_dlerror(); +#ifdef NEW_LOGGING + LDAP_LOG(( "module", LDAP_LEVEL_CRIT, + "module_load: lt_dlopen failed: (%s) %s.\n", + file_name, error )); +#else Debug(LDAP_DEBUG_ANY, "lt_dlopen failed: (%s) %s\n", file_name, error, 0); +#endif + ch_free(module); return -1; } +#ifdef NEW_LOGGING + LDAP_LOG(( "module", LDAP_LEVEL_INFO, + "module_load: loaded module %s\n", file_name )); +#else Debug(LDAP_DEBUG_CONFIG, "loaded module %s\n", file_name, 0, 0); +#endif + if ((initialize = lt_dlsym(module->lib, "init_module")) == NULL) { +#ifdef NEW_LOGGING + LDAP_LOG(( "module", LDAP_LEVEL_ERR, + "module_load: module %s : no init_module() function found\n", + file_name )); +#else Debug(LDAP_DEBUG_CONFIG, "module %s: no init_module() function found\n", file_name, 0, 0); +#endif + lt_dlclose(module->lib); ch_free(module); return -1; @@ -115,8 +153,14 @@ int module_load(const char* file_name, int argc, char *argv[]) */ rc = initialize(argc, argv); if (rc == -1) { +#ifdef NEW_LOGGING + LDAP_LOG(( "module", LDAP_LEVEL_ERR, + "module_load: module %s init_module() failed\n", file_name)); +#else Debug(LDAP_DEBUG_CONFIG, "module %s: init_module() failed\n", file_name, 0, 0); +#endif + lt_dlclose(module->lib); ch_free(module); return rc; @@ -125,16 +169,29 @@ int module_load(const char* file_name, int argc, char *argv[]) if (rc >= (sizeof(module_regtable) / sizeof(struct module_regtable_t)) || module_regtable[rc].proc == NULL) { +#ifdef NEW_LOGGING + LDAP_LOG(( "module", LDAP_LEVEL_ERR, + "module_load: module %s: unknown registration type (%d).\n", file_name)); +#else Debug(LDAP_DEBUG_CONFIG, "module %s: unknown registration type (%d)\n", file_name, rc, 0); +#endif + module_unload(module); return -1; } rc = (module_regtable[rc].proc)(module, file_name); if (rc != 0) { +#ifdef NEW_LOGGING + LDAP_LOG(( "module", LDAP_LEVEL_ERR, + "module_load: module %s:%s could not be registered.\n", + file_name, module_regtable[rc].type )); +#else Debug(LDAP_DEBUG_CONFIG, "module %s: %s module could not be registered\n", file_name, module_regtable[rc].type, 0); +#endif + module_unload(module); return rc; } @@ -142,8 +199,15 @@ int module_load(const char* file_name, int argc, char *argv[]) module->next = module_list; module_list = module; +#ifdef NEW_LOGGING + LDAP_LOG(( "module", LDAP_LEVEL_INFO, + "module_load: module %s:%s registered\n", file_name, + module_regtable[rc].type )); +#else Debug(LDAP_DEBUG_CONFIG, "module %s: %s module registered\n", file_name, module_regtable[rc].type, 0); +#endif + return 0; } diff --git a/servers/slapd/mr.c b/servers/slapd/mr.c index 705c2b7aa6..4149de0d65 100644 --- a/servers/slapd/mr.c +++ b/servers/slapd/mr.c @@ -168,8 +168,14 @@ register_matching_rule( const char *err; if( usage == SLAP_MR_NONE ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "register_matching_rule: %s not usable\n", desc )); +#else Debug( LDAP_DEBUG_ANY, "register_matching_rule: not usable %s\n", desc, 0, 0 ); +#endif + return -1; } @@ -180,9 +186,16 @@ register_matching_rule( /* ignore for now */ if( amr == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "register_matching_rule: could not locate associated matching rule %s for %s\n", + associated, desc )); +#else Debug( LDAP_DEBUG_ANY, "register_matching_rule: could not locate " "associated matching rule %s for %s\n", associated, desc, 0 ); +#endif + return -1; } #endif @@ -191,8 +204,15 @@ register_matching_rule( mr = ldap_str2matchingrule( desc, &code, &err, LDAP_SCHEMA_ALLOW_ALL); if ( !mr ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "register_matching_rule: %s before %s in %s.\n", + ldap_scherr2str(code), err, desc )); +#else Debug( LDAP_DEBUG_ANY, "Error in register_matching_rule: %s before %s in %s\n", ldap_scherr2str(code), err, desc ); +#endif + return( -1 ); } @@ -203,8 +223,15 @@ register_matching_rule( ldap_memfree( mr ); if ( code ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "register_matching_rule: %s for %s in %s.\n", + scherr2str(code), err, desc )); +#else Debug( LDAP_DEBUG_ANY, "Error in register_matching_rule: %s for %s in %s\n", scherr2str(code), err, desc ); +#endif + return( -1 ); } diff --git a/servers/slapd/mra.c b/servers/slapd/mra.c index dc630f8c23..7373978c39 100644 --- a/servers/slapd/mra.c +++ b/servers/slapd/mra.c @@ -51,7 +51,13 @@ get_mra( rc = ber_scanf( ber, "{t", &tag ); if( rc == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "get_mra: ber_scanf (\"{t\") failure\n" )); +#else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 ); +#endif + *text = "Error parsing matching rule assertion"; mra_free( ma, 1 ); return SLAPD_DISCONNECT; @@ -60,7 +66,13 @@ get_mra( if ( tag == LDAP_FILTER_EXT_OID ) { rc = ber_scanf( ber, "a", &ma->ma_rule_text ); if ( rc == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "get_mra: ber_scanf(\"a\") failure.\n" )); +#else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf for mr\n", 0, 0, 0 ); +#endif + *text = "Error parsing matching rule in matching rule assertion"; mra_free( ma, 1 ); return SLAPD_DISCONNECT; @@ -70,7 +82,13 @@ get_mra( rc = ber_scanf( ber, "t", &tag ); if( rc == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "get_mra: ber_scanf (\"t\") failure\n" )); +#else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 ); +#endif + *text = "Error parsing matching rule assertion"; mra_free( ma, 1 ); return SLAPD_DISCONNECT; @@ -80,7 +98,13 @@ get_mra( if ( tag == LDAP_FILTER_EXT_TYPE ) { rc = ber_scanf( ber, "o", &type ); if ( rc == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "get_mra: ber_scanf (\"o\") failure.\n" )); +#else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf for ad\n", 0, 0, 0 ); +#endif + *text = "Error parsing attribute description in matching rule assertion"; return SLAPD_DISCONNECT; } @@ -97,7 +121,13 @@ get_mra( rc = ber_scanf( ber, "t", &tag ); if( rc == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "get_mra: ber_scanf (\"t\") failure.\n" )); +#else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 ); +#endif + *text = "Error parsing matching rule assertion"; mra_free( ma, 1 ); return SLAPD_DISCONNECT; @@ -105,7 +135,13 @@ get_mra( } if ( tag != LDAP_FILTER_EXT_VALUE ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "get_mra: ber_scanf missing value\n" )); +#else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf missing value\n", 0, 0, 0 ); +#endif + *text = "Missing value in matching rule assertion"; mra_free( ma, 1 ); return SLAPD_DISCONNECT; @@ -114,7 +150,13 @@ get_mra( rc = ber_scanf( ber, "o", &value ); if( rc == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "get_mra: ber_scanf (\"o\") failure.\n" )); +#else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 ); +#endif + *text = "Error decoding value in matching rule assertion"; mra_free( ma, 1 ); return SLAPD_DISCONNECT; @@ -144,7 +186,13 @@ get_mra( } if( rc == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "get_mra: ber_scanf failure\n")); +#else Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 ); +#endif + *text = "Error decoding dnattrs matching rule assertion"; mra_free( ma, 1 ); return SLAPD_DISCONNECT; diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index 8ffd3d43c0..5b4ac1f43e 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -66,10 +66,17 @@ int is_entry_objectclass( if( attr == NULL ) { /* no objectClass attribute */ +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "is_entry_objectclass: dn(%s), oid (%s), no objectlcass attribute.\n", + e->e_dn == NULL ? "" : e->e_dn, oc->soc_oclass.oc_oid )); +#else Debug( LDAP_DEBUG_ANY, "is_entry_objectclass(\"%s\", \"%s\") " "no objectClass attribute\n", e->e_dn == NULL ? "" : e->e_dn, oc->soc_oclass.oc_oid, 0 ); +#endif + return 0; } diff --git a/servers/slapd/operation.c b/servers/slapd/operation.c index ce2eef1179..43853d0522 100644 --- a/servers/slapd/operation.c +++ b/servers/slapd/operation.c @@ -96,8 +96,15 @@ slap_op_remove( Operation **olist, Operation *op ) ; /* NULL */ if ( *tmp == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "slap_op_remove: can't find op %ld.\n", + (long)op->o_msgid )); +#else Debug( LDAP_DEBUG_ANY, "op_delete: can't find op %ld\n", (long) op->o_msgid, 0, 0 ); +#endif + return -1; } diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index 63110da271..a9c6772fe3 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -82,8 +82,14 @@ int slap_passwd_parse( struct berval *reqdata, ber = ber_init( reqdata ); if( ber == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "slap_passwd_parse: ber_init failed\n" )); +#else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: ber_init failed\n", 0, 0, 0 ); +#endif + *text = "password decoding error"; return LDAP_PROTOCOL_ERROR; } @@ -96,8 +102,14 @@ int slap_passwd_parse( struct berval *reqdata, if( tag == LDAP_TAG_EXOP_X_MODIFY_PASSWD_ID ) { if( id == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "slap_passwd_parse: ID not allowed.\n")); +#else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: ID not allowed.\n", 0, 0, 0 ); +#endif + *text = "user must change own password"; rc = LDAP_UNWILLING_TO_PERFORM; goto done; @@ -106,8 +118,14 @@ int slap_passwd_parse( struct berval *reqdata, tag = ber_scanf( ber, "O", id ); if( tag == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "slap_passwd_parse: ID parse failed.\n")); +#else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: ID parse failed.\n", 0, 0, 0 ); +#endif + goto decoding_error; } @@ -116,8 +134,14 @@ int slap_passwd_parse( struct berval *reqdata, if( tag == LDAP_TAG_EXOP_X_MODIFY_PASSWD_OLD ) { if( oldpass == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "slap_passwd_parse: OLD not allowed.\n" )); +#else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: OLD not allowed.\n", 0, 0, 0 ); +#endif + *text = "use bind to verify old password"; rc = LDAP_UNWILLING_TO_PERFORM; goto done; @@ -126,8 +150,14 @@ int slap_passwd_parse( struct berval *reqdata, tag = ber_scanf( ber, "O", oldpass ); if( tag == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "slap_passwd_parse: ID parse failed.\n" )); +#else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: ID parse failed.\n", 0, 0, 0 ); +#endif + goto decoding_error; } @@ -136,8 +166,14 @@ int slap_passwd_parse( struct berval *reqdata, if( tag == LDAP_TAG_EXOP_X_MODIFY_PASSWD_NEW ) { if( newpass == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "slap_passwd_parse: NEW not allowed.\n" )); +#else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: NEW not allowed.\n", 0, 0, 0 ); +#endif + *text = "user specified passwords disallowed"; rc = LDAP_UNWILLING_TO_PERFORM; goto done; @@ -146,8 +182,14 @@ int slap_passwd_parse( struct berval *reqdata, tag = ber_scanf( ber, "O", newpass ); if( tag == LBER_ERROR ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "slap_passwd_parse: OLD parse failed.\n")); +#else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: OLD parse failed.\n", 0, 0, 0 ); +#endif + goto decoding_error; } @@ -156,9 +198,15 @@ int slap_passwd_parse( struct berval *reqdata, if( len != 0 ) { decoding_error: +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "slap_passwd_parse: decoding error, len=%ld\n", (long)len )); +#else Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: decoding error, len=%ld\n", (long) len, 0, 0 ); +#endif + *text = "data decoding error"; rc = LDAP_PROTOCOL_ERROR; @@ -195,8 +243,14 @@ struct berval * slap_passwd_return( assert( cred != NULL ); +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "slap_passwd_return: %ld\n",(long)cred->bv_len )); +#else Debug( LDAP_DEBUG_TRACE, "slap_passwd_return: %ld\n", (long) cred->bv_len, 0, 0 ); +#endif + if( ber == NULL ) return NULL; @@ -250,7 +304,13 @@ slap_passwd_check( struct berval * slap_passwd_generate( void ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "slap_passwd_generate: begin\n" )); +#else Debug( LDAP_DEBUG_TRACE, "slap_passwd_generate\n", 0, 0, 0 ); +#endif + /* * generate passwords of only 8 characters as some getpass(3) diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 7eb853b32e..3ee2d569db 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -214,8 +214,15 @@ static long send_ldap_ber( * it's a hard error and return. */ +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_ldap_ber: conn %d ber_flush failed err=%d (%s)\n", + conn ? conn->c_connid : 0, err, sock_errstr(err) )); +#else Debug( LDAP_DEBUG_CONNS, "ber_flush failed errno=%d reason=\"%s\"\n", err, sock_errstr(err), 0 ); +#endif + if ( err != EWOULDBLOCK && err != EAGAIN ) { connection_closing( conn ); @@ -265,18 +272,40 @@ send_ldap_response( ber = ber_alloc_t( LBER_USE_DER ); +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "send_ldap_response: conn %d msgid=%ld tag=%ld err=%ld\n", + conn ? conn->c_connid : 0, (long)msgid, (long)tag, (long)err )); +#else Debug( LDAP_DEBUG_TRACE, "send_ldap_response: msgid=%ld tag=%ld err=%ld\n", (long) msgid, (long) tag, (long) err ); +#endif + if( ref ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + "send_ldap_response: conn %d ref=\"%s\"\n", + conn ? conn->c_connid : 0, + ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL" )); +#else Debug( LDAP_DEBUG_ARGS, "send_ldap_response: ref=\"%s\"\n", ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL", NULL, NULL ); +#endif + } if ( ber == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_ldap_response: conn %d ber_alloc failed\n", + conn ? conn->c_connid : 0 )); +#else Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 ); +#endif + return; } @@ -315,7 +344,14 @@ send_ldap_response( } if ( rc == -1 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_ldap_response: conn %d ber_printf failed\n", + conn ? conn->c_connid : 0 )); +#else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); return; } @@ -325,9 +361,16 @@ send_ldap_response( ber_free( ber, 1 ); if ( bytes < 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_ldap_response: conn %d ber write failed\n", + conn ? conn->c_connid : 0 )); +#else Debug( LDAP_DEBUG_ANY, "send_ldap_response: ber write failed\n", 0, 0, 0 ); +#endif + return; } @@ -358,9 +401,16 @@ send_ldap_disconnect( assert( LDAP_UNSOLICITED_ERROR( err ) ); +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "send_ldap_disconnect: conn %d %d:%s\n", + conn ? conn->c_connid : 0, err, text ? text : "" )); +#else Debug( LDAP_DEBUG_TRACE, "send_ldap_disconnect %d:%s\n", err, text ? text : "", NULL ); +#endif + if ( op->o_protocol < LDAP_VERSION3 ) { reqoid = NULL; @@ -400,18 +450,39 @@ send_ldap_result( assert( !LDAP_API_ERROR( err ) ); +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "send_ldap_result : conn %ld op=%ld p=%d\n", + (long)op->o_connid, (long)op->o_opid, op->o_protocol )); +#else Debug( LDAP_DEBUG_TRACE, "send_ldap_result: conn=%ld op=%ld p=%d\n", (long) op->o_connid, (long) op->o_opid, op->o_protocol ); +#endif + +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + "send_ldap_result: conn=%ld err=%d matched=\"%s\" text=\"%s\"\n", + (long)op->o_connid, err, matched ? matched : "", text ? text : "" )); +#else Debug( LDAP_DEBUG_ARGS, "send_ldap_result: err=%d matched=\"%s\" text=\"%s\"\n", err, matched ? matched : "", text ? text : "" ); +#endif + if( ref ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + "send_ldap_result: referral=\"%s\"\n", + ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL" )); +#else Debug( LDAP_DEBUG_ARGS, "send_ldap_result: referral=\"%s\"\n", ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL", NULL, NULL ); +#endif + } assert( err != LDAP_PARTIAL_RESULTS ); @@ -466,8 +537,15 @@ send_ldap_sasl( ber_tag_t tag; ber_int_t msgid; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "send_ldap_sasl: conn %d err=%ld len=%ld\n", + op->o_connid, (long)err, cred ? cred->bv_len : -1 )); +#else Debug( LDAP_DEBUG_TRACE, "send_ldap_sasl: err=%ld len=%ld\n", (long) err, cred ? cred->bv_len : -1, NULL ); +#endif + tag = req2res( op->o_tag ); msgid = (tag != LBER_SEQUENCE) ? op->o_msgid : 0; @@ -493,11 +571,19 @@ send_ldap_extended( ber_tag_t tag; ber_int_t msgid; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "send_ldap_extended: conn %d err=%ld oid=%s len=%ld\n", + op->o_connid, (long)err, rspoid ? rspoid : "", + rspdata != NULL ? (long)rspdata->bv_len : (long)0 )); +#else Debug( LDAP_DEBUG_TRACE, "send_ldap_extended err=%ld oid=%s len=%ld\n", (long) err, rspoid ? rspoid : "", rspdata != NULL ? (long) rspdata->bv_len : (long) 0 ); +#endif + tag = req2res( op->o_tag ); msgid = (tag != LBER_SEQUENCE) ? op->o_msgid : 0; @@ -525,9 +611,17 @@ send_search_result( char *tmp = NULL; assert( !LDAP_API_ERROR( err ) ); +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "send_search_result: conn %d err=%d matched=\"%s\"\n", + op->o_connid, err, matched ? matched : "", + text ? text : "" )); +#else Debug( LDAP_DEBUG_TRACE, "send_search_result: err=%d matched=\"%s\" text=\"%s\"\n", err, matched ? matched : "", text ? text : "" ); +#endif + assert( err != LDAP_PARTIAL_RESULTS ); @@ -591,16 +685,31 @@ send_search_entry( AttributeDescription *ad_entry = slap_schema.si_ad_entry; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "send_search_entry: conn %d dn=\"%s\"%s\n", + op->o_connid, e->e_dn, + attrsonly ? " (attrsOnly)" : "" )); +#else Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: dn=\"%s\"%s\n", e->e_dn, attrsonly ? " (attrsOnly)" : "", 0 ); +#endif + if ( ! access_allowed( be, conn, op, e, ad_entry, NULL, ACL_READ ) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + "send_search_entry: conn %d access to entry (%s) not allowed\n", + op->o_connid, e->e_dn )); +#else Debug( LDAP_DEBUG_ACL, "send_search_entry: access to entry not allowed\n", 0, 0, 0 ); +#endif + return( 1 ); } @@ -609,7 +718,14 @@ send_search_entry( ber = ber_alloc_t( LBER_USE_DER ); if ( ber == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_entry: conn %d ber_alloc failed\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 ); +#endif + send_ldap_result( conn, op, LDAP_OTHER, NULL, "BER allocation error", NULL, NULL ); goto error_return; @@ -619,7 +735,14 @@ send_search_entry( LDAP_RES_SEARCH_ENTRY, e->e_dn ); if ( rc == -1 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_entry: conn %d ber_printf failed\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); send_ldap_result( conn, op, LDAP_OTHER, NULL, "encoding DN error", NULL, NULL ); @@ -659,13 +782,27 @@ send_search_entry( } if ( ! access_allowed( be, conn, op, e, desc, NULL, ACL_READ ) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + "send_search_entry: conn %d access to attribute %s not allowed\n", + op->o_connid, desc->ad_cname->bv_val )); +#else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s not allowed\n", desc->ad_cname->bv_val, 0, 0 ); +#endif + continue; } if (( rc = ber_printf( ber, "{s[" /*]}*/ , type )) == -1 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_entry: conn %d ber_printf failed\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); send_ldap_result( conn, op, LDAP_OTHER, NULL, "encoding description error", NULL, NULL ); @@ -677,15 +814,29 @@ send_search_entry( if ( ! access_allowed( be, conn, op, e, desc, a->a_vals[i], ACL_READ ) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + "send_search_entry: conn %d access to attribute %s, value %d not allowed\n", + op->o_connid, desc->ad_cname->bv_val, i )); +#else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s, value %d not allowed\n", desc->ad_cname->bv_val, i, 0 ); +#endif + continue; } if (( rc = ber_printf( ber, "O", a->a_vals[i] )) == -1 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_entry: conn %d ber_printf failed.\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); send_ldap_result( conn, op, LDAP_OTHER, NULL, "encoding values error", NULL, NULL ); @@ -695,7 +846,14 @@ send_search_entry( } if (( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_entry: conn %d ber_printf failed\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); send_ldap_result( conn, op, LDAP_OTHER, NULL, "encode end error", NULL, NULL ); @@ -731,14 +889,28 @@ send_search_entry( } if ( ! access_allowed( be, conn, op, e, desc, NULL, ACL_READ ) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + "send_search_entry: conn %s access to attribute %s not allowed\n", + op->o_connid, desc->ad_cname->bv_val )); +#else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s not allowed\n", desc->ad_cname->bv_val, 0, 0 ); +#endif + continue; } rc = ber_printf( ber, "{s[" /*]}*/ , desc->ad_cname->bv_val ); if ( rc == -1 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_entry: conn %d ber_printf failed\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); send_ldap_result( conn, op, LDAP_OTHER, NULL, "encoding description error", NULL, NULL ); @@ -750,16 +922,30 @@ send_search_entry( if ( ! access_allowed( be, conn, op, e, desc, a->a_vals[i], ACL_READ ) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + "send_search_entry: conn %d access to %s, value %d not allowed\n", + op->o_connid, desc->ad_cname->bv_val, i )); +#else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s, value %d not allowed\n", desc->ad_cname->bv_val, i, 0 ); +#endif + continue; } if (( rc = ber_printf( ber, "O", a->a_vals[i] )) == -1 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_entry: conn %d ber_printf failed\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); send_ldap_result( conn, op, LDAP_OTHER, NULL, "encoding values error", NULL, NULL ); @@ -769,7 +955,14 @@ send_search_entry( } if (( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_entry: conn %d ber_printf failed\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); send_ldap_result( conn, op, LDAP_OTHER, NULL, "encode end error", NULL, NULL ); @@ -782,7 +975,14 @@ send_search_entry( rc = ber_printf( ber, /*{{{*/ "}N}N}" ); if ( rc == -1 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_entry: conn %d ber_printf failed\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); send_ldap_result( conn, op, LDAP_OTHER, NULL, "encode entry end error", NULL, NULL ); @@ -793,9 +993,16 @@ send_search_entry( ber_free( ber, 1 ); if ( bytes < 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_ldap_response: conn %d ber write failed.\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "send_ldap_response: ber write failed\n", 0, 0, 0 ); +#endif + return -1; } @@ -808,7 +1015,14 @@ send_search_entry( Statslog( LDAP_DEBUG_STATS2, "conn=%ld op=%ld ENTRY dn=\"%s\"\n", (long) conn->c_connid, (long) op->o_opid, e->e_dn, 0, 0 ); +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "send_search_entry: conn %d exit.\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_TRACE, "<= send_search_entry\n", 0, 0, 0 ); +#endif + rc = 0; @@ -835,32 +1049,60 @@ send_search_reference( AttributeDescription *ad_ref = slap_schema.si_ad_ref; AttributeDescription *ad_entry = slap_schema.si_ad_entry; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "send_search_reference: conn %d dn=\"%s\"\n", + op->o_connid, e->e_dn )); +#else Debug( LDAP_DEBUG_TRACE, "=> send_search_reference: dn=\"%s\"\n", e->e_dn, 0, 0 ); +#endif + if ( ! access_allowed( be, conn, op, e, ad_entry, NULL, ACL_READ ) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + "send_search_reference: conn %d access to entry %s not allowed\n", + op->o_connid, e->e_dn )); +#else Debug( LDAP_DEBUG_ACL, "send_search_reference: access to entry not allowed\n", 0, 0, 0 ); +#endif + return( 1 ); } if ( ! access_allowed( be, conn, op, e, ad_ref, NULL, ACL_READ ) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "acl", LDAP_LEVEL_INFO, + "send_search_reference: conn %d access to reference not allowed.\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ACL, "send_search_reference: access to reference not allowed\n", 0, 0, 0 ); +#endif + return( 1 ); } if( refs == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_reference: null ref in (%s).\n", + op->o_connid, e->e_dn )); +#else Debug( LDAP_DEBUG_ANY, "send_search_reference: null ref in (%s)\n", e->e_dn, 0, 0 ); +#endif + return( 1 ); } @@ -875,8 +1117,15 @@ send_search_reference( ber = ber_alloc_t( LBER_USE_DER ); if ( ber == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_reference: conn %d ber_alloc failed\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "send_search_reference: ber_alloc failed\n", 0, 0, 0 ); +#endif + send_ldap_result( conn, op, LDAP_OTHER, NULL, "alloc BER error", NULL, NULL ); return -1; @@ -886,8 +1135,15 @@ send_search_reference( LDAP_RES_SEARCH_REFERENCE, refs ); if ( rc == -1 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ERR, + "send_search_reference: conn %d ber_printf failed.\n", + op->o_connid )); +#else Debug( LDAP_DEBUG_ANY, "send_search_reference: ber_printf failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); send_ldap_result( conn, op, LDAP_OTHER, NULL, "encode DN error", NULL, NULL ); @@ -906,7 +1162,13 @@ send_search_reference( Statslog( LDAP_DEBUG_STATS2, "conn=%ld op=%ld ENTRY dn=\"%s\"\n", (long) conn->c_connid, (long) op->o_opid, e->e_dn, 0, 0 ); +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "send_search_reference: conn %d exit.\n", op->o_connid )); +#else Debug( LDAP_DEBUG_TRACE, "<= send_search_reference\n", 0, 0, 0 ); +#endif + return 0; } @@ -928,8 +1190,14 @@ str2result( *info = NULL; if ( strncasecmp( s, "RESULT", 6 ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "str2result: (%s), expecting \"RESULT\"\n", s )); +#else Debug( LDAP_DEBUG_ANY, "str2result (%s) expecting \"RESULT\"\n", s, 0, 0 ); +#endif + return( -1 ); } @@ -957,8 +1225,14 @@ str2result( *info = c; } } else { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "str2result: (%s) unknown.\n", s )); +#else Debug( LDAP_DEBUG_ANY, "str2result (%s) unknown\n", s, 0, 0 ); +#endif + rc = -1; } } diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index aa06f29b5d..e1136b4148 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -59,9 +59,17 @@ slap_sasl_log( return SASL_BADPARAM; } +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "SASL [conn=%d] %s: %s\n", + conn ? conn->c_connid : -1, + label, message )); +#else Debug( level, "SASL [conn=%d] %s: %s\n", conn ? conn->c_connid: -1, label, message ); +#endif + return SASL_OK; } @@ -80,8 +88,16 @@ int slap_sasl_getdn( Connection *conn, char *id, char **dnptr, int flags ) sasl_conn_t *ctx; +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_getdn: conn %d id=%s\n", + conn ? conn->c_connid : -1, + id ? (*id ? id : "") : "NULL" )); +#else Debug( LDAP_DEBUG_ARGS, "slap_sasl_getdn: id=%s\n", id?(*id?id:""):"NULL",0,0 ); +#endif + /* Blatantly anonymous ID */ len = strlen( "anonymous" ); @@ -119,8 +135,14 @@ int slap_sasl_getdn( Connection *conn, char *id, char **dnptr, int flags ) /* Figure out how much data we have for the dn */ rc = sasl_getprop( ctx, SASL_REALM, (void **)&c ); if( rc != SASL_OK ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, + "slap_sasl_getdn: getprop(REALM) failed.\n" )); +#else Debug(LDAP_DEBUG_TRACE, "getdn: getprop(REALM) failed!\n", 0,0,0); +#endif + ch_free( dn ); *dnptr = NULL; return( LDAP_OPERATIONS_ERROR ); @@ -146,7 +168,13 @@ int slap_sasl_getdn( Connection *conn, char *id, char **dnptr, int flags ) } strcpy( dn+len, ",cn=authzid" ); len += len1; +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "getdn: u:id converted to %s.\n", dn )); +#else Debug( LDAP_DEBUG_TRACE, "getdn: u:id converted to %s\n", dn,0,0 ); +#endif + } /* DN strings that are a cn=authzid identity to run through regexp */ @@ -162,7 +190,13 @@ int slap_sasl_getdn( Connection *conn, char *id, char **dnptr, int flags ) sprintf( dn, "dn:%s", c1 ); ch_free( c1 ); } +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_getdn: dn:id converted to %s.\n", dn )); +#else Debug( LDAP_DEBUG_TRACE, "getdn: dn:id converted to %s\n", dn,0,0 ); +#endif + } } @@ -190,11 +224,20 @@ slap_sasl_authorize( *user = NULL; +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sas_authorize: conn %d authcid=\"%s\" authzid=\"%s\"\n", + conn ? conn->c_connid : -1, + authcid ? authcid : "", + authzid ? authzid : "" )); +#else Debug( LDAP_DEBUG_ARGS, "SASL Authorize [conn=%ld]: " "authcid=\"%s\" authzid=\"%s\"\n", (long) (conn ? conn->c_connid : -1), authcid ? authcid : "", authzid ? authzid : "" ); +#endif + /* Convert the identities to DN's. If no authzid was given, client will be bound as the DN matching their username */ @@ -204,8 +247,15 @@ slap_sasl_authorize( return SASL_NOAUTHZ; } if( ( authzid == NULL ) || !strcmp( authcid,authzid ) ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_authorize: conn %d Using authcDN=%s\n", + conn ? conn->c_connid : -1, authcDN )); +#else Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " "Using authcDN=%s\n", (long) (conn ? conn->c_connid : -1), authcDN,0 ); +#endif + *user = authcDN; *errstr = NULL; return SASL_OK; @@ -219,18 +269,32 @@ slap_sasl_authorize( rc = slap_sasl_authorized( authcDN, authzDN ); if( rc ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_INFO, + "slap_sasl_authorize: conn %ld authorization disallowed (%d)\n", + (long)(conn ? conn->c_connid : -1), rc )); +#else Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " " authorization disallowed (%d)\n", (long) (conn ? conn->c_connid : -1), rc, 0 ); +#endif + *errstr = "not authorized"; ch_free( authcDN ); ch_free( authzDN ); return SASL_NOAUTHZ; } +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_authorize: conn %d authorization allowed\n", + (long)(conn ? conn->c_connid : -1 ) ); +#else Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " " authorization allowed\n", (long) (conn ? conn->c_connid : -1), 0, 0 ); +#endif + ch_free( authcDN ); *user = authzDN; @@ -303,13 +367,25 @@ int slap_sasl_init( void ) rc = sasl_server_init( server_callbacks, "slapd" ); if( rc != SASL_OK ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_INFO, + "slap_sasl_init: init failed.\n" )); +#else Debug( LDAP_DEBUG_ANY, "sasl_server_init failed\n", 0, 0, 0 ); +#endif + return -1; } +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_INFO, + "slap_sasl_init: initialized!\n")); +#else Debug( LDAP_DEBUG_TRACE, "slap_sasl_init: initialized!\n", 0, 0, 0 ); +#endif + /* default security properties */ memset( &sasl_secprops, '\0', sizeof(sasl_secprops) ); @@ -367,8 +443,14 @@ int slap_sasl_open( Connection *conn ) session_callbacks, SASL_SECURITY_LAYER, &ctx ); if( sc != SASL_OK ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, + "slap_sasl_open: sasl_server_new failed: %d\n", sc )); +#else Debug( LDAP_DEBUG_ANY, "sasl_server_new failed: %d\n", sc, 0, 0 ); +#endif + return -1; } @@ -379,8 +461,14 @@ int slap_sasl_open( Connection *conn ) SASL_SEC_PROPS, &sasl_secprops ); if( sc != SASL_OK ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, + "slap_sasl_open: sasl_setprop failed: %d \n", sc )); +#else Debug( LDAP_DEBUG_ANY, "sasl_setprop failed: %d\n", sc, 0, 0 ); +#endif + slap_sasl_close( conn ); return -1; } @@ -448,8 +536,14 @@ char ** slap_sasl_mechs( Connection *conn ) &mechstr, NULL, NULL ); if( sc != SASL_OK ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, + "slap_sasl_mechs: sasl_listmech failed: %d\n", sc )); +#else Debug( LDAP_DEBUG_ANY, "slap_sasl_listmech failed: %d\n", sc, 0, 0 ); +#endif + return NULL; } @@ -498,10 +592,19 @@ int slap_sasl_bind( const char *errstr; int sc; +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "sasl_bind: conn %ld dn=\"%s\" mech=%s datalen=%d\n", + conn->c_connid, dn, + conn->c_sasl_bind_in_progress ? "" : conn->c_sasl_bind_mech, + cred ? cred->bv_len : 0 )); +#else Debug(LDAP_DEBUG_ARGS, "==> sasl_bind: dn=\"%s\" mech=%s datalen=%d\n", dn, conn->c_sasl_bind_in_progress ? "":conn->c_sasl_bind_mech, cred ? cred->bv_len : 0 ); +#endif + if( ctx == NULL ) { send_ldap_result( conn, op, LDAP_UNAVAILABLE, @@ -530,9 +633,15 @@ int slap_sasl_bind( SASL_USERNAME, (void **)&username ); if ( sc != SASL_OK ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, + "slap_sasl_bind: getprop(USERNAME) failed: %d\n", sc )); +#else Debug(LDAP_DEBUG_TRACE, "slap_sasl_bind: getprop(USERNAME) failed!\n", 0, 0, 0); +#endif + send_ldap_result( conn, op, rc = slap_sasl_err2ldap( sc ), NULL, "no SASL username", NULL, NULL ); @@ -580,7 +689,13 @@ int slap_sasl_bind( NULL, errstr, NULL, NULL ); } +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_bind: rc=%d\n", rc )); +#else Debug(LDAP_DEBUG_TRACE, "<== slap_sasl_bind: rc=%d\n", rc, 0, 0); +#endif + #else send_ldap_result( conn, op, rc = LDAP_UNAVAILABLE, diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index 392c1caad9..d5a6389e55 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -42,7 +42,13 @@ int slap_parseURI( char *uri, char **searchbase, int *scope, Filter **filter ) *scope = -1; *filter = NULL; +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_parseURI: parsing %s\n", uri )); +#else Debug( LDAP_DEBUG_TRACE, "slap_parseURI: parsing %s\n", uri, 0, 0 ); +#endif + /* If it does not look like a URI, assume it is a DN */ if( !strncasecmp( uri, "dn:", 3 ) ) { @@ -134,9 +140,16 @@ int slap_sasl_regexp_config( const char *match, const char *replace ) /* Precompile matching pattern */ rc = regcomp( ®->workspace, reg->match, REG_EXTENDED|REG_ICASE ); if ( rc ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, + "slap_sasl_regexp_config: \"%s\" could not be compiled.\n" + reg->match )); +#else Debug( LDAP_DEBUG_ANY, "SASL match pattern %s could not be compiled by regexp engine\n", reg->match, 0, 0 ); +#endif + return( LDAP_OPERATIONS_ERROR ); } @@ -150,9 +163,16 @@ int slap_sasl_regexp_config( const char *match, const char *replace ) } if ( *c == '$' ) { if ( n == SASLREGEX_REPLACE ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ERR, + "slap_sasl_regexp_config: \"%s\" has too many $n placeholders (max %d)\n", + reg->replace, SASLREGEX_REPLACE )); +#else Debug( LDAP_DEBUG_ANY, "SASL replace pattern %s has too many $n placeholders (max %d)\n", reg->replace, SASLREGEX_REPLACE, 0 ); +#endif + return( LDAP_OPERATIONS_ERROR ); } reg->offset[n] = c - reg->replace; @@ -189,8 +209,14 @@ char *slap_sasl_regexp( char *saslname ) SaslRegexp_t *reg; +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_regexp: converting SASL name %s\n", saslname )); +#else Debug( LDAP_DEBUG_TRACE, "slap_sasl_regexp: converting SASL name %s\n", saslname, 0, 0 ); +#endif + if (( saslname == NULL ) || ( nSaslRegexp == 0 )) return( NULL ); @@ -249,8 +275,14 @@ char *slap_sasl_regexp( char *saslname ) } uri[insert] = '\0'; +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_regexp: converted SASL name to %s\n", uri )); +#else Debug( LDAP_DEBUG_TRACE, "slap_sasl_regexp: converted SASL name to %s\n", uri, 0, 0 ); +#endif + return( uri ); } @@ -278,8 +310,14 @@ char *slap_sasl2dn( char *saslname ) LDAPMessage *res=NULL, *msg; +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl2dn: converting SASL name %s to DN.\n", saslname )); +#else Debug( LDAP_DEBUG_TRACE, "==>slap_sasl2dn: Converting SASL name %s to a DN\n", saslname, 0,0 ); +#endif + /* Convert the SASL name into an LDAP URI */ uri = slap_sasl_regexp( saslname ); @@ -298,9 +336,16 @@ char *slap_sasl2dn( char *saslname ) /* Must do an internal search */ +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_DETAIL1, + "slap_sasl2dn: performing internal search (base=%s, scope=%s)\n", + searchbase, scope )); +#else Debug( LDAP_DEBUG_TRACE, "slap_sasl2dn: performing internal search (base=%s, scope=%d)\n", searchbase, scope, 0 ); +#endif + be = select_backend( searchbase, 0 ); if(( be == NULL ) || ( be->be_search == NULL)) @@ -323,8 +368,14 @@ char *slap_sasl2dn( char *saslname ) /* Make sure exactly one entry was returned */ rc = ldap_count_entries( client, res ); +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_DETAIL1, + "slap_sasl2dn: search DN returned %d entries\n", rc )); +#else Debug( LDAP_DEBUG_TRACE, "slap_sasl2dn: search DN returned %d entries\n", rc,0,0 ); +#endif + if( rc != 1 ) goto FINISHED; @@ -339,8 +390,14 @@ FINISHED: if( res ) ldap_msgfree( res ); if( client ) ldap_unbind( client ); if( DN ) dn_normalize( DN ); +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl2dn: Converted SASL name to %s\n", DN ? DN : "" )); +#else Debug( LDAP_DEBUG_TRACE, "<==slap_sasl2dn: Converted SASL name to %s\n", DN ? DN : "", 0, 0 ); +#endif + return( DN ); } @@ -370,8 +427,14 @@ int slap_sasl_match( char *rule, char *assertDN, char *authc ) regex_t reg; +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_match: comparing DN %s to rule %s\n", assertDN, rule ); +#else Debug( LDAP_DEBUG_TRACE, "===>slap_sasl_match: comparing DN %s to rule %s\n", assertDN, rule, 0 ); +#endif + rc = slap_parseURI( rule, &searchbase, &scope, &filter ); if( rc != LDAP_SUCCESS ) @@ -394,9 +457,16 @@ int slap_sasl_match( char *rule, char *assertDN, char *authc ) /* Must run an internal search. */ +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_DETAIL1, + "slap_sasl_match: performing internal search (base=%s, scope=%d)\n", + searchbase, scope )); +#else Debug( LDAP_DEBUG_TRACE, "slap_sasl_match: performing internal search (base=%s, scope=%d)\n", searchbase, scope, 0 ); +#endif + be = select_backend( searchbase, 0 ); if(( be == NULL ) || ( be->be_search == NULL)) { @@ -441,8 +511,14 @@ CONCLUDED: if( conn ) connection_internal_close( conn ); if( res ) ldap_msgfree( res ); if( client ) ldap_unbind( client ); +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_match: comparison returned %d\n", rc )); +#else Debug( LDAP_DEBUG_TRACE, "<===slap_sasl_match: comparison returned %d\n", rc, 0, 0); +#endif + return( rc ); } @@ -468,9 +544,16 @@ slap_sasl_check_authz(char *searchDN, char *assertDN, char *attr, char *authc) AttributeDescription *ad=NULL; +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_check_authz: does %s match %s rule in %s?\n", + assertDN, attr, searchDN )); +#else Debug( LDAP_DEBUG_TRACE, "==>slap_sasl_check_authz: does %s match %s rule in %s?\n", assertDN, attr, searchDN); +#endif + rc = slap_str2ad( attr, &ad, &errmsg ); if( rc != LDAP_SUCCESS ) goto COMPLETE; @@ -491,8 +574,14 @@ COMPLETE: if( vals ) ber_bvecfree( vals ); if( ad ) ad_free( ad, 1 ); +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_check_authz: %s check returning %s\n", attr, rc )); +#else Debug( LDAP_DEBUG_TRACE, "<==slap_sasl_check_authz: %s check returning %d\n", attr, rc, 0); +#endif + return( rc ); } @@ -518,8 +607,14 @@ int slap_sasl_authorized( char *authcDN, char *authzDN ) goto DONE; } +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_authorized: can %s become %s?\n", authcDN, authzDN )); +#else Debug( LDAP_DEBUG_TRACE, "==>slap_sasl_authorized: can %s become %s?\n", authcDN, authzDN, 0 ); +#endif + /* If person is authorizing to self, succeed */ if ( !strcmp( authcDN, authzDN ) ) { @@ -543,6 +638,12 @@ int slap_sasl_authorized( char *authcDN, char *authzDN ) rc = LDAP_INAPPROPRIATE_AUTH; DONE: +#ifdef NEW_LOGGING + LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, + "slap_sasl_authorized: return %s\n", rc )); +#else Debug( LDAP_DEBUG_TRACE, "<== slap_sasl_authorized: return %d\n",rc,0,0 ); +#endif + return( rc ); } diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index 29cb3d9e09..6e6e797c31 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -40,8 +40,14 @@ entry_schema_check( /* find the object class attribute - could error out here */ if ( (aoc = attr_find( e->e_attrs, ad_objectClass )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_INFO, + "entry_schema_check: No object class for entry (%s).\n", e->e_dn )); +#else Debug( LDAP_DEBUG_ANY, "No object class for entry (%s)\n", e->e_dn, 0, 0 ); +#endif + *text = "no objectClass attribute"; return LDAP_OBJECT_CLASS_VIOLATION; } @@ -51,9 +57,16 @@ entry_schema_check( /* check that the entry has required attrs for each oc */ for ( i = 0; aoc->a_vals[i] != NULL; i++ ) { if ( (oc = oc_find( aoc->a_vals[i]->bv_val )) == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_INFO, + "entry_schema_check: dn (%s), objectclass \"%s\" not recognized\n", + e->e_dn, aoc->a_vals[i]->bv_val )); +#else Debug( LDAP_DEBUG_ANY, "entry_check_schema(%s): objectclass \"%s\" not recognized\n", e->e_dn, aoc->a_vals[i]->bv_val, 0 ); +#endif + *text = "unrecognized object class"; return LDAP_OBJECT_CLASS_VIOLATION; @@ -61,9 +74,16 @@ entry_schema_check( char *s = oc_check_required( e, aoc->a_vals[i] ); if (s != NULL) { +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_INFO, + "entry_schema_check: dn (%s) oc \"%s\" requires att \"%s\"\n", + e->e_dn, aoc->a_vals[i]->bv_val, s )); +#else Debug( LDAP_DEBUG_ANY, "Entry (%s), oc \"%s\" requires attr \"%s\"\n", e->e_dn, aoc->a_vals[i]->bv_val, s ); +#endif + *text = "missing required attribute"; return LDAP_OBJECT_CLASS_VIOLATION; } @@ -84,9 +104,16 @@ entry_schema_check( ret = oc_check_allowed( a->a_desc->ad_type, aoc->a_vals ); if ( ret != 0 ) { char *type = a->a_desc->ad_cname->bv_val; +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_INFO, + "entry_schema_check: Entry (%s) attr \"%s\" not allowed.\n", + e->e_dn, type )); +#else Debug( LDAP_DEBUG_ANY, "Entry (%s), attr \"%s\" not allowed\n", e->e_dn, type, 0 ); +#endif + *text = "attribute not allowed"; break; } @@ -103,9 +130,16 @@ oc_check_required( Entry *e, struct berval *ocname ) int i; Attribute *a; +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, + "oc_check_required: dn (%s), objectclass \"%s\"\n", + e->e_dn, ocname->bv_val )); +#else Debug( LDAP_DEBUG_TRACE, "oc_check_required entry (%s), objectclass \"%s\"\n", e->e_dn, ocname->bv_val, 0 ); +#endif + /* find global oc defn. it we don't know about it assume it's ok */ if ( (oc = oc_find( ocname->bv_val )) == NULL ) { @@ -142,9 +176,15 @@ int oc_check_allowed( ObjectClass *oc; int i, j; +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, + "oc_check_allowed: type \"%s\"\n", at->sat_cname )); +#else Debug( LDAP_DEBUG_TRACE, "oc_check_allowed type \"%s\"\n", at->sat_cname, 0, 0 ); +#endif + /* always allow objectclass attribute */ if ( strcasecmp( at->sat_cname, "objectclass" ) == 0 ) { diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 04084b0672..6961745e82 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -289,8 +289,15 @@ dnMatch( #endif } +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, + "dnMatch: %d\n %s\n %s\n", match, + value->bv_val, asserted->bv_val )); +#else Debug( LDAP_DEBUG_ARGS, "dnMatch %d\n\t\"%s\"\n\t\"%s\"\n", match, value->bv_val, asserted->bv_val ); +#endif + *matchp = match; return LDAP_SUCCESS; @@ -3735,9 +3742,16 @@ objectIdentifierFirstComponentMatch( ch_free( stored ); } +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, + "objectIdentifierFirstComponentMatch: %d\n %s\n %s\n", + match, value->bv_val, asserted->bv_val )); +#else Debug( LDAP_DEBUG_ARGS, "objectIdentifierFirstComponentMatch " "%d\n\t\"%s\"\n\t\"%s\"\n", match, value->bv_val, asserted->bv_val ); +#endif + if( rc == LDAP_SUCCESS ) *matchp = match; return rc; diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index ce6bbbd9e6..ec2de05531 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -60,8 +60,15 @@ objectClassMatch( } #if 0 +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, + "objectClassMatch(%s, %s) = %d\n", + value->bv_val, a->bv_val, *matchp )); +#else Debug( LDAP_DEBUG_TRACE, "objectClassMatch(%s,%s) = %d\n", value->bv_val, a->bv_val, *matchp ); +#endif + #endif return LDAP_SUCCESS; @@ -102,8 +109,15 @@ structuralObjectClassMatch( *matchp = ( asserted != oc ); #if 0 +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, + "structuralObjectClassMatch( %s, %s ) = %d\n", + value->bv_val, a->bv_val, *matchp )); +#else Debug( LDAP_DEBUG_TRACE, "structuralObjectClassMatch(%s,%s) = %d\n", value->bv_val, a->bv_val, *matchp ); +#endif + #endif return LDAP_SUCCESS; diff --git a/servers/slapd/search.c b/servers/slapd/search.c index e197f28ffd..5136449623 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -41,9 +41,13 @@ do_search( const char *text; int manageDSAit; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "do_search: conn %d\n", conn->c_connid )); +#else Debug( LDAP_DEBUG_TRACE, "do_search\n", 0, 0, 0 ); - LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, "conn: %d do_search\n", - conn->c_connid)); +#endif + /* * Parse the search request. It looks like this: * @@ -109,9 +113,15 @@ do_search( goto return_results; } +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + "do_search \"%s\" %d %d %d %d %d\n", base, scope, + deref, sizelimit, timelimit, attrsonly )); +#else Debug( LDAP_DEBUG_ARGS, "SRCH \"%s\" %d %d", base, scope, deref ); Debug( LDAP_DEBUG_ARGS, " %d %d %d\n", sizelimit, timelimit, attrsonly); +#endif /* filter - returns a "normalized" version */ rc = get_filter( conn, op->o_ber, &filter, &fstr, &text ); @@ -126,7 +136,13 @@ do_search( goto return_results; } +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + "do_search: conn %d filter: %s\n", conn->c_connid, fstr )); +#else Debug( LDAP_DEBUG_ARGS, " filter: %s\n", fstr, 0, 0 ); +#endif + /* attributes */ if ( ber_scanf( op->o_ber, /*{*/ "{v}}", &attrs ) == LBER_ERROR ) { @@ -137,21 +153,45 @@ do_search( } if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "do_search: conn %d get_ctrls failed (%d)\n", + conn->c_connid, rc )); +#else Debug( LDAP_DEBUG_ANY, "do_search: get_ctrls failed\n", 0, 0, 0 ); +#endif + goto return_results; } rc = 0; +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + "do_search: conn %d attrs:", conn->c_connid )); +#else Debug( LDAP_DEBUG_ARGS, " attrs:", 0, 0, 0 ); +#endif + if ( attrs != NULL ) { for ( i = 0; attrs[i] != NULL; i++ ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, + "do_search: %s", attrs[i] )); +#else Debug( LDAP_DEBUG_ARGS, " %s", attrs[i], 0, 0 ); +#endif + } } +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, "\n" )); +#else Debug( LDAP_DEBUG_ARGS, "\n", 0, 0, 0 ); +#endif + Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d SRCH base=\"%s\" scope=%d filter=\"%s\"\n", diff --git a/servers/slapd/str2filter.c b/servers/slapd/str2filter.c index f21ffd2d7f..9ce1371bb1 100644 --- a/servers/slapd/str2filter.c +++ b/servers/slapd/str2filter.c @@ -27,7 +27,13 @@ str2filter( const char *str ) Filter *f = NULL; char *end, *freeme; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "str2filter: \"%s\"\n", str )); +#else Debug( LDAP_DEBUG_FILTER, "str2filter \"%s\"\n", str, 0, 0 ); +#endif + if ( str == NULL || *str == '\0' ) { return( NULL ); @@ -47,32 +53,56 @@ str2filter( const char *str ) str++; switch ( *str ) { case '&': +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "str2filter: AND\n" )); +#else Debug( LDAP_DEBUG_FILTER, "str2filter: AND\n", 0, 0, 0 ); +#endif + str++; f = str2list( str, LDAP_FILTER_AND ); break; case '|': +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "str2filter: OR\n" )); +#else Debug( LDAP_DEBUG_FILTER, "put_filter: OR\n", 0, 0, 0 ); +#endif + str++; f = str2list( str, LDAP_FILTER_OR ); break; case '!': +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "str2filter: NOT\n" )); +#else Debug( LDAP_DEBUG_FILTER, "put_filter: NOT\n", 0, 0, 0 ); +#endif + str++; f = str2list( str, LDAP_FILTER_NOT ); break; default: +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "str2filter: simple\n" )); +#else Debug( LDAP_DEBUG_FILTER, "str2filter: simple\n", 0, 0, 0 ); +#endif + f = str2simple( str ); break; @@ -81,8 +111,14 @@ str2filter( const char *str ) break; default: /* assume it's a simple type=value filter */ +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, + "str2filter: default\n" )); +#else Debug( LDAP_DEBUG_FILTER, "str2filter: default\n", 0, 0, 0 ); +#endif + f = str2simple( str ); break; @@ -104,7 +140,13 @@ str2list( const char *str, unsigned long ftype ) char *next; char save; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "str2list: \"%s\"\n", str )); +#else Debug( LDAP_DEBUG_FILTER, "str2list \"%s\"\n", str, 0, 0 ); +#endif + f = (Filter *) ch_calloc( 1, sizeof(Filter) ); f->f_choice = ftype; @@ -148,7 +190,13 @@ str2simple( const char *str ) int rc; const char *text; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "str2simple: \"%s\"\n", str )); +#else Debug( LDAP_DEBUG_FILTER, "str2simple \"%s\"\n", str, 0, 0 ); +#endif + if ( (s = strchr( str, '=' )) == NULL ) { return( NULL ); @@ -240,7 +288,13 @@ str2subvals( const char *in, Filter *f ) char *nextstar, *val, *freeme; int gotstar; +#ifdef NEW_LOGGING + LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, + "str2subvals: \"%s\"\n", in )); +#else Debug( LDAP_DEBUG_FILTER, "str2subvals \"%s\"\n", in, 0, 0 ); +#endif + if( in == NULL ) return 0; diff --git a/servers/slapd/suffixalias.c b/servers/slapd/suffixalias.c index 848364897b..64cd7f4518 100644 --- a/servers/slapd/suffixalias.c +++ b/servers/slapd/suffixalias.c @@ -63,9 +63,16 @@ char *suffix_alias( dn = ch_malloc( diff + strlen(be->be_suffixAlias[i+1]) + 1 ); strncpy( dn, oldDN, diff ); strcpy( &dn[diff], be->be_suffixAlias[i+1] ); +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "suffix_alias: converted \"%s\" to \"%s\"\n", + oldDN, dn )); +#else Debug( LDAP_DEBUG_ARGS, "suffix_alias: converted \"%s\" to \"%s\"\n", oldDN, dn, 0); +#endif + free (oldDN); break; } diff --git a/servers/slapd/syntax.c b/servers/slapd/syntax.c index 6fd2a73e3b..e2207c8dc0 100644 --- a/servers/slapd/syntax.c +++ b/servers/slapd/syntax.c @@ -150,8 +150,15 @@ register_syntax( syn = ldap_str2syntax( desc, &code, &err, LDAP_SCHEMA_ALLOW_ALL); if ( !syn ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_ERR, + "register_syntax: Error - %s before %s in %s.\n", + ldap_scherr2str(code), err, desc )); +#else Debug( LDAP_DEBUG_ANY, "Error in register_syntax: %s before %s in %s\n", ldap_scherr2str(code), err, desc ); +#endif + return( -1 ); } @@ -160,8 +167,15 @@ register_syntax( ldap_memfree( syn ); if ( code ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_ERR, + "register_syntax: Error - %s %s in %s\n", + scherr2str(code), err, desc )); +#else Debug( LDAP_DEBUG_ANY, "Error in register_syntax: %s %s in %s\n", scherr2str(code), err, desc ); +#endif + return( -1 ); } @@ -198,8 +212,15 @@ syn_schema_info( Entry *e ) } val.bv_len = strlen( val.bv_val ); #if 0 +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, + "syn_schema_info: Merging syn [%ld] %s\n", + (long)val.bv_len, val.bv_val )); +#else Debug( LDAP_DEBUG_TRACE, "Merging syn [%ld] %s\n", (long) val.bv_len, val.bv_val, 0 ); +#endif + #endif attr_merge( e, ad_ldapSyntaxes, vals ); ldap_memfree( val.bv_val ); diff --git a/servers/slapd/unbind.c b/servers/slapd/unbind.c index e4abaaed66..c1744576a8 100644 --- a/servers/slapd/unbind.c +++ b/servers/slapd/unbind.c @@ -33,7 +33,13 @@ do_unbind( Operation *op ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, + "do_unbind: conn %d\n", conn ? conn->c_connid : -1 )); +#else Debug( LDAP_DEBUG_TRACE, "do_unbind\n", 0, 0, 0 ); +#endif + /* * Parse the unbind request. It looks like this: diff --git a/servers/slapd/user.c b/servers/slapd/user.c index 3a3ecdff17..97ee7ed3f0 100644 --- a/servers/slapd/user.c +++ b/servers/slapd/user.c @@ -63,8 +63,15 @@ slap_init_user( char *user, char *group ) pwd = getpwnam( user ); did_getpw: if ( pwd == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "slap_init_user: No passwd entry for user %s\n", + user )); +#else Debug( LDAP_DEBUG_ANY, "No passwd entry for user %s\n", user, 0, 0 ); +#endif + exit( EXIT_FAILURE ); } if ( got_uid ) { @@ -96,8 +103,14 @@ slap_init_user( char *user, char *group ) gid = grp->gr_gid; did_group: if ( grp == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "slap_init_user: No group entry for group %s\n", group)); +#else Debug( LDAP_DEBUG_ANY, "No group entry for group %s\n", group, 0, 0 ); +#endif + exit( EXIT_FAILURE ); } } @@ -107,8 +120,14 @@ slap_init_user( char *user, char *group ) if ( user ) { if ( getuid() == 0 && initgroups( user, gid ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "slap_init_user: Could not set the group access (gid) list.\n" )); +#else Debug( LDAP_DEBUG_ANY, "Could not set the group access (gid) list\n", 0, 0, 0 ); +#endif + exit( EXIT_FAILURE ); } free( user ); @@ -120,14 +139,26 @@ slap_init_user( char *user, char *group ) if ( got_gid ) { if ( setgid( gid ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "slap_init_user: could not set real group id to %d\n", (int)gid)); +#else Debug( LDAP_DEBUG_ANY, "Could not set real group id to %d\n", (int) gid, 0, 0 ); +#endif + exit( EXIT_FAILURE ); } #ifdef HAVE_SETEGID if ( setegid( gid ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "slap_init_user: Could not set effective group id to %d\n",(int)gid)); +#else Debug( LDAP_DEBUG_ANY, "Could not set effective group id to %d\n", (int) gid, 0, 0 ); +#endif + exit( EXIT_FAILURE ); } #endif @@ -135,14 +166,26 @@ slap_init_user( char *user, char *group ) if ( got_uid ) { if ( setuid( uid ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "slap_init_user: Could not set real user id to %d\n", (int)uid )); +#else Debug( LDAP_DEBUG_ANY, "Could not set real user id to %d\n", (int) uid, 0, 0 ); +#endif + exit( EXIT_FAILURE ); } #ifdef HAVE_SETEUID if ( seteuid( uid ) != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_INFO, + "slap_init_user: Could not set effective user id to %d\n", (int)uid )); +#else Debug( LDAP_DEBUG_ANY, "Could not set effective user id to %d\n", (int) uid, 0, 0 ); +#endif + exit( EXIT_FAILURE ); } #endif