From: Kurt Zeilenga Date: Sat, 23 Jan 1999 22:05:01 +0000 (+0000) Subject: lber_debug/ldap_debug are always defined and provided by the implementation. X-Git-Tag: OPENLDAP_REL_ENG_1_2_BETA~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d03618b3ee5eac3f06caa125976076c9108516c;p=thirdparty%2Fopenldap.git lber_debug/ldap_debug are always defined and provided by the implementation. --- diff --git a/clients/fax500/main.c b/clients/fax500/main.c index 240f737293..2c103c20a8 100644 --- a/clients/fax500/main.c +++ b/clients/fax500/main.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -185,6 +186,10 @@ main ( int argc, char **argv ) identity = MAIL500; } +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + #ifdef LOG_MAIL openlog( myname, OPENLOG_OPTIONS, LOG_MAIL ); #else diff --git a/clients/fax500/rp500.c b/clients/fax500/rp500.c index bd6744ad98..abf4daad89 100644 --- a/clients/fax500/rp500.c +++ b/clients/fax500/rp500.c @@ -38,7 +38,7 @@ #define DEFAULT_PORT 79 #define DEFAULT_SIZELIMIT 50 -int debug; +int debug = 0; char *ldaphost = NULL; char *base = NULL; int deref; @@ -81,7 +81,7 @@ main( int argc, char **argv ) break; case 'd': /* turn on debugging */ - debug = atoi( optarg ); + debug |= atoi( optarg ); break; case 'f': /* ldap filter file */ @@ -111,6 +111,14 @@ main( int argc, char **argv ) exit( -1 ); } + if ( debug ) { + lber_debug = ldap_debug = debug; + } + +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) { perror( "ldap_open" ); exit( -1 ); diff --git a/clients/finger/main.c b/clients/finger/main.c index b359bee984..0b3f6b2d84 100644 --- a/clients/finger/main.c +++ b/clients/finger/main.c @@ -122,6 +122,10 @@ main( int argc, char **argv ) else myname = strdup( myname + 1 ); +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + if ( dosyslog ) { #ifdef LOG_LOCAL4 openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL4 ); diff --git a/clients/gopher/go500.c b/clients/gopher/go500.c index 05d56b2136..13b450c459 100644 --- a/clients/gopher/go500.c +++ b/clients/gopher/go500.c @@ -41,7 +41,7 @@ #include "disptmpl.h" -int debug; +int debug = 0; int dosyslog; int inetd; int dtblsize; @@ -95,7 +95,7 @@ main( int argc, char **argv ) break; case 'd': /* debug level */ - debug = atoi( optarg ); + debug |= atoi( optarg ); break; case 'f': /* ldap filter file */ @@ -165,6 +165,14 @@ main( int argc, char **argv ) else myname = strdup( myname + 1 ); + if ( debug ) { + lber_debug = ldap_debug = debug; + } + +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + if ( dosyslog ) { #ifdef LOG_LOCAL3 openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL3 ); diff --git a/clients/gopher/go500gw.c b/clients/gopher/go500gw.c index 2c6142507b..4cd87ce55b 100644 --- a/clients/gopher/go500gw.c +++ b/clients/gopher/go500gw.c @@ -43,7 +43,7 @@ #include "ldapconfig.h" -int debug; +int debug = 0; int dosyslog; int inetd; int dtblsize; @@ -109,10 +109,8 @@ main (int argc, char **argv ) break; case 'd': /* debugging level */ - debug = atoi( optarg ); -#ifdef LDAP_DEBUG - ldap_debug = debug; -#else + debug |= atoi( optarg ); +#ifndef LDAP_DEBUG fprintf( stderr, "warning: ldap debugging requires LDAP_DEBUG\n" ); #endif break; @@ -193,6 +191,14 @@ main (int argc, char **argv ) else myname = strdup( myname + 1 ); + if ( debug ) { + lber_debug = ldap_debug = debug; + } + +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + if ( dosyslog ) { #ifdef LOG_LOCAL3 openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL3 ); diff --git a/clients/mail500/main.c b/clients/mail500/main.c index d826499e0f..aedd5594d3 100644 --- a/clients/mail500/main.c +++ b/clients/mail500/main.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -63,7 +64,7 @@ char *mailfrom = NULL; char *host = NULL; char *ldaphost = NULL; int hostlen = 0; -int debug; +int debug = 0; typedef struct errs { int e_code; @@ -165,6 +166,10 @@ main ( int argc, char **argv ) else myname = strdup( myname + 1 ); +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + #ifdef LOG_MAIL openlog( myname, OPENLOG_OPTIONS, LOG_MAIL ); #else @@ -174,7 +179,7 @@ main ( int argc, char **argv ) while ( (i = getopt( argc, argv, "d:f:h:l:m:v:" )) != EOF ) { switch( i ) { case 'd': /* turn on debugging */ - debug = atoi( optarg ); + debug |= atoi( optarg ); break; case 'f': /* who it's from & where errors should go */ diff --git a/clients/rcpt500/main.c b/clients/rcpt500/main.c index 346c5fc10d..2ea4d740f2 100644 --- a/clients/rcpt500/main.c +++ b/clients/rcpt500/main.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -114,6 +115,10 @@ main( int argc, char **argv ) exit( 1 ); } +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + if ( dosyslog ) { /* * if syslogging requested, initialize diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index a9ca7f6b0c..244db3b191 100644 --- a/clients/tools/ldapdelete.c +++ b/clients/tools/ldapdelete.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -36,9 +37,9 @@ main( int argc, char **argv ) char *usage = "usage: %s [-n] [-v] [-k] [-W] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n"; char buf[ 4096 ]; FILE *fp; - int i, rc, authmethod, want_bindpw; + int i, rc, authmethod, want_bindpw, debug; - not = verbose = contoper = want_bindpw = 0; + not = verbose = contoper = want_bindpw = debug = 0; fp = NULL; authmethod = LDAP_AUTH_SIMPLE; @@ -78,7 +79,7 @@ main( int argc, char **argv ) break; case 'd': #ifdef LDAP_DEBUG - ldap_debug = lber_debug = atoi( optarg ); /* */ + debug |= atoi( optarg ); /* */ #else /* LDAP_DEBUG */ fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" ); #endif /* LDAP_DEBUG */ @@ -107,6 +108,14 @@ main( int argc, char **argv ) } } + if ( debug ) { + lber_debug = ldap_debug = debug; + } + +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) { perror( "ldap_open" ); exit( 1 ); diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 02280642a6..0545070459 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -71,7 +72,7 @@ main( int argc, char **argv ) { char *infile, *rbuf, *start, *p, *q; FILE *fp; - int rc, i, use_ldif, authmethod, want_bindpw; + int rc, i, use_ldif, authmethod, want_bindpw, debug; char *usage = "usage: %s [-abcknrvWF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n"; if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) { @@ -82,7 +83,7 @@ main( int argc, char **argv ) new = ( strcmp( prog, "ldapadd" ) == 0 ); infile = NULL; - not = verbose = valsfromfiles = want_bindpw = 0; + not = verbose = valsfromfiles = want_bindpw = debug = 0; authmethod = LDAP_AUTH_SIMPLE; while (( i = getopt( argc, argv, "WFabckKnrtvh:p:D:w:d:f:" )) != EOF ) { @@ -127,7 +128,7 @@ main( int argc, char **argv ) break; case 'd': #ifdef LDAP_DEBUG - ldap_debug = lber_debug = atoi( optarg ); /* */ + debug |= atoi( optarg ); #else /* LDAP_DEBUG */ fprintf( stderr, "%s: compile with -DLDAP_DEBUG for debugging\n", prog ); @@ -168,6 +169,13 @@ main( int argc, char **argv ) fp = stdin; } + if ( debug ) { + lber_debug = ldap_debug = debug; + } + +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif if ( !not ) { if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) { diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c index d3fa7db564..5bff7c0cd8 100644 --- a/clients/tools/ldapmodrdn.c +++ b/clients/tools/ldapmodrdn.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -38,10 +39,10 @@ main(int argc, char **argv) char *usage = "usage: %s [-nvkWc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n"; char *myname,*infile, *entrydn, *rdn, buf[ 4096 ]; FILE *fp; - int rc, i, remove, havedn, authmethod, want_bindpw; + int rc, i, remove, havedn, authmethod, want_bindpw, debug; infile = NULL; - not = contoper = verbose = remove = want_bindpw = 0; + not = contoper = verbose = remove = want_bindpw = debug = 0; authmethod = LDAP_AUTH_SIMPLE; myname = (myname = strrchr(argv[0], '/')) == NULL ? argv[0] : ++myname; @@ -76,7 +77,7 @@ main(int argc, char **argv) break; case 'd': #ifdef LDAP_DEBUG - ldap_debug = lber_debug = atoi( optarg ); /* */ + debug |= atoi( optarg ); #else /* LDAP_DEBUG */ fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" ); #endif /* LDAP_DEBUG */ @@ -131,6 +132,14 @@ main(int argc, char **argv) fp = stdin; } + if ( debug ) { + lber_debug = ldap_debug = debug; + } + +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) { perror( "ldap_open" ); exit( 1 ); diff --git a/clients/tools/ldappasswd.c b/clients/tools/ldappasswd.c index 02cd291e08..e2848a82bd 100644 --- a/clients/tools/ldappasswd.c +++ b/clients/tools/ldappasswd.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -561,6 +562,10 @@ main (int argc, char *argv[]) lber_debug = ldap_debug = debug; } +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + /* connect to server */ if ((ld = ldap_open (ldaphost, ldapport)) == NULL) { diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index 79e63c33ba..b9cdb8f760 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -90,13 +91,13 @@ char **argv; { char *infile, *filtpattern, **attrs, line[ BUFSIZ ]; FILE *fp; - int rc, i, first, scope, kerberos, deref, attrsonly; + int rc, i, first, scope, kerberos, deref, attrsonly, debug; int ldap_options, timelimit, sizelimit, authmethod; LDAP *ld; infile = NULL; deref = verbose = allow_binary = not = kerberos = vals2tmp = - attrsonly = ldif = 0; + attrsonly = ldif = debug = 0; #ifdef LDAP_REFERRALS ldap_options = LDAP_OPT_REFERRALS; @@ -125,7 +126,7 @@ char **argv; break; case 'd': #ifdef LDAP_DEBUG - ldap_debug = lber_debug = atoi( optarg ); /* */ + debug |= atoi( optarg ); #else /* LDAP_DEBUG */ fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" ); #endif /* LDAP_DEBUG */ @@ -260,6 +261,14 @@ char **argv; printf( "ldap_open( %s, %d )\n", ldaphost, ldapport ); } + if ( debug ) { + lber_debug = ldap_debug = debug; + } + +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, SIG_IGN ); +#endif + if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) { perror( ldaphost ); exit( 1 ); diff --git a/clients/ud/main.c b/clients/ud/main.c index 673b1e040d..0a22e14b03 100644 --- a/clients/ud/main.c +++ b/clients/ud/main.c @@ -95,8 +95,8 @@ main( int argc, char **argv ) switch (c) { case 'l' : #ifdef LDAP_DEBUG - ldap_debug = (int) strtol(optarg, (char **) NULL, 0); - lber_debug = ldap_debug; + ldap_debug |= (int) strtol(optarg, (char **) NULL, 0); + lber_debug |= ldap_debug; #endif break; case 'd' : @@ -151,6 +151,10 @@ main( int argc, char **argv ) printf(Version); fflush( stdout ); +#ifdef SIGPIPE + (void) SIGNAL (SIGPIPE, SIG_IGN); +#endif + initialize_client(); initialize_attribute_strings(); diff --git a/include/lber.h b/include/lber.h index b2e690681f..f4816426f0 100644 --- a/include/lber.h +++ b/include/lber.h @@ -125,9 +125,7 @@ struct berval { char *bv_val; }; -#ifdef LDAP_DEBUG extern int lber_debug; -#endif /* * in bprint.c: diff --git a/include/ldap.h b/include/ldap.h index 8b93f57c32..18f710dff8 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -41,8 +41,10 @@ LDAP_BEGIN_DECL #define LDAP_MAX_ATTR_LEN 100 /* debugging stuff */ +extern int ldap_debug; /* always available */ + #ifdef LDAP_DEBUG -extern int ldap_debug; + #ifdef LDAP_SYSLOG extern int ldap_syslog; extern int ldap_syslog_level; diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index 0a60d5ad85..90d5f33354 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -27,9 +27,7 @@ #include "lber.h" -#ifdef LDAP_DEBUG int lber_debug; -#endif static int ber_getnint LDAP_P(( BerElement *ber, long *num, int len )); diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index ef64cf3ed3..7f3c44fc9b 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -26,9 +26,7 @@ #include "ldap.h" #include "ldap-int.h" -#ifdef LDAP_DEBUG int ldap_debug; -#endif /*