From 1814d9b6f108c5dc5ec56867d02c3d5846a97db4 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sun, 28 Jul 2002 21:10:45 +0000 Subject: [PATCH] mostly new logging --- libraries/libldap/abandon.c | 7 +- libraries/libldap/add.c | 2 +- libraries/libldap/bind.c | 6 +- libraries/libldap/cache.c | 93 +++--- libraries/libldap/compare.c | 3 +- libraries/libldap/cyrus.c | 26 +- libraries/libldap/delete.c | 4 +- libraries/libldap/dntest.c | 4 +- libraries/libldap/error.c | 20 +- libraries/libldap/extended.c | 10 +- libraries/libldap/filter.c | 51 ++- libraries/libldap/getattr.c | 4 +- libraries/libldap/getdn.c | 39 ++- libraries/libldap/getfilter.c | 6 +- libraries/libldap/getvalues.c | 4 +- libraries/libldap/init.c | 37 +-- libraries/libldap/kbind.c | 22 +- libraries/libldap/modify.c | 4 +- libraries/libldap/modrdn.c | 4 +- libraries/libldap/open.c | 12 +- libraries/libldap/options.c | 608 ++++++++++++++++++++++++++++++++++ libraries/libldap/os-ip.c | 26 +- libraries/libldap/os-local.c | 12 +- libraries/libldap/request.c | 80 ++--- libraries/libldap/result.c | 113 ++++--- libraries/libldap/sasl.c | 17 +- libraries/libldap/sbind.c | 5 +- libraries/libldap/schema.c | 2 +- libraries/libldap/search.c | 6 +- libraries/libldap/tls.c | 113 ++++--- libraries/libldap/unbind.c | 4 +- libraries/libldap/url.c | 13 +- 32 files changed, 983 insertions(+), 374 deletions(-) create mode 100644 libraries/libldap/options.c diff --git a/libraries/libldap/abandon.c b/libraries/libldap/abandon.c index 70c2d97e73..a88a5865b5 100644 --- a/libraries/libldap/abandon.c +++ b/libraries/libldap/abandon.c @@ -58,7 +58,7 @@ ldap_abandon_ext( { int rc; #ifdef NEW_LOGGING - LDAP_LOG (( "abandon", LDAP_LEVEL_ARGS, "ldap_abandon_ext %d\n", msgid )); + LDAP_LOG ( OPERATION, ARGS, "ldap_abandon_ext %d\n", msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 ); #endif @@ -86,7 +86,7 @@ int ldap_abandon( LDAP *ld, int msgid ) { #ifdef NEW_LOGGING - LDAP_LOG (( "abandon", LDAP_LEVEL_ARGS, "ldap_abandon %d\n", msgid )); + LDAP_LOG ( OPERATION, ARGS, "ldap_abandon %d\n", msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_abandon %d\n", msgid, 0, 0 ); #endif @@ -110,8 +110,7 @@ do_abandon( LDAPRequest *lr; #ifdef NEW_LOGGING - LDAP_LOG (( "abandon", LDAP_LEVEL_ARGS, "do_abandon %d, msgid %d\n", - origid, msgid )); + LDAP_LOG ( OPERATION, ARGS, "do_abandon %d, msgid %d\n", origid, msgid, 0 ); #else Debug( LDAP_DEBUG_TRACE, "do_abandon origid %d, msgid %d\n", origid, msgid, 0 ); diff --git a/libraries/libldap/add.c b/libraries/libldap/add.c index 1ce57eba7f..20a987e977 100644 --- a/libraries/libldap/add.c +++ b/libraries/libldap/add.c @@ -100,7 +100,7 @@ ldap_add_ext( int i, rc; #ifdef NEW_LOGGING - LDAP_LOG (( "add", LDAP_LEVEL_ENTRY, "ldap_add_ext\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_add_ext\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_add_ext\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/bind.c b/libraries/libldap/bind.c index 076bd17976..4040da1804 100644 --- a/libraries/libldap/bind.c +++ b/libraries/libldap/bind.c @@ -42,7 +42,7 @@ #include #include "ldap-int.h" - +#include "ldap_log.h" /* * ldap_bind - bind to the ldap server (and X.500). The dn and password @@ -61,7 +61,7 @@ int ldap_bind( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd, int authmethod ) { #ifdef NEW_LOGGING - LDAP_LOG (( "bind", LDAP_LEVEL_ENTRY, "ldap_bind\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_bind\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_bind\n", 0, 0, 0 ); #endif @@ -110,7 +110,7 @@ ldap_bind_s( int authmethod ) { #ifdef NEW_LOGGING - LDAP_LOG (( "bind", LDAP_LEVEL_ENTRY, "ldap_bind_s\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_bind_s\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_bind_s\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/cache.c b/libraries/libldap/cache.c index 83e6e7953c..f071ab6255 100644 --- a/libraries/libldap/cache.c +++ b/libraries/libldap/cache.c @@ -118,7 +118,7 @@ ldap_flush_cache( LDAP *ld ) assert( LDAP_VALID( ld ) ); #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_flush_cache\n" )); + LDAP_LOG ( CACHE, ENTRY, "ldap_flush_cache\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_flush_cache\n", 0, 0, 0 ); #endif @@ -154,9 +154,9 @@ ldap_uncache_request( LDAP *ld, int msgid ) #ifndef LDAP_NOCACHE #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, - "ldap_uncache_request %d ld_cache %lx\n", - msgid, (long) ld->ld_cache )); + + LDAP_LOG ( CACHE, ARGS, "ldap_uncache_request %d ld_cache %lx\n", + msgid, (long) ld->ld_cache, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_uncache_request %d ld_cache %lx\n", msgid, (long) ld->ld_cache, 0 ); @@ -176,9 +176,9 @@ ldap_uncache_entry( LDAP *ld, LDAP_CONST char *dn ) #ifndef LDAP_NOCACHE #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, - "ldap_uncache_entry %s ld_cache %lx\n", - dn, (long) ld->ld_cache )); + + LDAP_LOG ( CACHE, ARGS, "ldap_uncache_entry %s ld_cache %lx\n", + dn, (long) ld->ld_cache, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry %s ld_cache %lx\n", dn, (long) ld->ld_cache, 0 ); @@ -200,9 +200,10 @@ uncache_entry_or_req( LDAP *ld, LDAPMessage *m, *prev, *next; #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, + + LDAP_LOG ( CACHE, ARGS, "uncache_entry_or_req dn %s msgid %ld ld_cache %lx\n", - dn, (long) msgid, (long) ld->ld_cache )); + dn, (long) msgid, (long) ld->ld_cache ); #else Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry_or_req dn %s msgid %ld ld_cache %lx\n", @@ -266,7 +267,7 @@ ldap_add_request_to_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) assert( LDAP_VALID( ld ) ); #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_add_request_to_cache\n" )); + LDAP_LOG ( CACHE, ENTRY, "ldap_add_request_to_cache\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_add_request_to_cache\n", 0, 0, 0 ); #endif @@ -318,9 +319,10 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) assert( result != NULL ); #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, + + LDAP_LOG ( CACHE, ARGS, "ldap_add_result_to_cache: id %ld, type %ld\n", - (long) result->lm_msgid, (long) result->lm_msgtype )); + (long) result->lm_msgid, (long) result->lm_msgtype, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_add_result_to_cache: id %ld, type %ld\n", (long) result->lm_msgid, (long) result->lm_msgtype, 0 ); @@ -329,8 +331,8 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) if ( ld->ld_cache == NULL || ( ld->ld_cache->lc_enabled == 0 )) { #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, - "ldap_add_result_to_cache: cache disabled\n" )); + LDAP_LOG ( CACHE, DETAIL1, + "ldap_add_result_to_cache: cache disabled\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "artc: cache disabled\n", 0, 0, 0 ); #endif @@ -345,9 +347,9 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) * only cache search and compare operations */ #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, - "ldap_add_result_to_cache: " - "only caching search & compare operations\n" )); + LDAP_LOG ( CACHE, DETAIL1, + "ldap_add_result_to_cache: only caching search & " + "compare operations\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "artc: only caching search & compare operations\n", 0, 0, 0 ); @@ -376,9 +378,9 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) new->lm_chain = NULL; m->lm_chain = new; #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, + LDAP_LOG ( CACHE, RESULTS, "ldap_add_result_to_cache: " - "result added to cache request chain\n" )); + "result added to cache request chain\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "artc: result added to cache request chain\n", @@ -418,9 +420,9 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) if ( !keep ) { #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, + LDAP_LOG ( CACHE, RESULTS, "ldap_add_result_to_cache: " - "not caching result with error\n" )); + "not caching result with error\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "artc: not caching result with error %d\n", @@ -436,9 +438,9 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) ld->ld_cache->lc_memused += msg_size( req ); check_cache_memused( ld->ld_cache ); #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, + LDAP_LOG ( CACHE, RESULTS, "ldap_add_result_to_cache: " - "cached result with error\n" )); + "cached result with error\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "artc: cached result with error %d\n", @@ -448,9 +450,8 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) } } else { #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, - "ldap_add_result_to_cache: " - "msgid not in request list\n" )); + LDAP_LOG ( CACHE, RESULTS, + "ldap_add_result_to_cache: msgid not in request list\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "artc: msgid not in request list\n", 0, 0, 0 ); @@ -481,7 +482,7 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) assert( request != NULL ); #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_check_cache\n" )); + LDAP_LOG ( CACHE, ENTRY, "ldap_check_cache\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_check_cache\n", 0, 0, 0 ); #endif @@ -503,9 +504,9 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) hash = cache_hash( &reqber ); for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULL; m = next ) { #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( CACHE, DETAIL1, "ldap_check_cache: examining id %ld, type %ld\n", - (long) m->lm_msgid, (long) m->lm_msgtype )); + (long) m->lm_msgid, (long) m->lm_msgtype, 0 ); #else Debug( LDAP_DEBUG_TRACE,"cc: examining id %ld,type %ld\n", (long) m->lm_msgid, (long) m->lm_msgtype, 0 ); @@ -519,9 +520,8 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) prev->lm_next = next; } #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, - "ldap_check_cache: expired id %ld\n", - (long) m->lm_msgid )); + LDAP_LOG ( CACHE, DETAIL1, "ldap_check_cache: expired id %ld\n", + (long) m->lm_msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "cc: expired id %d\n", m->lm_msgid, 0, 0 ); @@ -562,9 +562,8 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) } prev = new; #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, - "ldap_check_cache: added type %ld\n", - (long) m->lm_msgtype )); + LDAP_LOG ( CACHE, DETAIL1, "ldap_check_cache: added type %ld\n", + (long) m->lm_msgtype, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "cc: added type %ld\n", (long) new->lm_msgtype, 0, 0 ); @@ -572,8 +571,8 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) } #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, - "ldap_check_cache: result returned from cache\n" )); + LDAP_LOG ( CACHE, RESULTS, + "ldap_check_cache: result returned from cache\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "cc: result returned from cache\n", 0, 0, 0 ); #endif @@ -603,9 +602,8 @@ cache_hash( BerElement *ber ) } #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, - "cache_hash: len is %ld, returning %ld\n", - len, len % LDAP_CACHE_BUCKETS )); + LDAP_LOG ( CACHE, RESULTS, "cache_hash: len is %ld, returning %ld\n", + len, len % LDAP_CACHE_BUCKETS, 0 ); #else Debug( LDAP_DEBUG_TRACE, "cache_hash: len is %ld, returning %ld\n", len, len % LDAP_CACHE_BUCKETS, 0 ); @@ -760,9 +758,9 @@ check_cache_memused( LDAPCache *lc ) LDAPMessage *m, *prev, *next; #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( CACHE, DETAIL1, "check_cache_memused: %ld bytes in use (%ld max)\n", - lc->lc_memused, lc->lc_maxmem )); + lc->lc_memused, lc->lc_maxmem, 0 ); #else Debug( LDAP_DEBUG_TRACE, "check_cache_memused: %ld bytes in use (%ld max)\n", lc->lc_memused, lc->lc_maxmem, 0 ); @@ -789,9 +787,8 @@ check_cache_memused( LDAPCache *lc ) } lc->lc_memused -= msg_size( m ); #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, - "check_cache_memused: removed %ld\n", - m->lm_msgid )); + LDAP_LOG ( CACHE, DETAIL1, + "check_cache_memused: removed %ld\n", m->lm_msgid,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "ccm: removed %d\n", @@ -807,9 +804,9 @@ check_cache_memused( LDAPCache *lc ) } #ifdef NEW_LOGGING - LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, - "check_cache_memused: reduced usage to %ld bytes\n", - lc->lc_memused )); + LDAP_LOG ( CACHE, DETAIL1, + "check_cache_memused: reduced usage to %ld bytes\n", + lc->lc_memused, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ccm: reduced usage to %ld bytes\n", lc->lc_memused, 0, 0 ); diff --git a/libraries/libldap/compare.c b/libraries/libldap/compare.c index 4af59d01b8..bb13bcc11f 100644 --- a/libraries/libldap/compare.c +++ b/libraries/libldap/compare.c @@ -29,6 +29,7 @@ #include #include "ldap-int.h" +#include "ldap_log.h" /* * ldap_compare_ext - perform an ldap extended compare operation. The dn @@ -55,7 +56,7 @@ ldap_compare_ext( BerElement *ber; #ifdef NEW_LOGGING - LDAP_LOG (( "compare", LDAP_LEVEL_ENTRY, "ldap_compare\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_compare\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c index f215b752e1..5310903c0e 100644 --- a/libraries/libldap/cyrus.c +++ b/libraries/libldap/cyrus.c @@ -361,7 +361,7 @@ Sockbuf_IO ldap_pvt_sockbuf_io_sasl = { int ldap_pvt_sasl_install( Sockbuf *sb, void *ctx_arg ) { #ifdef NEW_LOGGING - LDAP_LOG (( "cyrus", LDAP_LEVEL_ENTRY, "ldap_pvt_sasl_install\n" )); + LDAP_LOG ( TRANSPORT, ENTRY, "ldap_pvt_sasl_install\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_pvt_sasl_install\n", 0, 0, 0 ); @@ -457,8 +457,8 @@ ldap_int_sasl_open( } #ifdef NEW_LOGGING - LDAP_LOG (( "cyrus", LDAP_LEVEL_DETAIL1, - "ldap_int_sasl_open: host=%s\n", host )); + LDAP_LOG ( TRANSPORT, DETAIL1, "ldap_int_sasl_open: host=%s\n", + host, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_int_sasl_open: host=%s\n", host, 0, 0 ); @@ -479,8 +479,8 @@ ldap_int_sasl_open( (void *) &extprops ); #endif #ifdef NEW_LOGGING - LDAP_LOG (( "cyrus", LDAP_LEVEL_DETAIL1, - "ldap_int_sasl_open: ssf=%ld\n", (long) ssf )); + LDAP_LOG ( TRANSPORT, DETAIL1, + "ldap_int_sasl_open: ssf=%ld\n", (long) ssf, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_int_sasl_open: ssf=%ld\n", (long) ssf, 0, 0 ); @@ -525,8 +525,8 @@ ldap_int_sasl_bind( ber_socket_t sd; #ifdef NEW_LOGGING - LDAP_LOG (( "cyrus", LDAP_LEVEL_ARGS, - "ldap_int_sasl_bind: %s\n", mechs ? mechs : "" )); + LDAP_LOG ( TRANSPORT, ARGS, "ldap_int_sasl_bind: %s\n", + mechs ? mechs : "", 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_int_sasl_bind: %s\n", mechs ? mechs : "", 0, 0 ); @@ -637,9 +637,9 @@ ldap_int_sasl_bind( if( scred && scred->bv_len ) { /* and server provided us with data? */ #ifdef NEW_LOGGING - LDAP_LOG (( "cyrus", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( TRANSPORT, DETAIL1, "ldap_int_sasl_bind: rc=%d sasl=%d len=%ld\n", - rc, saslrc, scred->bv_len )); + rc, saslrc, scred->bv_len ); #else Debug( LDAP_DEBUG_TRACE, "ldap_int_sasl_bind: rc=%d sasl=%d len=%ld\n", @@ -655,9 +655,9 @@ ldap_int_sasl_bind( if( scred && scred->bv_len ) { /* but server provided us with data! */ #ifdef NEW_LOGGING - LDAP_LOG (( "cyrus", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( TRANSPORT, DETAIL1, "ldap_int_sasl_bind: rc=%d sasl=%d len=%ld\n", - rc, saslrc, scred->bv_len )); + rc, saslrc, scred->bv_len ); #else Debug( LDAP_DEBUG_TRACE, "ldap_int_sasl_bind: rc=%d sasl=%d len=%ld\n", @@ -678,8 +678,8 @@ ldap_int_sasl_bind( &credlen ); #ifdef NEW_LOGGING - LDAP_LOG (( "cyrus", LDAP_LEVEL_DETAIL1, - "ldap_int_sasl_bind: sasl_client_step: %d\n", saslrc )); + LDAP_LOG ( TRANSPORT, DETAIL1, + "ldap_int_sasl_bind: sasl_client_step: %d\n", saslrc,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "sasl_client_step: %d\n", saslrc, 0, 0 ); diff --git a/libraries/libldap/delete.c b/libraries/libldap/delete.c index c91e02e565..e930fc579b 100644 --- a/libraries/libldap/delete.c +++ b/libraries/libldap/delete.c @@ -49,7 +49,7 @@ ldap_delete_ext( BerElement *ber; #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_ENTRY, "ldap_delete_ext\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_delete_ext\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_delete_ext\n", 0, 0, 0 ); #endif @@ -139,7 +139,7 @@ ldap_delete( LDAP *ld, LDAP_CONST char *dn ) */ #ifdef NEW_LOGGING - LDAP_LOG (( "delete", LDAP_LEVEL_ENTRY, "ldap_delete\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_delete\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/dntest.c b/libraries/libldap/dntest.c index 72d3c52feb..97cc727880 100644 --- a/libraries/libldap/dntest.c +++ b/libraries/libldap/dntest.c @@ -12,12 +12,12 @@ */ #include "portable.h" +#include + #include #include #include -#include - #include #include "ldap-int.h" diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index 3569887747..45f9eec86e 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -30,13 +30,13 @@ static struct ldaperror ldap_builtin_errlist[] = { {LDAP_COMPARE_FALSE, "Compare False" }, {LDAP_COMPARE_TRUE, "Compare True" }, {LDAP_STRONG_AUTH_NOT_SUPPORTED, "Authentication method not supported" }, - {LDAP_STRONG_AUTH_REQUIRED, "Strong authentication required" }, + {LDAP_STRONG_AUTH_REQUIRED, "Strong(er) authentication required" }, {LDAP_PARTIAL_RESULTS, "Partial results and referral received" }, {LDAP_REFERRAL, "Referral"}, {LDAP_ADMINLIMIT_EXCEEDED, "Administrative limit exceeded"}, {LDAP_UNAVAILABLE_CRITICAL_EXTENSION, - "Criticial extension is unavailable"}, + "Critical extension is unavailable"}, {LDAP_CONFIDENTIALITY_REQUIRED, "Confidentiality required"}, {LDAP_SASL_BIND_IN_PROGRESS, "SASL bind in progress"}, @@ -56,21 +56,21 @@ static struct ldaperror ldap_builtin_errlist[] = { {LDAP_INAPPROPRIATE_AUTH, "Inappropriate authentication" }, {LDAP_INVALID_CREDENTIALS, "Invalid credentials" }, {LDAP_INSUFFICIENT_ACCESS, "Insufficient access" }, - {LDAP_BUSY, "DSA is busy" }, - {LDAP_UNAVAILABLE, "DSA is unavailable" }, - {LDAP_UNWILLING_TO_PERFORM, "DSA is unwilling to perform" }, + {LDAP_BUSY, "Server is busy" }, + {LDAP_UNAVAILABLE, "Server is unavailable" }, + {LDAP_UNWILLING_TO_PERFORM, "Server is unwilling to perform" }, {LDAP_LOOP_DETECT, "Loop detected" }, {LDAP_NAMING_VIOLATION, "Naming violation" }, {LDAP_OBJECT_CLASS_VIOLATION, "Object class violation" }, - {LDAP_NOT_ALLOWED_ON_NONLEAF, "Operation not allowed on nonleaf" }, + {LDAP_NOT_ALLOWED_ON_NONLEAF, "Operation not allowed on non-leaf" }, {LDAP_NOT_ALLOWED_ON_RDN, "Operation not allowed on RDN" }, {LDAP_ALREADY_EXISTS, "Already exists" }, {LDAP_NO_OBJECT_CLASS_MODS, "Cannot modify object class" }, {LDAP_RESULTS_TOO_LARGE, "Results too large" }, {LDAP_AFFECTS_MULTIPLE_DSAS, "Operation affects multiple DSAs" }, - {LDAP_OTHER, "Unknown error" }, + {LDAP_OTHER, "Internal (implementation specific) error" }, /* API ResultCodes */ {LDAP_SERVER_DOWN, "Can't contact LDAP server" }, @@ -147,7 +147,7 @@ ldap_err2string( int err ) const struct ldaperror *e; #ifdef NEW_LOGGING - LDAP_LOG (( "error", LDAP_LEVEL_ENTRY, "ldap_err2string\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_err2string\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_err2string\n", 0, 0, 0 ); #endif @@ -163,7 +163,7 @@ ldap_perror( LDAP *ld, LDAP_CONST char *str ) { const struct ldaperror *e; #ifdef NEW_LOGGING - LDAP_LOG (( "error", LDAP_LEVEL_ENTRY, "ldap_perror\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_perror\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_perror\n", 0, 0, 0 ); #endif @@ -243,7 +243,7 @@ ldap_parse_result( BerElement *ber; #ifdef NEW_LOGGING - LDAP_LOG (( "error", LDAP_LEVEL_ENTRY, "ldap_parse_result\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_parse_result\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_parse_result\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/extended.c b/libraries/libldap/extended.c index b0a7ed691a..3789720d88 100644 --- a/libraries/libldap/extended.c +++ b/libraries/libldap/extended.c @@ -30,6 +30,7 @@ #include #include "ldap-int.h" +#include "ldap_log.h" int ldap_extended_operation( @@ -44,7 +45,7 @@ ldap_extended_operation( int rc; #ifdef NEW_LOGGING - LDAP_LOG (( "extended", LDAP_LEVEL_ENTRY, "ldap_extended_operation\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_extended_operation\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_extended_operation\n", 0, 0, 0 ); #endif @@ -117,7 +118,7 @@ ldap_extended_operation_s( LDAPMessage *res; #ifdef NEW_LOGGING - LDAP_LOG (( "extended", LDAP_LEVEL_ENTRY, "ldap_extended_operation_s\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_extended_operation_s\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_extended_operation_s\n", 0, 0, 0 ); #endif @@ -173,7 +174,7 @@ ldap_parse_extended_result ( assert( res != NULL ); #ifdef NEW_LOGGING - LDAP_LOG (( "extended", LDAP_LEVEL_ENTRY, "ldap_parse_extended_result\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_parse_extended_result\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_parse_extended_result\n", 0, 0, 0 ); #endif @@ -300,8 +301,7 @@ ldap_parse_extended_partial ( assert( res != NULL ); #ifdef NEW_LOGGING - LDAP_LOG (( "extended", LDAP_LEVEL_ENTRY, - "ldap_parse_extended_partial\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_parse_extended_partial\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_parse_extended_partial\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/filter.c b/libraries/libldap/filter.c index 93a45cd75a..259c9a4590 100644 --- a/libraries/libldap/filter.c +++ b/libraries/libldap/filter.c @@ -357,8 +357,7 @@ ldap_pvt_put_filter( BerElement *ber, const char *str_in ) */ #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_ARGS, "ldap_pvt_put_filter: \"%s\"\n", - str_in )); + LDAP_LOG ( FILTER, ARGS, "ldap_pvt_put_filter: \"%s\"\n", str_in,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "put_filter: \"%s\"\n", str_in, 0, 0 ); #endif @@ -380,8 +379,7 @@ ldap_pvt_put_filter( BerElement *ber, const char *str_in ) switch ( *str ) { case '&': #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_DETAIL1, - "ldap_pvt_put_filter: AND\n" )); + LDAP_LOG ( FILTER, DETAIL1, "ldap_pvt_put_filter: AND\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "put_filter: AND\n", 0, 0, 0 ); @@ -399,8 +397,7 @@ ldap_pvt_put_filter( BerElement *ber, const char *str_in ) case '|': #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_DETAIL1, - "ldap_pvt_put_filter: OR\n" )); + LDAP_LOG ( FILTER, DETAIL1, "ldap_pvt_put_filter: OR\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "put_filter: OR\n", 0, 0, 0 ); @@ -418,8 +415,7 @@ ldap_pvt_put_filter( BerElement *ber, const char *str_in ) case '!': #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_DETAIL1, - "ldap_pvt_put_filter: NOT\n" )); + LDAP_LOG ( FILTER, DETAIL1, "ldap_pvt_put_filter: NOT\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "put_filter: NOT\n", 0, 0, 0 ); @@ -437,8 +433,7 @@ ldap_pvt_put_filter( BerElement *ber, const char *str_in ) default: #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_DETAIL1, - "ldap_pvt_put_filter: simple\n" )); + LDAP_LOG ( FILTER, DETAIL1, "ldap_pvt_put_filter: simple\n", 0,0,0); #else Debug( LDAP_DEBUG_TRACE, "put_filter: simple\n", 0, 0, 0 ); @@ -488,8 +483,7 @@ ldap_pvt_put_filter( BerElement *ber, const char *str_in ) case /*'('*/ ')': #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_DETAIL1, - "ldap_pvt_put_filter: end\n" )); + LDAP_LOG ( FILTER, DETAIL1, "ldap_pvt_put_filter: end\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "put_filter: end\n", 0, 0, 0 ); @@ -508,8 +502,7 @@ ldap_pvt_put_filter( BerElement *ber, const char *str_in ) default: /* assume it's a simple type=value filter */ #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_DETAIL1, - "ldap_pvt_put_filter: default\n" )); + LDAP_LOG ( FILTER, DETAIL1, "ldap_pvt_put_filter: default\n", 0,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "put_filter: default\n", 0, 0, 0 ); @@ -542,8 +535,7 @@ put_filter_list( BerElement *ber, char *str, ber_tag_t tag ) char save; #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_ARGS, - "put_filter_list \"%s\"\n", str )); + LDAP_LOG ( FILTER, ARGS, "put_filter_list \"%s\"\n", str,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "put_filter_list \"%s\"\n", str, 0, 0 ); @@ -587,8 +579,7 @@ put_simple_filter( int rc = -1; #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_ARGS, - "put_simple_filter: \"%s\"\n", str )); + LDAP_LOG ( FILTER, ARGS, "put_simple_filter: \"%s\"\n", str,0,0 ); #else Debug( LDAP_DEBUG_TRACE, "put_simple_filter: \"%s\"\n", str, 0, 0 ); @@ -759,8 +750,7 @@ put_substring_filter( BerElement *ber, char *type, char *val ) ber_tag_t ftype = LDAP_FILTER_SUBSTRINGS; #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_ARGS, - "put_substring_filter \"%s=%s\"\n", type, val )); + LDAP_LOG ( FILTER, ARGS, "put_substring_filter \"%s=%s\"\n", type, val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "put_substring_filter \"%s=%s\"\n", type, val, 0 ); @@ -847,8 +837,8 @@ put_vrFilter( BerElement *ber, const char *str_in ) */ #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_ARGS, "put_vrFilter: \"%s\"\n", - str_in )); + LDAP_LOG ( FILTER, ARGS, "ldap_pvt_put_vrFilter: \"%s\"\n", + str_in, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "put_vrFilter: \"%s\"\n", str_in, 0, 0 ); #endif @@ -892,8 +882,8 @@ put_vrFilter( BerElement *ber, const char *str_in ) default: #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_DETAIL1, - "put_vrFilter: simple\n" )); + LDAP_LOG ( FILTER, DETAIL1, + "put_vrFilter: simple\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "put_vrFilter: simple\n", 0, 0, 0 ); @@ -943,8 +933,7 @@ put_vrFilter( BerElement *ber, const char *str_in ) case /*'('*/ ')': #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_DETAIL1, - "ldap_pvt_put_filter: end\n" )); + LDAP_LOG ( FILTER, DETAIL1, "ldap_pvt_put_filter: end\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "put_filter: end\n", 0, 0, 0 ); @@ -963,8 +952,8 @@ put_vrFilter( BerElement *ber, const char *str_in ) default: /* assume it's a simple type=value filter */ #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_DETAIL1, - "ldap_pvt_put_filter: default\n" )); + LDAP_LOG ( FILTER, DETAIL1, "ldap_pvt_put_filter: default\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "put_filter: default\n", 0, 0, 0 ); @@ -1011,8 +1000,7 @@ put_vrFilter_list( BerElement *ber, char *str ) char save; #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_ARGS, - "put_vrFilter_list \"%s\"\n", str )); + LDAP_LOG ( FILTER, ARGS, "put_vrFilter_list \"%s\"\n", str, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "put_vrFilter_list \"%s\"\n", str, 0, 0 ); @@ -1050,8 +1038,7 @@ put_simple_vrFilter( int rc = -1; #ifdef NEW_LOGGING - LDAP_LOG (( "filter", LDAP_LEVEL_ARGS, - "put_simple_vrFilter: \"%s\"\n", str )); + LDAP_LOG ( FILTER, ARGS, "put_simple_vrFilter: \"%s\"\n", str, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "put_simple_vrFilter: \"%s\"\n", str, 0, 0 ); diff --git a/libraries/libldap/getattr.c b/libraries/libldap/getattr.c index e5cd6e628d..91e37b2835 100644 --- a/libraries/libldap/getattr.c +++ b/libraries/libldap/getattr.c @@ -31,7 +31,7 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **berout ) BerElement *ber; #ifdef NEW_LOGGING - LDAP_LOG (( "getattr", LDAP_LEVEL_ENTRY, "ldap_first_attribute\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_first_attribute\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 ); #endif @@ -97,7 +97,7 @@ ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber ) char *attr; #ifdef NEW_LOGGING - LDAP_LOG (( "getattr", LDAP_LEVEL_ENTRY, "ldap_next_attribute\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_next_attribute\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c index 43c1b4470b..781dca07af 100644 --- a/libraries/libldap/getdn.c +++ b/libraries/libldap/getdn.c @@ -85,7 +85,7 @@ ldap_get_dn( LDAP *ld, LDAPMessage *entry ) BerElement tmp; #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_ENTRY, "ldap_get_dn\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_get_dn\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_get_dn\n", 0, 0, 0 ); #endif @@ -112,7 +112,7 @@ ldap_dn2ufn( LDAP_CONST char *dn ) char *out = NULL; #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_ENTRY, "ldap_dn2ufn\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_dn2ufn\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_dn2ufn\n", 0, 0, 0 ); #endif @@ -135,7 +135,7 @@ ldap_explode_dn( LDAP_CONST char *dn, int notypes ) unsigned flag = notypes ? LDAP_DN_FORMAT_UFN : LDAP_DN_FORMAT_LDAPV3; #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_ENTRY, "ldap_explode_dn\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_explode_dn\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_explode_dn\n", 0, 0, 0 ); #endif @@ -179,7 +179,7 @@ ldap_explode_rdn( LDAP_CONST char *rdn, int notypes ) int iAVA; #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_ENTRY, "ldap_explode_rdn\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_explode_rdn\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_explode_rdn\n", 0, 0, 0 ); #endif @@ -264,7 +264,7 @@ ldap_dn2dcedn( LDAP_CONST char *dn ) char *out = NULL; #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_ENTRY, "ldap_dn2dcedn\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_dn2dcedn\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_dn2dcedn\n", 0, 0, 0 ); #endif @@ -281,7 +281,7 @@ ldap_dcedn2dn( LDAP_CONST char *dce ) char *out = NULL; #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_ENTRY, "ldap_dcedn2dn\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_dcedn2dn\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_dcedn2dn\n", 0, 0, 0 ); #endif @@ -297,7 +297,7 @@ ldap_dn2ad_canonical( LDAP_CONST char *dn ) char *out = NULL; #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_ENTRY, "ldap_dn2ad_canonical\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_dn2ad_canonical\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_dn2ad_canonical\n", 0, 0, 0 ); #endif @@ -333,7 +333,7 @@ ldap_dn_normalize( LDAP_CONST char *dnin, LDAPDN *tmpDN = NULL; #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_ENTRY, "ldap_dn_normalize\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_dn_normalize\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_dn_normalize\n", 0, 0, 0 ); #endif @@ -660,9 +660,8 @@ ldap_bv2dn( struct berval *bv, LDAPDN **dn, unsigned flags ) assert( dn ); #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_ARGS, "ldap_bv2dn(%s,%u)\n%s", - str, flags, "" )); -#elif 0 + LDAP_LOG ( OPERATION, ARGS, "ldap_bv2dn(%s,%u)\n%s", str, flags, "" ); +#else Debug( LDAP_DEBUG_TRACE, "=> ldap_bv2dn(%s,%u)\n%s", str, flags, "" ); #endif @@ -837,9 +836,9 @@ return_result:; } #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_RESULTS, "<= ldap_bv2dn(%s,%u)=%d\n", - str, flags, rc )); -#elif 0 + LDAP_LOG ( OPERATION, RESULTS, "<= ldap_bv2dn(%s,%u)=%d\n", + str, flags, rc ); +#else Debug( LDAP_DEBUG_TRACE, "<= ldap_bv2dn(%s,%u)=%d\n", str, flags, rc ); #endif *dn = newDN; @@ -2967,9 +2966,9 @@ int ldap_dn2bv( LDAPDN *dn, struct berval *bv, unsigned flags ) bv->bv_val = NULL; #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_ARGS, "=> ldap_dn2bv(%u)\n%s%s", - flags, "", "" )); -#elif 0 + LDAP_LOG ( OPERATION, ARGS, "=> ldap_dn2bv(%u)\n%s%s", + flags, "", "" ); +#else Debug( LDAP_DEBUG_TRACE, "=> ldap_dn2bv(%u)\n%s%s", flags, "", "" ); #endif @@ -3279,9 +3278,9 @@ int ldap_dn2bv( LDAPDN *dn, struct berval *bv, unsigned flags ) } #ifdef NEW_LOGGING - LDAP_LOG (( "getdn", LDAP_LEVEL_RESULTS, "<= ldap_dn2bv(%s,%u)=%d\n", - bv->bv_val, flags, rc )); -#elif 0 + LDAP_LOG ( OPERATION, RESULTS, "<= ldap_dn2bv(%s,%u)=%d\n", + bv->bv_val, flags, rc ); +#else Debug( LDAP_DEBUG_TRACE, "<= ldap_dn2bv(%s,%u)=%d\n", bv->bv_val, flags, rc ); #endif diff --git a/libraries/libldap/getfilter.c b/libraries/libldap/getfilter.c index d6f62f3255..d4d0d4452a 100644 --- a/libraries/libldap/getfilter.c +++ b/libraries/libldap/getfilter.c @@ -79,9 +79,9 @@ ldap_init_getfilter_buf( char *buf, ber_len_t buflen ) regerror(rc, &re, error, sizeof(error)); ldap_getfilter_free( lfdp ); #ifdef NEW_LOGGING - LDAP_LOG (( "getfilter", LDAP_LEVEL_ERR, - "ldap_init_get_filter_buf: bad regular expression %s, %s\n", - nextflp->lfl_pattern, error )); + LDAP_LOG ( FILTER, ERR, + "ldap_init_get_filter_buf: bad regular expression %s, %s\n", + nextflp->lfl_pattern, error, 0 ); #else Debug( LDAP_DEBUG_ANY, "ldap_init_get_filter_buf: " "bad regular expression %s, %s\n", diff --git a/libraries/libldap/getvalues.c b/libraries/libldap/getvalues.c index bbf16d8c41..34ee28da56 100644 --- a/libraries/libldap/getvalues.c +++ b/libraries/libldap/getvalues.c @@ -37,7 +37,7 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) assert( target != NULL ); #ifdef NEW_LOGGING - LDAP_LOG (( "getvalues", LDAP_LEVEL_ENTRY, "ldap_get_values\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_get_values\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 ); #endif @@ -98,7 +98,7 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) assert( target != NULL ); #ifdef NEW_LOGGING - LDAP_LOG (( "getvalues", LDAP_LEVEL_ENTRY, "ldap_get_values_len\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_get_values_len\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c index c6b6875982..96e7b8f3dc 100644 --- a/libraries/libldap/init.c +++ b/libraries/libldap/init.c @@ -116,8 +116,8 @@ static void openldap_ldap_init_w_conf( } #ifdef NEW_LOGGING - LDAP_LOG (( "init", LDAP_LEVEL_DETAIL1, - "openldap_init_w_conf: trying %s\n", file )); + LDAP_LOG ( CONFIG, DETAIL1, + "openldap_init_w_conf: trying %s\n", file, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "ldap_init: trying %s\n", file, 0, 0); #endif @@ -129,8 +129,7 @@ static void openldap_ldap_init_w_conf( } #ifdef NEW_LOGGING - LDAP_LOG (( "init", LDAP_LEVEL_DETAIL1, - "openldap_init_w_conf: using %s\n", file )); + LDAP_LOG ( CONFIG, DETAIL1, "openldap_init_w_conf: using %s\n", file, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "ldap_init: using %s\n", file, 0, 0); #endif @@ -262,17 +261,17 @@ static void openldap_ldap_init_w_userconf(const char *file) if (home != NULL) { #ifdef NEW_LOGGING - LDAP_LOG (( "init", LDAP_LEVEL_ARGS, - "openldap_init_w_userconf: HOME env is %s\n", home )); + LDAP_LOG ( CONFIG, ARGS, + "openldap_init_w_userconf: HOME env is %s\n", home, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "ldap_init: HOME env is %s\n", home, 0, 0); #endif - path = LDAP_MALLOC(strlen(home) + strlen(file) + 3); + path = LDAP_MALLOC(strlen(home) + strlen(file) + sizeof( LDAP_DIRSEP ".")); } else { #ifdef NEW_LOGGING - LDAP_LOG (( "init", LDAP_LEVEL_ARGS, - "openldap_init_w_userconf: HOME env is NULL\n" )); + LDAP_LOG ( CONFIG, ARGS, "openldap_init_w_userconf: HOME env is NULL\n", + 0, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "ldap_init: HOME env is NULL\n", 0, 0, 0); @@ -283,11 +282,11 @@ static void openldap_ldap_init_w_userconf(const char *file) /* we assume UNIX path syntax is used... */ /* try ~/file */ - sprintf(path, "%s%s%s", home, LDAP_DIRSEP, file); + sprintf(path, "%s" LDAP_DIRSEP "%s", home, file); openldap_ldap_init_w_conf(path, 1); /* try ~/.file */ - sprintf(path, "%s%s.%s", home, LDAP_DIRSEP, file); + sprintf(path, "%s" LDAP_DIRSEP ".%s", home, file); openldap_ldap_init_w_conf(path, 1); } @@ -555,9 +554,9 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl ) if( altfile != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "init", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( CONFIG, DETAIL1, "openldap_init_w_userconf: %sCONF env is %s\n", - LDAP_ENV_PREFIX, altfile )); + LDAP_ENV_PREFIX, altfile, 0 ); #else Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is %s\n", LDAP_ENV_PREFIX "CONF", altfile, 0); @@ -566,9 +565,9 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl ) } else #ifdef NEW_LOGGING - LDAP_LOG (( "init", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( CONFIG, DETAIL1, "openldap_init_w_userconf: %sCONF env is NULL\n", - LDAP_ENV_PREFIX )); + LDAP_ENV_PREFIX, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is NULL\n", LDAP_ENV_PREFIX "CONF", 0, 0); @@ -580,9 +579,9 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl ) if( altfile != NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "init", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( CONFIG, DETAIL1, "openldap_init_w_userconf: %sRC env is %s\n", - LDAP_ENV_PREFIX, altfile )); + LDAP_ENV_PREFIX, altfile, 0 ); #else Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is %s\n", LDAP_ENV_PREFIX "RC", altfile, 0); @@ -591,9 +590,9 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl ) } else #ifdef NEW_LOGGING - LDAP_LOG (( "init", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( CONFIG, DETAIL1, "openldap_init_w_userconf: %sRC env is NULL\n", - LDAP_ENV_PREFIX )); + LDAP_ENV_PREFIX, 0, 0 ); #else Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is NULL\n", LDAP_ENV_PREFIX "RC", 0, 0); diff --git a/libraries/libldap/kbind.c b/libraries/libldap/kbind.c index 372eb9fa00..eadf2ac72d 100644 --- a/libraries/libldap/kbind.c +++ b/libraries/libldap/kbind.c @@ -45,7 +45,6 @@ #include "ldap-int.h" - /* * ldap_kerberos_bind1 - initiate a bind to the ldap server using * kerberos authentication. The dn is supplied. It is assumed the user @@ -65,7 +64,7 @@ ldap_kerberos_bind1( LDAP *ld, LDAP_CONST char *dn ) ber_len_t credlen; #ifdef NEW_LOGGING - LDAP_LOG (( "kbind", LDAP_LEVEL_ENTRY, "ldap_kerberos_bind1\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_kerberos_bind1\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_kerberos_bind1\n", 0, 0, 0 ); #endif @@ -119,7 +118,7 @@ ldap_kerberos_bind1_s( LDAP *ld, LDAP_CONST char *dn ) LDAPMessage *res; #ifdef NEW_LOGGING - LDAP_LOG (( "kbind", LDAP_LEVEL_ENTRY, "ldap_kerberos_bind1_s\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_kerberos_bind1_s\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_kerberos_bind1_s\n", 0, 0, 0 ); #endif @@ -156,7 +155,7 @@ ldap_kerberos_bind2( LDAP *ld, LDAP_CONST char *dn ) ber_len_t credlen; #ifdef NEW_LOGGING - LDAP_LOG (( "kbind", LDAP_LEVEL_ENTRY, "ldap_kerberos_bind2\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_kerberos_bind2\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_kerberos_bind2\n", 0, 0, 0 ); #endif @@ -205,7 +204,7 @@ ldap_kerberos_bind2_s( LDAP *ld, LDAP_CONST char *dn ) LDAPMessage *res; #ifdef NEW_LOGGING - LDAP_LOG (( "kbind", LDAP_LEVEL_ENTRY, "ldap_kerberos_bind2_s\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_kerberos_bind2_s\n" , 0, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "ldap_kerberos_bind2_s\n", 0, 0, 0 ); #endif @@ -230,7 +229,7 @@ ldap_kerberos_bind_s( LDAP *ld, LDAP_CONST char *dn ) int err; #ifdef NEW_LOGGING - LDAP_LOG (( "kbind", LDAP_LEVEL_ENTRY, "ldap_kerberos_bind_s\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_kerberos_bind_s\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_kerberos_bind_s\n", 0, 0, 0 ); #endif @@ -261,17 +260,16 @@ ldap_get_kerberosv4_credentials( char realm[REALM_SZ], *cred, *krbinstance; #ifdef NEW_LOGGING - LDAP_LOG (( "kbind", LDAP_LEVEL_ENTRY, - "ldap_get_kerberosv4_credentials\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_get_kerberosv4_credentials\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_get_kerberosv4_credentials\n", 0, 0, 0 ); #endif if ( (err = krb_get_tf_realm( tkt_string(), realm )) != KSUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "kbind", LDAP_LEVEL_ERR, + LDAP_LOG ( OPERATION, ERR, "ldap_get_kerberosv4_credentials: krb_get_tf_realm failed: %s\n", - krb_err_txt[err] )); + krb_err_txt[err], 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ldap_get_kerberosv4_credentials: " "krb_get_tf_realm failed: %s\n", krb_err_txt[err], 0, 0 ); @@ -293,9 +291,9 @@ ldap_get_kerberosv4_credentials( != KSUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "kbind", LDAP_LEVEL_ERR, + LDAP_LOG ( OPERATION, ERR, "ldap_get_kerberosv4_credentials: krb_mk_req failed: %s\n", - krb_err_txt[err] )); + krb_err_txt[err], 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "ldap_get_kerberosv4_credentials: " "krb_mk_req failed (%s)\n", krb_err_txt[err], 0, 0 ); diff --git a/libraries/libldap/modify.c b/libraries/libldap/modify.c index cf9f6ed573..f346064370 100644 --- a/libraries/libldap/modify.c +++ b/libraries/libldap/modify.c @@ -72,7 +72,7 @@ ldap_modify_ext( LDAP *ld, */ #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ENTRY, "ldap_modify_ext\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_modify_ext\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_modify_ext\n", 0, 0, 0 ); #endif @@ -160,7 +160,7 @@ ldap_modify( LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods ) int rc, msgid; #ifdef NEW_LOGGING - LDAP_LOG (( "modify", LDAP_LEVEL_ENTRY, "ldap_modify\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_modify\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_modify\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/modrdn.c b/libraries/libldap/modrdn.c index 5603d6dbea..6907a22998 100644 --- a/libraries/libldap/modrdn.c +++ b/libraries/libldap/modrdn.c @@ -69,7 +69,7 @@ ldap_rename( int rc; #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ENTRY, "ldap_rename\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_rename\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_rename\n", 0, 0, 0 ); #endif @@ -156,7 +156,7 @@ ldap_rename2( int rc; #ifdef NEW_LOGGING - LDAP_LOG (( "modrdn", LDAP_LEVEL_ENTRY, "ldap_rename2\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_rename2\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_rename2\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index 11a9b41331..8030790a94 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -23,6 +23,7 @@ #include #include "ldap-int.h" +#include "ldap_log.h" int ldap_open_defconn( LDAP *ld ) { @@ -55,8 +56,7 @@ ldap_open( LDAP_CONST char *host, int port ) LDAP *ld; #ifdef NEW_LOGGING - LDAP_LOG (( "open", LDAP_LEVEL_ARGS, "ldap_open(%s, %d)\n", - host, port )); + LDAP_LOG ( CONNECTION, ARGS, "ldap_open(%s, %d)\n", host, port, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_open(%s, %d)\n", host, port, 0 ); @@ -75,8 +75,8 @@ ldap_open( LDAP_CONST char *host, int port ) } #ifdef NEW_LOGGING - LDAP_LOG (( "open", LDAP_LEVEL_RESULTS, "ldap_open: %s\n", - ld == NULL ? "succeeded" : "failed" )); + LDAP_LOG ( CONNECTION, RESULTS, "ldap_open: %s\n", + ld == NULL ? "succeeded" : "failed", 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_open: %s\n", ld == NULL ? "succeeded" : "failed", 0, 0 ); @@ -107,7 +107,7 @@ ldap_create( LDAP **ldp ) } #ifdef NEW_LOGGING - LDAP_LOG (( "open", LDAP_LEVEL_ENTRY, "ldap_create\n" )); + LDAP_LOG ( CONNECTION, ENTRY, "ldap_create\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_create\n", 0, 0, 0 ); #endif @@ -240,7 +240,7 @@ ldap_int_open_connection( long addr; #ifdef NEW_LOGGING - LDAP_LOG (( "open", LDAP_LEVEL_ENTRY, "ldap_int_open_connection\n" )); + LDAP_LOG ( CONNECTION, ENTRY, "ldap_int_open_connection\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_int_open_connection\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c new file mode 100644 index 0000000000..45ceae125f --- /dev/null +++ b/libraries/libldap/options.c @@ -0,0 +1,608 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include + +#include + +#include +#include +#include + +#include "ldap-int.h" + +#define LDAP_OPT_REBIND_PROC 0x4e814d +#define LDAP_OPT_REBIND_PARAMS 0x4e814e + +static const LDAPAPIFeatureInfo features[] = { +#ifdef LDAP_API_FEATURE_X_OPENLDAP + { /* OpenLDAP Extensions API Feature */ + LDAP_FEATURE_INFO_VERSION, + "X_OPENLDAP", + LDAP_API_FEATURE_X_OPENLDAP + }, +#endif + +#ifdef LDAP_API_FEATURE_THREAD_SAFE + { /* Basic Thread Safe */ + LDAP_FEATURE_INFO_VERSION, + "THREAD_SAFE", + LDAP_API_FEATURE_THREAD_SAFE + }, +#endif +#ifdef LDAP_API_FEATURE_SESSION_THREAD_SAFE + { /* Session Thread Safe */ + LDAP_FEATURE_INFO_VERSION, + "SESSION_THREAD_SAFE", + LDAP_API_FEATURE_SESSION_THREAD_SAFE + }, +#endif +#ifdef LDAP_API_FEATURE_OPERATION_THREAD_SAFE + { /* Operation Thread Safe */ + LDAP_FEATURE_INFO_VERSION, + "OPERATION_THREAD_SAFE", + LDAP_API_FEATURE_OPERATION_THREAD_SAFE + }, +#endif +#ifdef LDAP_API_FEATURE_X_OPENLDAP_REENTRANT + { /* OpenLDAP Reentrant */ + LDAP_FEATURE_INFO_VERSION, + "X_OPENLDAP_REENTRANT", + LDAP_API_FEATURE_X_OPENLDAP_REENTRANT + }, +#endif +#if defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) && \ + defined( LDAP_THREAD_SAFE ) + { /* OpenLDAP Thread Safe */ + LDAP_FEATURE_INFO_VERSION, + "X_OPENLDAP_THREAD_SAFE", + LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE + }, +#endif +#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS + { /* V2 Referrals */ + LDAP_FEATURE_INFO_VERSION, + "X_OPENLDAP_V2_REFERRALS", + LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS + }, +#endif + {0, NULL, 0} +}; + +int +ldap_get_option( + LDAP *ld, + int option, + void *outvalue) +{ + struct ldapoptions *lo; + + /* Get pointer to global option structure */ + lo = LDAP_INT_GLOBAL_OPT(); + if (NULL == lo) { + return LDAP_NO_MEMORY; + } + + if( lo->ldo_valid != LDAP_INITIALIZED ) { + ldap_int_initialize(lo, NULL); + } + + if(ld != NULL) { + assert( LDAP_VALID( ld ) ); + + if( !LDAP_VALID( ld ) ) { + return LDAP_OPT_ERROR; + } + + lo = &ld->ld_options; + } + + if(outvalue == NULL) { + /* no place to get to */ + return LDAP_OPT_ERROR; + } + + switch(option) { + case LDAP_OPT_API_INFO: { + struct ldapapiinfo *info = (struct ldapapiinfo *) outvalue; + + if(info == NULL) { + /* outvalue must point to an apiinfo structure */ + return LDAP_OPT_ERROR; + } + + if(info->ldapai_info_version != LDAP_API_INFO_VERSION) { + /* api info version mismatch */ + info->ldapai_info_version = LDAP_API_INFO_VERSION; + return LDAP_OPT_ERROR; + } + + info->ldapai_api_version = LDAP_API_VERSION; + info->ldapai_api_version = LDAP_API_VERSION; + info->ldapai_protocol_version = LDAP_VERSION_MAX; + + if(features[0].ldapaif_name == NULL) { + info->ldapai_extensions = NULL; + } else { + int i; + info->ldapai_extensions = LDAP_MALLOC(sizeof(char *) * + sizeof(features)/sizeof(LDAPAPIFeatureInfo)); + + for(i=0; features[i].ldapaif_name != NULL; i++) { + info->ldapai_extensions[i] = + LDAP_STRDUP(features[i].ldapaif_name); + } + + info->ldapai_extensions[i] = NULL; + } + + info->ldapai_vendor_name = LDAP_STRDUP(LDAP_VENDOR_NAME); + info->ldapai_vendor_version = LDAP_VENDOR_VERSION; + + return LDAP_OPT_SUCCESS; + } break; + + case LDAP_OPT_DESC: + if( ld == NULL || ld->ld_sb == NULL ) { + /* bad param */ + break; + } + + ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, outvalue ); + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_TIMEOUT: + /* the caller has to free outvalue ! */ + if ( ldap_int_timeval_dup( outvalue, lo->ldo_tm_api) != 0 ) { + return LDAP_OPT_ERROR; + } + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_NETWORK_TIMEOUT: + /* the caller has to free outvalue ! */ + if ( ldap_int_timeval_dup( outvalue, lo->ldo_tm_net ) != 0 ) { + return LDAP_OPT_ERROR; + } + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_DEREF: + * (int *) outvalue = lo->ldo_deref; + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_SIZELIMIT: + * (int *) outvalue = lo->ldo_sizelimit; + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_TIMELIMIT: + * (int *) outvalue = lo->ldo_timelimit; + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_REFERRALS: + * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_REFERRALS); + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_RESTART: + * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_RESTART); + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_PROTOCOL_VERSION: + * (int *) outvalue = lo->ldo_version; + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_SERVER_CONTROLS: + * (LDAPControl ***) outvalue = + ldap_controls_dup( lo->ldo_sctrls ); + + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_CLIENT_CONTROLS: + * (LDAPControl ***) outvalue = + ldap_controls_dup( lo->ldo_cctrls ); + + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_HOST_NAME: + * (char **) outvalue = ldap_url_list2hosts(lo->ldo_defludp); + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_URI: + * (char **) outvalue = ldap_url_list2urls(lo->ldo_defludp); + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_ERROR_NUMBER: + if(ld == NULL) { + /* bad param */ + break; + } + * (int *) outvalue = ld->ld_errno; + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_ERROR_STRING: + if(ld == NULL) { + /* bad param */ + break; + } + + if( ld->ld_error == NULL ) { + * (char **) outvalue = NULL; + } else { + * (char **) outvalue = LDAP_STRDUP(ld->ld_error); + } + + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_MATCHED_DN: + if(ld == NULL) { + /* bad param */ + break; + } + + if( ld->ld_matched == NULL ) { + * (char **) outvalue = NULL; + } else { + * (char **) outvalue = LDAP_STRDUP(ld->ld_matched); + } + + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_API_FEATURE_INFO: { + LDAPAPIFeatureInfo *info = (LDAPAPIFeatureInfo *) outvalue; + int i; + + if(info == NULL) return LDAP_OPT_ERROR; + + if(info->ldapaif_info_version != LDAP_FEATURE_INFO_VERSION) { + /* api info version mismatch */ + info->ldapaif_info_version = LDAP_FEATURE_INFO_VERSION; + return LDAP_OPT_ERROR; + } + + if(info->ldapaif_name == NULL) return LDAP_OPT_ERROR; + + for(i=0; features[i].ldapaif_name != NULL; i++) { + if(!strcmp(info->ldapaif_name, features[i].ldapaif_name)) { + info->ldapaif_version = + features[i].ldapaif_version; + return LDAP_OPT_SUCCESS; + } + } + } + break; + + case LDAP_OPT_DEBUG_LEVEL: + * (int *) outvalue = lo->ldo_debug; + return LDAP_OPT_SUCCESS; + + default: +#ifdef HAVE_TLS + if ( ldap_pvt_tls_get_option( ld, option, outvalue ) == 0 ) { + return LDAP_OPT_SUCCESS; + } +#endif +#ifdef HAVE_CYRUS_SASL + if ( ldap_int_sasl_get_option( ld, option, outvalue ) == 0 ) { + return LDAP_OPT_SUCCESS; + } +#endif + /* bad param */ + break; + } + + return LDAP_OPT_ERROR; +} + +int +ldap_set_option( + LDAP *ld, + int option, + LDAP_CONST void *invalue) +{ + struct ldapoptions *lo; + int *dbglvl = NULL; + + /* Get pointer to global option structure */ + lo = LDAP_INT_GLOBAL_OPT(); + if (lo == NULL) { + return LDAP_NO_MEMORY; + } + + /* + * The architecture to turn on debugging has a chicken and egg + * problem. Thus, we introduce a fix here. + */ + + if (option == LDAP_OPT_DEBUG_LEVEL) + dbglvl = (int *) invalue; + + if( lo->ldo_valid != LDAP_INITIALIZED ) { + ldap_int_initialize(lo, dbglvl); + } + + if(ld != NULL) { + assert( LDAP_VALID( ld ) ); + + if( !LDAP_VALID( ld ) ) { + return LDAP_OPT_ERROR; + } + + lo = &ld->ld_options; + } + + switch(option) { + case LDAP_OPT_REFERRALS: + if(invalue == LDAP_OPT_OFF) { + LDAP_BOOL_CLR(lo, LDAP_BOOL_REFERRALS); + } else { + LDAP_BOOL_SET(lo, LDAP_BOOL_REFERRALS); + } + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_RESTART: + if(invalue == LDAP_OPT_OFF) { + LDAP_BOOL_CLR(lo, LDAP_BOOL_RESTART); + } else { + LDAP_BOOL_SET(lo, LDAP_BOOL_RESTART); + } + return LDAP_OPT_SUCCESS; + } + + /* options which can withstand invalue == NULL */ + switch ( option ) { + case LDAP_OPT_SERVER_CONTROLS: { + LDAPControl *const *controls = + (LDAPControl *const *) invalue; + + ldap_controls_free( lo->ldo_sctrls ); + + if( controls == NULL || *controls == NULL ) { + lo->ldo_sctrls = NULL; + return LDAP_OPT_SUCCESS; + } + + lo->ldo_sctrls = ldap_controls_dup( controls ); + + if(lo->ldo_sctrls == NULL) { + /* memory allocation error ? */ + break; + } + } return LDAP_OPT_SUCCESS; + + case LDAP_OPT_CLIENT_CONTROLS: { + LDAPControl *const *controls = + (LDAPControl *const *) invalue; + + ldap_controls_free( lo->ldo_cctrls ); + + if( controls == NULL || *controls == NULL ) { + lo->ldo_cctrls = NULL; + return LDAP_OPT_SUCCESS; + } + + lo->ldo_cctrls = ldap_controls_dup( controls ); + + if(lo->ldo_cctrls == NULL) { + /* memory allocation error ? */ + break; + } + } return LDAP_OPT_SUCCESS; + + case LDAP_OPT_TIMEOUT: { + const struct timeval *tv = + (const struct timeval *) invalue; + + if ( lo->ldo_tm_api != NULL ) { + LDAP_FREE( lo->ldo_tm_api ); + lo->ldo_tm_api = NULL; + } + + if ( ldap_int_timeval_dup( &lo->ldo_tm_api, tv ) != 0 ) { + return LDAP_OPT_ERROR; + } + } return LDAP_OPT_SUCCESS; + + case LDAP_OPT_NETWORK_TIMEOUT: { + const struct timeval *tv = + (const struct timeval *) invalue; + + if ( lo->ldo_tm_net != NULL ) { + LDAP_FREE( lo->ldo_tm_net ); + lo->ldo_tm_net = NULL; + } + + if ( ldap_int_timeval_dup( &lo->ldo_tm_net, tv ) != 0 ) { + return LDAP_OPT_ERROR; + } + } return LDAP_OPT_SUCCESS; + + /* Only accessed from inside this function by ldap_set_rebind_proc() */ + case LDAP_OPT_REBIND_PROC: { + lo->ldo_rebind_proc = (LDAP_REBIND_PROC *)invalue; + } return LDAP_OPT_SUCCESS; + case LDAP_OPT_REBIND_PARAMS: { + lo->ldo_rebind_params = (void *)invalue; + } return LDAP_OPT_SUCCESS; + } + + if(invalue == NULL) { + /* no place to set from */ + return LDAP_OPT_ERROR; + } + + /* options which cannot withstand invalue == NULL */ + + switch(option) { + case LDAP_OPT_API_INFO: + case LDAP_OPT_DESC: + /* READ ONLY */ + break; + + case LDAP_OPT_DEREF: + lo->ldo_deref = * (const int *) invalue; + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_SIZELIMIT: + lo->ldo_sizelimit = * (const int *) invalue; + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_TIMELIMIT: + lo->ldo_timelimit = * (const int *) invalue; + return LDAP_OPT_SUCCESS; + + case LDAP_OPT_PROTOCOL_VERSION: { + int vers = * (const int *) invalue; + if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) { + /* not supported */ + break; + } + lo->ldo_version = vers; + } return LDAP_OPT_SUCCESS; + + + case LDAP_OPT_HOST_NAME: { + const char *host = (const char *) invalue; + LDAPURLDesc *ludlist = NULL; + int rc = LDAP_OPT_SUCCESS; + + if(host != NULL) { + rc = ldap_url_parsehosts( &ludlist, host, + lo->ldo_defport ? lo->ldo_defport : LDAP_PORT ); + + } else if(ld == NULL) { + /* + * must want global default returned + * to initial condition. + */ + rc = ldap_url_parselist(&ludlist, "ldap://localhost/"); + + } else { + /* + * must want the session default + * updated to the current global default + */ + ludlist = ldap_url_duplist( + ldap_int_global_options.ldo_defludp); + if (ludlist == NULL) + rc = LDAP_NO_MEMORY; + } + + if (rc == LDAP_OPT_SUCCESS) { + if (lo->ldo_defludp != NULL) + ldap_free_urllist(lo->ldo_defludp); + lo->ldo_defludp = ludlist; + } + return rc; + } + + case LDAP_OPT_URI: { + const char *urls = (const char *) invalue; + LDAPURLDesc *ludlist = NULL; + int rc = LDAP_OPT_SUCCESS; + + if(urls != NULL) { + rc = ldap_url_parselist(&ludlist, urls); + + } else if(ld == NULL) { + /* + * must want global default returned + * to initial condition. + */ + rc = ldap_url_parselist(&ludlist, "ldap://localhost/"); + + } else { + /* + * must want the session default + * updated to the current global default + */ + ludlist = ldap_url_duplist( + ldap_int_global_options.ldo_defludp); + if (ludlist == NULL) + rc = LDAP_NO_MEMORY; + } + + if (rc == LDAP_OPT_SUCCESS) { + if (lo->ldo_defludp != NULL) + ldap_free_urllist(lo->ldo_defludp); + lo->ldo_defludp = ludlist; + } + return rc; + } + + case LDAP_OPT_ERROR_NUMBER: { + int err = * (const int *) invalue; + + if(ld == NULL) { + /* need a struct ldap */ + break; + } + + ld->ld_errno = err; + } return LDAP_OPT_SUCCESS; + + case LDAP_OPT_ERROR_STRING: { + const char *err = (const char *) invalue; + + if(ld == NULL) { + /* need a struct ldap */ + break; + } + + if( ld->ld_error ) { + LDAP_FREE(ld->ld_error); + } + + ld->ld_error = LDAP_STRDUP(err); + } return LDAP_OPT_SUCCESS; + + case LDAP_OPT_MATCHED_DN: { + const char *err = (const char *) invalue; + + if(ld == NULL) { + /* need a struct ldap */ + break; + } + + if( ld->ld_matched ) { + LDAP_FREE(ld->ld_matched); + } + + ld->ld_matched = LDAP_STRDUP(err); + } return LDAP_OPT_SUCCESS; + + case LDAP_OPT_API_FEATURE_INFO: + /* read-only */ + break; + + case LDAP_OPT_DEBUG_LEVEL: + lo->ldo_debug = * (const int *) invalue; + return LDAP_OPT_SUCCESS; + + default: +#ifdef HAVE_TLS + if ( ldap_pvt_tls_set_option( ld, option, (void *)invalue ) == 0 ) + return LDAP_OPT_SUCCESS; +#endif +#ifdef HAVE_CYRUS_SASL + if ( ldap_int_sasl_set_option( ld, option, (void *)invalue ) == 0 ) + return LDAP_OPT_SUCCESS; +#endif + /* bad param */ + break; + } + return LDAP_OPT_ERROR; +} + +int +ldap_set_rebind_proc( LDAP *ld, LDAP_REBIND_PROC *proc, void *params ) +{ + int rc; + rc = ldap_set_option( ld, LDAP_OPT_REBIND_PROC, (void *)proc ); + if( rc != LDAP_OPT_SUCCESS ) return rc; + + rc = ldap_set_option( ld, LDAP_OPT_REBIND_PARAMS, (void *)params ); + return rc; +} diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index 7412a58014..d549c7f324 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -31,7 +31,11 @@ int ldap_int_tblsize = 0; #if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP ) +# ifdef LDAP_PF_INET6 int ldap_int_inet4or6 = AF_UNSPEC; +# else +int ldap_int_inet4or6 = AF_INET; +# endif #endif /* @@ -197,6 +201,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr *sin, socklen_t addrlen, int async) { + int rc; struct timeval tv, *opt_tv=NULL; fd_set wfds, *z=NULL; #ifdef HAVE_WINSOCK @@ -226,8 +231,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, if ( ldap_pvt_ndelay_on(ld, s) == -1 ) return ( -1 ); - if ( connect(s, sin, addrlen) != AC_SOCKET_ERROR ) - { + if ( connect(s, sin, addrlen) != AC_SOCKET_ERROR ) { if ( ldap_pvt_ndelay_off(ld, s) == -1 ) return ( -1 ); return ( 0 ); @@ -253,16 +257,18 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, FD_SET(s, &efds ); #endif - if ( select(ldap_int_tblsize, z, &wfds, + do { + rc = select(ldap_int_tblsize, z, &wfds, #ifdef HAVE_WINSOCK - &efds, + &efds, #else - z, + z, #endif - opt_tv ? &tv : NULL) == AC_SOCKET_ERROR ) - { - return ( -1 ); - } + opt_tv ? &tv : NULL); + } while( rc == AC_SOCKET_ERROR && errno == EINTR && + LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART )); + + if( rc == AC_SOCKET_ERROR ) return rc; #ifdef HAVE_WINSOCK /* This means the connection failed */ @@ -686,7 +692,7 @@ ldap_int_select( LDAP *ld, struct timeval *timeout ) struct selectinfo *sip; #ifdef NEW_LOGGING - LDAP_LOG (( "os-ip", LDAP_LEVEL_ENTRY, "ldap_int_select\n" )); + LDAP_LOG ( CONNECTION, ENTRY, "ldap_int_select\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_int_select\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/os-local.c b/libraries/libldap/os-local.c index 8b3da9f228..b752a382fe 100644 --- a/libraries/libldap/os-local.c +++ b/libraries/libldap/os-local.c @@ -134,6 +134,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) static int ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_un *sa, int async) { + int rc; struct timeval tv, *opt_tv=NULL; fd_set wfds, *z=NULL; @@ -168,11 +169,12 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_un *sa, int async) FD_ZERO(&wfds); FD_SET(s, &wfds ); - if ( select(ldap_int_tblsize, z, &wfds, z, opt_tv ? &tv : NULL) - == AC_SOCKET_ERROR ) - { - return ( -1 ); - } + do { + rc = select(ldap_int_tblsize, z, &wfds, z, opt_tv ? &tv : NULL); + } while( rc == AC_SOCKET_ERROR && errno == EINTR && + LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART )); + + if( rc == AC_SOCKET_ERROR ) return rc; if ( FD_ISSET(s, &wfds) ) { if ( ldap_pvt_is_socket_ready(ld, s) == -1 ) diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 3c4d2347f7..b9ecd9b3bd 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -84,7 +84,7 @@ ldap_send_initial_request( int rc; #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ENTRY, "ldap_send_initial_request\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_send_initial_request\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_send_initial_request\n", 0, 0, 0 ); #endif @@ -99,8 +99,9 @@ ldap_send_initial_request( } #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_DETAIL1, - "ldap_send_initial_request: ldap_open_defconn: successful\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "ldap_send_initial_request: ldap_open_defconn: successful\n" , + 0, 0, 0); #else Debug( LDAP_DEBUG_TRACE, "ldap_open_defconn: successful\n", @@ -151,7 +152,7 @@ ldap_send_server_request( int incparent; #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ENTRY, "ldap_send_server_request\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_send_server_request\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_send_server_request\n", 0, 0, 0 ); #endif @@ -263,7 +264,7 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, Sockbuf *sb = NULL; #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ENTRY, "ldap_new_connection\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_new_connection\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_new_connection\n", 0, 0, 0 ); #endif @@ -329,8 +330,9 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, ld->ld_defconn = lc; #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_DETAIL1, - "ldap_new_connection: Call application rebind_proc\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "ldap_new_connection: Call application rebind_proc\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "Call application rebind_proc\n", 0, 0, 0); #endif @@ -354,8 +356,9 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, ld->ld_defconn = lc; #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_DETAIL1, - "ldap_new_connection: anonymous rebind via ldap_bind_s\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "ldap_new_connection: anonymous rebind via ldap_bind_s\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "anonymous rebind via ldap_bind_s\n", 0, 0, 0); #endif @@ -422,7 +425,7 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) LDAPConn *tmplc, *prevlc; #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ENTRY, "ldap_free_connection\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_free_connection\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_free_connection\n", 0, 0, 0 ); #endif @@ -472,8 +475,8 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) } LDAP_FREE( lc ); #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_RESULTS, - "ldap_free_connection: actually freed\n" )); + LDAP_LOG ( OPERATION, RESULTS, + "ldap_free_connection: actually freed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_free_connection: actually freed\n", 0, 0, 0 ); @@ -481,8 +484,8 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) } else { lc->lconn_lastused = time( NULL ); #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_RESULTS, - "ldap_free_connection: refcnt %d\n", lc->lconn_refcnt )); + LDAP_LOG ( OPERATION, RESULTS, "ldap_free_connection: refcnt %d\n", + lc->lconn_refcnt, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_free_connection: refcnt %d\n", lc->lconn_refcnt, 0, 0 ); @@ -612,9 +615,8 @@ ldap_free_request( LDAP *ld, LDAPRequest *lr ) LDAPRequest **ttmplr; #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ARGS, - "ldap_free_request (origid %d, msgid %d)\n", - lr->lr_origid, lr->lr_msgid )); + LDAP_LOG ( OPERATION, ARGS, "ldap_free_request (origid %d, msgid %d)\n", + lr->lr_origid, lr->lr_msgid, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_free_request (origid %d, msgid %d)\n", lr->lr_origid, lr->lr_msgid, 0 ); @@ -665,7 +667,7 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char * *hadrefp = 0; #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ENTRY, "ldap_chase_v3referrals\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_chase_v3referrals\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_chase_v3referrals\n", 0, 0, 0 ); #endif @@ -682,9 +684,9 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char * /* Check for hop limit exceeded */ if ( lr->lr_parentcnt >= ld->ld_refhoplimit ) { #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "ldap_chase_v3referrals: more than %d referral hops (dropping)\n", - ld->ld_refhoplimit )); + ld->ld_refhoplimit, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "more than %d referral hops (dropping)\n", ld->ld_refhoplimit, 0, 0 ); @@ -737,9 +739,9 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char * * for the same server with different contexts. */ #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "ldap_chase_v3referrals: queue referral \"%s\"\n", - refarray[i] )); + refarray[i], 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_chase_v3referrals: queue referral \"%s\"\n", @@ -807,9 +809,9 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char * } #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "ldap_chase_v3referrals: msgid %d, url \"%s\"\n", - lr->lr_msgid, refarray[i] )); + lr->lr_msgid, refarray[i], 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_chase_v3referral: msgid %d, url \"%s\"\n", @@ -823,9 +825,9 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char * origreq, srv, NULL, &rinfo )) < 0 ) { /* Failure, try next referral in the list */ #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ERR, + LDAP_LOG ( OPERATION, ERR, "ldap_chase_v3referrals: Unable to chase referral \"%s\" (%s)\n", - refarray[i], ldap_err2string( ld->ld_errno ) )); + refarray[i], ldap_err2string( ld->ld_errno ), 0 ); #else Debug( LDAP_DEBUG_ANY, "Unable to chase referral \"%s\" (%s)\n", refarray[i], ldap_err2string( ld->ld_errno ), 0); @@ -908,7 +910,7 @@ ldap_chase_referrals( LDAP *ld, LDAPreqinfo rinfo; #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ENTRY, "ldap_chase_referrals\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_chase_referrals\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_chase_referrals\n", 0, 0, 0 ); #endif @@ -935,9 +937,9 @@ ldap_chase_referrals( LDAP *ld, if ( lr->lr_parentcnt >= ld->ld_refhoplimit ) { #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ENTRY, + LDAP_LOG ( OPERATION, ENTRY, "ldap_chase_referrals: more than %d referral hops (dropping)\n", - ld->ld_refhoplimit )); + ld->ld_refhoplimit, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "more than %d referral hops (dropping)\n", @@ -968,9 +970,9 @@ ldap_chase_referrals( LDAP *ld, if ( rc != LDAP_URL_SUCCESS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "ldap_chase_referrals: ignoring unknown referral <%s>\n", - ref )); + ref, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ignoring unknown referral <%s>\n", ref, 0, 0 ); @@ -986,8 +988,8 @@ ldap_chase_referrals( LDAP *ld, } #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_DETAIL1, - "ldap_chase_referrals: chasing LDAP referral <%s>\n", ref )); + LDAP_LOG ( OPERATION, DETAIL1, + "ldap_chase_referrals: chasing LDAP referral <%s>\n", ref, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "chasing LDAP referral: <%s>\n", ref, 0, 0 ); @@ -1016,9 +1018,9 @@ ldap_chase_referrals( LDAP *ld, ++count; } else { #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ERR, + LDAP_LOG ( OPERATION, ERR, "ldap_chase_referrals: Unable to chase referral <%s>\n", - ldap_err2string( ld->ld_errno) )); + ldap_err2string( ld->ld_errno), 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "Unable to chase referral (%s)\n", @@ -1091,10 +1093,10 @@ re_encode_request( LDAP *ld, char *dn; #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_ARGS, + LDAP_LOG ( OPERATION, ARGS, "re_encode_request: new msgid %ld, new dn <%s>\n", (long) msgid, - ( srv == NULL || srv->lud_dn == NULL ) ? "NONE" : srv->lud_dn )); + ( srv == NULL || srv->lud_dn == NULL ) ? "NONE" : srv->lud_dn, 0 ); #else Debug( LDAP_DEBUG_TRACE, "re_encode_request: new msgid %ld, new dn <%s>\n", @@ -1192,8 +1194,8 @@ re_encode_request( LDAP *ld, #ifdef LDAP_DEBUG if ( ldap_debug & LDAP_DEBUG_PACKETS ) { #ifdef NEW_LOGGING - LDAP_LOG (( "request", LDAP_LEVEL_DETAIL1, - "re_encode_request: new request is:\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "re_encode_request: new request is:\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "re_encode_request new request is:\n", 0, 0, 0 ); diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index a1ee317cf6..1a7bcec9ef 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -53,7 +53,7 @@ #include #include "ldap-int.h" - +#include "ldap_log.h" static int ldap_abandoned LDAP_P(( LDAP *ld, ber_int_t msgid )); static int ldap_mark_abandoned LDAP_P(( LDAP *ld, ber_int_t msgid )); @@ -98,7 +98,7 @@ ldap_result( assert( result != NULL ); #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_ARGS, "ldap_result msgid %d\n", msgid )); + LDAP_LOG ( OPERATION, ARGS, "ldap_result msgid %d\n", msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_result msgid %d\n", msgid, 0, 0 ); #endif @@ -129,8 +129,8 @@ chkResponseList( */ #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_ARGS, - "ldap_chkResponseList for msgid=%d, all=%d\n", msgid, all )); + LDAP_LOG ( OPERATION, ARGS, "ldap_chkResponseList for msgid=%d, all=%d\n", + msgid, all, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_chkResponseList for msgid=%d, all=%d\n", @@ -142,8 +142,8 @@ chkResponseList( if ( ldap_abandoned( ld, lm->lm_msgid ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, - "ldap_chkResponseList msg abandoned, msgid %d\n", msgid )); + LDAP_LOG ( OPERATION, DETAIL1, + "ldap_chkResponseList msg abandoned, msgid %d\n", msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_chkResponseList msg abandoned, msgid %d\n", @@ -207,17 +207,17 @@ chkResponseList( #ifdef LDAP_DEBUG if( lm == NULL) { #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_RESULTS, - "ldap_chkResponseList returns NULL\n" )); + LDAP_LOG ( OPERATION, RESULTS, "ldap_chkResponseList returns NULL\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_chkResponseList returns NULL\n", 0, 0, 0); #endif } else { #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_RESULTS, - "ldap_chkResponseList returns msgid %d, type 0x02lu\n", - lm->lm_msgid, (unsigned long) lm->lm_msgtype )); + LDAP_LOG ( OPERATION, RESULTS, + "ldap_chkResponseList returns msgid %d, type 0x%02lu\n", + lm->lm_msgid, (unsigned long) lm->lm_msgtype, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_chkResponseList returns msgid %d, type 0x%02lu\n", @@ -248,17 +248,17 @@ wait4msg( #ifdef LDAP_DEBUG if ( timeout == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_ARGS, - "wait4msg (infinite timeout), msgid %d\n", msgid )); + LDAP_LOG ( OPERATION, ARGS, + "wait4msg (infinite timeout), msgid %d\n", msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "wait4msg (infinite timeout), msgid %d\n", msgid, 0, 0 ); #endif } else { #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_ARGS, + LDAP_LOG ( OPERATION, ARGS, "wait4msg (timeout %ld sec, %ld usec), msgid %d\n", - (long) timeout->tv_sec, (long) timeout->tv_usec, msgid )); + (long) timeout->tv_sec, (long) timeout->tv_usec, msgid ); #else Debug( LDAP_DEBUG_TRACE, "wait4msg (timeout %ld sec, %ld usec), msgid %d\n", (long) timeout->tv_sec, (long) timeout->tv_usec, msgid ); @@ -278,8 +278,8 @@ wait4msg( while ( rc == -2 ) { #ifdef LDAP_DEBUG #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_ARGS, - "wait4msg continue, msgid %d, all %d\n", msgid, all )); + LDAP_LOG ( OPERATION, ARGS, + "wait4msg continue, msgid %d, all %d\n", msgid, all, 0 ); #else Debug( LDAP_DEBUG_TRACE, "wait4msg continue, msgid %d, all %d\n", msgid, all, 0 ); @@ -310,9 +310,9 @@ wait4msg( #ifdef LDAP_DEBUG if ( rc == -1 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_ARGS, + LDAP_LOG ( OPERATION, ARGS, "wait4msg: ldap_int_select returned -1: errno %d\n", - errno )); + errno, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_int_select returned -1: errno %d\n", @@ -358,8 +358,8 @@ wait4msg( } #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, - "wait4msg: %ld secs to go\n", (long) tv.tv_sec )); + LDAP_LOG ( OPERATION, DETAIL1, + "wait4msg: %ld secs to go\n", (long) tv.tv_sec, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "wait4msg: %ld secs to go\n", (long) tv.tv_sec, 0, 0 ); @@ -401,8 +401,7 @@ try_read1msg( assert( lc != NULL ); #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_ARGS, "read1msg: msgid %d, all %d\n", - msgid, all )); + LDAP_LOG ( OPERATION, ARGS, "read1msg: msgid %d, all %d\n", msgid, all, 0 ); #else Debug( LDAP_DEBUG_TRACE, "read1msg: msgid %d, all %d\n", msgid, all, 0 ); #endif @@ -431,8 +430,8 @@ try_read1msg( if ( tag == LBER_DEFAULT) { #ifdef LDAP_DEBUG #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, - "read1msg: ber_get_next failed\n" )); + LDAP_LOG ( OPERATION, DETAIL1, + "read1msg: ber_get_next failed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_CONNS, "ber_get_next failed.\n", 0, 0, 0 ); @@ -468,8 +467,7 @@ try_read1msg( if ( ldap_abandoned( ld, id ) ) { ber_free( ber, 1 ); #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, - "read1msg: abandoned\n" )); + LDAP_LOG ( OPERATION, DETAIL1, "read1msg: abandoned\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "abandoned\n", 0, 0, 0); #endif @@ -478,9 +476,9 @@ try_read1msg( if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "read1msg: no request for response with msgid %ld (tossing)\n", - (long) id )); + (long) id, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "no request for response with msgid %ld (tossing)\n", @@ -503,10 +501,10 @@ try_read1msg( } #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "read1msg: ldap_read: message type %s msgid %ld, original id %ld\n", ldap_int_msgtype2str( tag ), - (long) lr->lr_msgid, (long) lr->lr_origid )); + (long) lr->lr_msgid, (long) lr->lr_origid ); #else Debug( LDAP_DEBUG_TRACE, "ldap_read: message type %s msgid %ld, original id %ld\n", @@ -548,10 +546,10 @@ try_read1msg( if( lr->lr_status != LDAP_REQST_COMPLETED) { lr->lr_status = LDAP_REQST_CHASINGREFS; #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "read1msg: search ref chased," "mark request chasing refs, id = %d\n", - lr->lr_msgid )); + lr->lr_msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "read1msg: search ref chased, mark request chasing refs, id = %d\n", @@ -581,10 +579,10 @@ try_read1msg( rc = LDAP_DECODING_ERROR; lr->lr_status = LDAP_REQST_COMPLETED; #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "read1msg: referral decode error," "mark request completed, id = %d\n", - lr->lr_msgid )); + lr->lr_msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "read1msg: referral decode error, mark request completed, id = %d\n", @@ -598,10 +596,10 @@ try_read1msg( 0, &lr->lr_res_error, &hadref ); lr->lr_status = LDAP_REQST_COMPLETED; #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "read1msg: referral chased," "mark request completed, id = %d\n", - lr->lr_msgid )); + lr->lr_msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "read1msg: referral chased, mark request completed, id = %d\n", @@ -654,10 +652,10 @@ try_read1msg( &lr->lr_res_error, -1, &hadref ); lr->lr_status = LDAP_REQST_COMPLETED; #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "read1msg: V2 referral chased," "mark request completed, id = %d\n", - lr->lr_msgid )); + lr->lr_msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "read1msg: V2 referral chased, mark request completed, id = %d\n", lr->lr_msgid, 0, 0); @@ -675,10 +673,10 @@ try_read1msg( lr->lr_res_errno = LDAP_PARTIAL_RESULTS; } #ifdef NEW_LOGGING -LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, +LDAP_LOG ( OPERATION, DETAIL1, "read1msg: new result: res_errno: %d, res_error: <%s>, res_matched: <%s>\n", lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "", - lr->lr_res_matched ? lr->lr_res_matched : "" )); + lr->lr_res_matched ? lr->lr_res_matched : "" ); #else Debug( LDAP_DEBUG_TRACE, "new result: res_errno: %d, res_error: <%s>, res_matched: <%s>\n", @@ -689,8 +687,8 @@ Debug( LDAP_DEBUG_TRACE, } #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, - "read1msg: %d new referrals\n", refer_cnt )); + LDAP_LOG ( OPERATION, DETAIL1, "read1msg: %d new referrals\n", + refer_cnt, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "read1msg: %d new referrals\n", refer_cnt, 0, 0 ); @@ -715,8 +713,9 @@ Debug( LDAP_DEBUG_TRACE, lr->lr_status = LDAP_REQST_COMPLETED; /* declare this request done */ #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, - "read1msg: mark request completed, id = %d\n", lr->lr_msgid )); + LDAP_LOG ( OPERATION, DETAIL1, + "read1msg: mark request completed, id = %d\n", + lr->lr_msgid, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "read1msg: mark request completed, id = %d\n", lr->lr_msgid, 0, 0); @@ -745,12 +744,12 @@ Debug( LDAP_DEBUG_TRACE, id = lr->lr_msgid; tag = lr->lr_res_msgtype; #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, - "read1msg: request %ld done\n", (long) id )); - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, + "read1msg: request %ld done\n", (long) id, 0, 0 ); + LDAP_LOG ( OPERATION, DETAIL1, "read1msg: res_errno: %d,res_error: <%s>, res_matched: <%s>\n", lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "", - lr->lr_res_matched ? lr->lr_res_matched : "" )); + lr->lr_res_matched ? lr->lr_res_matched : "" ); #else Debug( LDAP_DEBUG_ANY, "request %ld done\n", (long) id, 0, 0 ); @@ -838,9 +837,9 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); } #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( OPERATION, DETAIL1, "read1msg: adding response id %ld type %ld\n", - (long) new->lm_msgid, (long) new->lm_msgtype )); + (long) new->lm_msgid, (long) new->lm_msgtype, 0 ); #else Debug( LDAP_DEBUG_TRACE, "adding response id %ld type %ld:\n", (long) new->lm_msgid, (long) new->lm_msgtype, 0 ); @@ -964,12 +963,12 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) } #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_DETAIL1, - "read1msg: merged parent (id %d) error info: result errno %d, " - "error <%s>, matched <%s>\n", parentr->lr_msgid, + LDAP_LOG( OPERATION, DETAIL1, "merged parent (id %d) error info: ", + parentr->lr_msgid, 0, 0 ); + LDAP_LOG( OPERATION, DETAIL1, "result errno %d, error <%s>, matched <%s>\n", parentr->lr_res_errno, parentr->lr_res_error ? parentr->lr_res_error : "", parentr->lr_res_matched ? - parentr->lr_res_matched : "" )); + parentr->lr_res_matched : "" ); #else Debug( LDAP_DEBUG_TRACE, "merged parent (id %d) error info: ", parentr->lr_msgid, 0, 0 ); @@ -1024,7 +1023,7 @@ ldap_msgfree( LDAPMessage *lm ) int type = 0; #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_ENTRY, "ldap_msgfree\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_msgfree\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_msgfree\n", 0, 0, 0 ); #endif @@ -1052,7 +1051,7 @@ ldap_msgdelete( LDAP *ld, int msgid ) assert( ld != NULL ); #ifdef NEW_LOGGING - LDAP_LOG (( "result", LDAP_LEVEL_ENTRY, "ldap_msgdelete\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_msgdelete\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_msgdelete\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c index 0164bc962f..e5c64921d5 100644 --- a/libraries/libldap/sasl.c +++ b/libraries/libldap/sasl.c @@ -62,7 +62,7 @@ ldap_sasl_bind( int rc; #ifdef NEW_LOGGING - LDAP_LOG (( "sasl", LDAP_LEVEL_ENTRY, "ldap_sasl_bind\n" )); + LDAP_LOG ( TRANSPORT, ENTRY, "ldap_sasl_bind\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_sasl_bind\n", 0, 0, 0 ); #endif @@ -169,7 +169,7 @@ ldap_sasl_bind_s( struct berval *scredp = NULL; #ifdef NEW_LOGGING - LDAP_LOG (( "sasl", LDAP_LEVEL_ENTRY, "ldap_sasl_bind_s\n" )); + LDAP_LOG ( TRANSPORT, ENTRY, "ldap_sasl_bind_s\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_sasl_bind_s\n", 0, 0, 0 ); #endif @@ -255,7 +255,7 @@ ldap_parse_sasl_bind_result( BerElement *ber; #ifdef NEW_LOGGING - LDAP_LOG (( "sasl", LDAP_LEVEL_ENTRY, "ldap_parse_sasl_bind_result\n" )); + LDAP_LOG ( TRANSPORT, ENTRY, "ldap_parse_sasl_bind_result\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_parse_sasl_bind_result\n", 0, 0, 0 ); #endif @@ -368,7 +368,7 @@ ldap_pvt_sasl_getmechs ( LDAP *ld, char **pmechlist ) int rc; #ifdef NEW_LOGGING - LDAP_LOG (( "sasl", LDAP_LEVEL_ENTRY, "ldap_pvt_sasl_getmech\n" )); + LDAP_LOG ( TRANSPORT, ENTRY, "ldap_pvt_sasl_getmech\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_pvt_sasl_getmech\n", 0, 0, 0 ); #endif @@ -456,8 +456,9 @@ ldap_sasl_interactive_bind_s( } #ifdef NEW_LOGGING - LDAP_LOG (( "sasl", LDAP_LEVEL_DETAIL1, - "ldap_interactive_sasl_bind_s: server supports: %s\n", smechs )); + LDAP_LOG ( TRANSPORT, DETAIL1, + "ldap_interactive_sasl_bind_s: server supports: %s\n", + smechs, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_interactive_sasl_bind_s: server supports: %s\n", @@ -468,8 +469,8 @@ ldap_sasl_interactive_bind_s( } else { #ifdef NEW_LOGGING - LDAP_LOG (( "sasl", LDAP_LEVEL_DETAIL1, - "ldap_interactive_sasl_bind_s: user selected: %s\n", mechs )); + LDAP_LOG ( TRANSPORT, DETAIL1, + "ldap_interactive_sasl_bind_s: user selected: %s\n", mechs, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_interactive_sasl_bind_s: user selected: %s\n", diff --git a/libraries/libldap/sbind.c b/libraries/libldap/sbind.c index eb8aaed4bd..1d016bbf92 100644 --- a/libraries/libldap/sbind.c +++ b/libraries/libldap/sbind.c @@ -41,7 +41,6 @@ #include "ldap-int.h" - /* * ldap_simple_bind - bind to the ldap server (and X.500). The dn and * password of the entry to which to bind are supplied. The message id @@ -63,7 +62,7 @@ ldap_simple_bind( struct berval cred; #ifdef NEW_LOGGING - LDAP_LOG (( "sbind", LDAP_LEVEL_ENTRY, "ldap_simple_bind\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_simple_bind\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind\n", 0, 0, 0 ); #endif @@ -102,7 +101,7 @@ ldap_simple_bind_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd ) struct berval cred; #ifdef NEW_LOGGING - LDAP_LOG (( "sbind", LDAP_LEVEL_ENTRY, "ldap_simple_bind_s\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_simple_bind_s\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind_s\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/schema.c b/libraries/libldap/schema.c index 4fd83bc4bd..93a1daf381 100644 --- a/libraries/libldap/schema.c +++ b/libraries/libldap/schema.c @@ -281,7 +281,7 @@ print_noidlen(safe_string *ss, char *s, int l) ret = print_numericoid(ss,s); if ( l ) { - sprintf(buf,"{%d}",l); + snprintf(buf, sizeof buf, "{%d}",l); ret = print_literal(ss,buf); } return(ret); diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index c0bc46df78..2817e65082 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -21,7 +21,7 @@ #include #include "ldap-int.h" - +#include "ldap_log.h" /* * ldap_search_ext - initiate an ldap search operation. @@ -62,7 +62,7 @@ ldap_search_ext( int timelimit; #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_ENTRY, "ldap_search_ext\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_search_ext\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_search_ext\n", 0, 0, 0 ); #endif @@ -184,7 +184,7 @@ ldap_search( BerElement *ber; #ifdef NEW_LOGGING - LDAP_LOG (( "search", LDAP_LEVEL_ENTRY, "ldap_search\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_search\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_search\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/tls.c b/libraries/libldap/tls.c index f7f27bce46..e8c8c266c4 100644 --- a/libraries/libldap/tls.c +++ b/libraries/libldap/tls.c @@ -180,9 +180,9 @@ ldap_pvt_tls_init_def_ctx( void ) tls_def_ctx = SSL_CTX_new( SSLv23_method() ); if ( tls_def_ctx == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_pvt_tls_init_def_ctx: " + LDAP_LOG ( TRANSPORT, ERR, "ldap_pvt_tls_init_def_ctx: " "TLS could not allocate default ctx (%d).\n", - ERR_peek_error() )); + ERR_peek_error(), 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: could not allocate default ctx (%lu).\n", @@ -195,9 +195,9 @@ ldap_pvt_tls_init_def_ctx( void ) !SSL_CTX_set_cipher_list( tls_def_ctx, tls_opt_ciphersuite ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_pvt_tls_init_def_ctx: " + LDAP_LOG ( TRANSPORT, ERR, "ldap_pvt_tls_init_def_ctx: " "TLS could not set cipher list %s.\n", - tls_opt_ciphersuite )); + tls_opt_ciphersuite, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: could not set cipher list %s.\n", @@ -213,12 +213,12 @@ ldap_pvt_tls_init_def_ctx( void ) !SSL_CTX_set_default_verify_paths( tls_def_ctx ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, + LDAP_LOG ( TRANSPORT, ERR, "ldap_pvt_tls_init_def_ctx: " "TLS could not load verify locations " "(file:`%s',dir:`%s').\n", tls_opt_cacertfile ? tls_opt_cacertfile : "", - tls_opt_cacertdir ? tls_opt_cacertdir : "" )); + tls_opt_cacertdir ? tls_opt_cacertdir : "", 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: " "could not load verify locations (file:`%s',dir:`%s').\n", @@ -233,10 +233,10 @@ ldap_pvt_tls_init_def_ctx( void ) calist = get_ca_list( tls_opt_cacertfile, tls_opt_cacertdir ); if ( !calist ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_pvt_tls_init_def_ctx: " + LDAP_LOG ( TRANSPORT, ERR, "ldap_pvt_tls_init_def_ctx: " "TLS could not load client CA list (file: `%s',dir:`%s')\n", tls_opt_cacertfile ? tls_opt_cacertfile : "", - tls_opt_cacertdir ? tls_opt_cacertdir : "" )); + tls_opt_cacertdir ? tls_opt_cacertdir : "", 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: " "could not load client CA list (file:`%s',dir:`%s').\n", @@ -256,8 +256,8 @@ ldap_pvt_tls_init_def_ctx( void ) tls_opt_keyfile, SSL_FILETYPE_PEM ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_pvt_tls_init_def_ctx: " - "TLS could not use key file `%s'.\n", tls_opt_keyfile )); + LDAP_LOG ( TRANSPORT, ERR, "ldap_pvt_tls_init_def_ctx: " + "TLS could not use key file `%s'.\n", tls_opt_keyfile, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: could not use key file `%s'.\n", @@ -272,8 +272,9 @@ ldap_pvt_tls_init_def_ctx( void ) tls_opt_certfile, SSL_FILETYPE_PEM ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_pvt_tls_init_def_ctx: " - "TLS could not use certificate `%s'.\n", tls_opt_certfile )); + LDAP_LOG ( TRANSPORT, ERR, "ldap_pvt_tls_init_def_ctx: " + "TLS could not use certificate `%s'.\n", + tls_opt_certfile, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: could not use certificate `%s'.\n", @@ -287,8 +288,9 @@ ldap_pvt_tls_init_def_ctx( void ) !SSL_CTX_check_private_key( tls_def_ctx ) ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_pvt_tls_init_def_ctx: " - "TLS private key mismatch.\n" )); + LDAP_LOG ( TRANSPORT, ERR, + "ldap_pvt_tls_init_def_ctx: TLS private key mismatch.\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: private key mismatch.\n", @@ -341,6 +343,7 @@ get_ca_list( char * bundle, char * dir ) if ( bundle ) { ca_list = SSL_load_client_CA_file( bundle ); } +#if defined(HAVE_DIRENT_H) || defined(dirent) if ( dir ) { DIR *dirp; struct dirent *d; @@ -377,6 +380,7 @@ get_ca_list( char * bundle, char * dir ) ca_list = NULL; } } +#endif done: return ca_list; } @@ -397,8 +401,8 @@ alloc_handle( void *ctx_arg ) ssl = SSL_new( ctx ); if ( ssl == NULL ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "alloc_handle: " - "TLS can't create ssl handle.\n" )); + LDAP_LOG ( TRANSPORT, ERR, + "alloc_handle: TLS can't create ssl handle.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY,"TLS: can't create ssl handle.\n",0,0,0); #endif @@ -739,8 +743,8 @@ ldap_int_tls_connect( LDAP *ld, LDAPConn *conn ) } #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_int_tls_connect: " - "TLS can't connect.\n" )); + LDAP_LOG ( TRANSPORT, ERR, + "ldap_int_tls_connect: TLS can't connect.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY,"TLS: can't connect.\n",0,0,0); #endif @@ -791,8 +795,8 @@ ldap_pvt_tls_accept( Sockbuf *sb, void *ctx_arg ) if ( update_flags( sb, ssl, err )) return 1; #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_pvt_tls_accept: " - "TLS can't accept.\n" )); + LDAP_LOG ( TRANSPORT, ERR, + "ldap_pvt_tls_accept: TLS can't accept.\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY,"TLS: can't accept.\n",0,0,0 ); #endif @@ -929,8 +933,9 @@ ldap_pvt_tls_check_hostname( void *s, const char *name_in ) x = tls_get_cert((SSL *)s); if (!x) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_pvt_tls_check_hostname: " - "TLS unable to get peer certificate.\n" )); + LDAP_LOG ( TRANSPORT, ERR, + "ldap_pvt_tls_check_hostname: " + "TLS unable to get peer certificate.\n" , 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: unable to get peer certificate.\n", @@ -1006,8 +1011,9 @@ ldap_pvt_tls_check_hostname( void *s, const char *name_in ) buf, sizeof(buf)) == -1) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_pvt_tls_check_hostname: " - "TLS unable to get common name from peer certificate.\n" )); + LDAP_LOG ( TRANSPORT, ERR, "ldap_pvt_tls_check_hostname: " + "TLS unable to get common name from peer certificate.\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: unable to get common name from peer certificate.\n", @@ -1016,9 +1022,9 @@ ldap_pvt_tls_check_hostname( void *s, const char *name_in ) } else if (strcasecmp(name, buf)) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "ldap_pvt_tls_check_hostname: " + LDAP_LOG ( TRANSPORT, ERR, "ldap_pvt_tls_check_hostname: " "TLS hostname (%s) does not match " - "common name in certificate (%s).\n", name, buf )); + "common name in certificate (%s).\n", name, buf, 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: hostname (%s) does not match " "common name in certificate (%s).\n", @@ -1344,8 +1350,8 @@ tls_info_cb( SSL *ssl, int where, int ret ) if ( where & SSL_CB_LOOP ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_DETAIL1, "tls_info_cb: " - "TLS trace: %s:%s\n", op, SSL_state_string_long( ssl ) )); + LDAP_LOG ( TRANSPORT, DETAIL1, "tls_info_cb: " + "TLS trace: %s:%s\n", op, SSL_state_string_long( ssl ), 0 ); #else Debug( LDAP_DEBUG_TRACE, "TLS trace: %s:%s\n", @@ -1355,10 +1361,10 @@ tls_info_cb( SSL *ssl, int where, int ret ) } else if ( where & SSL_CB_ALERT ) { op = ( where & SSL_CB_READ ) ? "read" : "write"; #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_DETAIL1, "tls_info_cb: " - "TLS trace: SSL3 alert %s:%s:%s\n", op, - SSL_alert_type_string_long( ret ), - SSL_alert_desc_string_long( ret) )); + LDAP_LOG ( TRANSPORT, DETAIL1, + "tls_info_cb: TLS trace: SSL3 alert %s:%s:%s\n", + op, SSL_alert_type_string_long( ret ), + SSL_alert_desc_string_long( ret) ); #else Debug( LDAP_DEBUG_TRACE, "TLS trace: SSL3 alert %s:%s:%s\n", @@ -1370,8 +1376,9 @@ tls_info_cb( SSL *ssl, int where, int ret ) } else if ( where & SSL_CB_EXIT ) { if ( ret == 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "tls_info_cb: " - "TLS trace: %s:failed in %s\n", op, SSL_state_string_long( ssl ) )); + LDAP_LOG ( TRANSPORT, ERR, + "tls_info_cb: TLS trace: %s:failed in %s\n", + op, SSL_state_string_long( ssl ), 0 ); #else Debug( LDAP_DEBUG_TRACE, "TLS trace: %s:failed in %s\n", @@ -1379,8 +1386,9 @@ tls_info_cb( SSL *ssl, int where, int ret ) #endif } else if ( ret < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "tls_info_cb: " - "TLS trace: %s:error in %s\n", op, SSL_state_string_long( ssl ) )); + LDAP_LOG ( TRANSPORT, ERR, + "tls_info_cb: TLS trace: %s:error in %s\n", + op, SSL_state_string_long( ssl ), 0 ); #else Debug( LDAP_DEBUG_TRACE, "TLS trace: %s:error in %s\n", @@ -1415,13 +1423,15 @@ tls_verify_cb( int ok, X509_STORE_CTX *ctx ) sname = X509_NAME_oneline( subject, NULL, 0 ); iname = X509_NAME_oneline( issuer, NULL, 0 ); #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "tls_verify_cb" - "TLS certificate verification: depth: %d, err: %d: " - "subject: %s, issuer: %s\n", errdepth, errnum, - sname ? sname : "-unknown-", iname ? iname : "-unknown-" )); + LDAP_LOG( TRANSPORT, ERR, + "TLS certificate verification: depth: %d, err: %d, subject: %s,", + errdepth, errnum, + sname ? sname : "-unknown-" ); + LDAP_LOG( TRANSPORT, ERR, " issuer: %s\n", iname ? iname : "-unknown-", 0, 0 ); if ( !ok ) { - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, "TLS certificate verification: Error, %s\n", - X509_verify_cert_error_string(errnum))); + LDAP_LOG ( TRANSPORT, ERR, + "TLS certificate verification: Error, %s\n", + X509_verify_cert_error_string(errnum), 0, 0 ); } #else Debug( LDAP_DEBUG_TRACE, @@ -1461,9 +1471,9 @@ tls_report_error( void ) while ( ( l = ERR_get_error_line( &file, &line ) ) != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, + LDAP_LOG ( TRANSPORT, ERR, "tls_report_error: TLS %s %s:%d\n", - ERR_error_string( l, buf ), file, line )); + ERR_error_string( l, buf ), file, line ); #else Debug( LDAP_DEBUG_ANY, "TLS: %s %s:%d\n", ERR_error_string( l, buf ), file, line ); @@ -1482,9 +1492,9 @@ tls_tmp_rsa_cb( SSL *ssl, int is_export, int key_length ) if ( !tmp_rsa ) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_ERR, - "tls_tmp_rsa_cb: TLS Failed to generate temporary %d-bit %s RSA key\n", - key_length, is_export ? "export" : "domestic" )); + LDAP_LOG ( TRANSPORT, ERR, + "tls_tmp_rsa_cb: TLS Failed to generate temporary %d-bit %s " + "RSA key\n", key_length, is_export ? "export" : "domestic", 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: Failed to generate temporary %d-bit %s RSA key\n", @@ -1518,9 +1528,9 @@ tls_seed_PRNG( const char *randfile ) if (randfile == NULL) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_DETAIL1, + LDAP_LOG ( TRANSPORT, DETAIL1, "tls_seed_PRNG: TLS Use configuration file or " - "$RANDFILE to define seed PRNG\n" )); + "$RANDFILE to define seed PRNG\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: Use configuration file or $RANDFILE to define seed PRNG\n", @@ -1533,8 +1543,9 @@ tls_seed_PRNG( const char *randfile ) if (RAND_status() == 0) { #ifdef NEW_LOGGING - LDAP_LOG (( "tls", LDAP_LEVEL_DETAIL1, - "tls_seed_PRNG: TLS PRNG not been seeded with enough data\n" )); + LDAP_LOG ( TRANSPORT, DETAIL1, + "tls_seed_PRNG: TLS PRNG not been seeded with enough data\n", + 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "TLS: PRNG not been seeded with enough data\n", diff --git a/libraries/libldap/unbind.c b/libraries/libldap/unbind.c index 4474920bf7..45b77f6528 100644 --- a/libraries/libldap/unbind.c +++ b/libraries/libldap/unbind.c @@ -59,7 +59,7 @@ int ldap_unbind( LDAP *ld ) { #ifdef NEW_LOGGING - LDAP_LOG (( "unbind", LDAP_LEVEL_ENTRY, "ldap_unbind\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_unbind\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_unbind\n", 0, 0, 0 ); #endif @@ -181,7 +181,7 @@ ldap_send_unbind( BerElement *ber; #ifdef NEW_LOGGING - LDAP_LOG (( "unbind", LDAP_LEVEL_ENTRY, "ldap_send_unbind\n" )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_send_unbind\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_send_unbind\n", 0, 0, 0 ); #endif diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index e7985dae6b..8bf8bd56d5 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -34,7 +34,6 @@ #include "ldap-int.h" - /* local functions */ static const char* skip_url_prefix LDAP_P(( const char *url, @@ -446,7 +445,7 @@ ldap_url_parse_ext( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) * the options and cause infinite recursion */ #ifdef NEW_LOGGING - LDAP_LOG (( "url", LDAP_LEVEL_ENTRY, "ldap_url_parse_ext(%s)\n", url_in )); + LDAP_LOG ( OPERATION, ENTRY, "ldap_url_parse_ext(%s)\n", url_in, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldap_url_parse_ext(%s)\n", url_in, 0, 0 ); #endif @@ -1138,12 +1137,14 @@ ldap_pvt_hex_unescape( char *s ) for ( p = s; *s != '\0'; ++s ) { if ( *s == '%' ) { - if ( *++s != '\0' ) { - *p = ldap_int_unhex( *s ) << 4; + if ( *++s == '\0' ) { + break; } - if ( *++s != '\0' ) { - *p++ += ldap_int_unhex( *s ); + *p = ldap_int_unhex( *s ) << 4; + if ( *++s == '\0' ) { + break; } + *p++ += ldap_int_unhex( *s ); } else { *p++ = *s; } -- 2.39.5