Commit a3ac3be6 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Added lber_get/set_option. Removed lber_debug/ldap_debug.

Updated other codes as needed.
parent 77cb308d
......@@ -9,7 +9,7 @@ OpenLDAP Devel README
guidelines for developers
Client developers seeking a stable development platform
should use -stable.
should use -stable or the latest OpenLDAP release.
OpenLDAP 1.1 README
......
......@@ -3,7 +3,8 @@
## Makefile Template for Shared Libraries
##
LINK = $(LTLINK) -version-info $(LIBVERSION)
LTVERSION = -version-info $(LIBVERSION)
LINK = $(LTLINK)
COMPILE = $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c
MKDEPFLAG = -l
......
......@@ -49,7 +49,7 @@ MKDEP = $(top_srcdir)/build/mkdep $(MKDEPFLAG) -c "$(CC)"
LIBTOOL = @LIBTOOL@
LIBVERSION = 0:0:0
LTLINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LFLAGS)
LTLINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LFLAGS) $(LTVERSION)
LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
# Misc UNIX commands used in makefiles
......
......@@ -37,7 +37,10 @@
#include "ldapconfig.h"
#include "lber.h"
#include "ldap.h"
#define ldap_debug debug
#include "ldap_log.h"
#include "lutil.h"
#include "disptmpl.h"
......@@ -96,7 +99,7 @@ main( int argc, char **argv )
break;
case 'd': /* debug level */
debug = atoi( optarg );
debug |= atoi( optarg );
break;
case 'f': /* ldap filter file */
......@@ -156,7 +159,6 @@ main( int argc, char **argv )
}
#endif /* FD_SETSIZE*/
/* detach if stderr is redirected or no debugging */
if ( inetd == 0 )
lutil_detach( debug && !isatty( 1 ), 1 );
......@@ -166,6 +168,11 @@ main( int argc, char **argv )
else
myname = strdup( myname + 1 );
if ( debug ) {
lber_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
}
if ( dosyslog ) {
#ifdef LOG_LOCAL3
openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL3 );
......
......@@ -37,7 +37,10 @@
#include "lber.h"
#include "ldap.h"
#define ldap_debug debug
#include "ldap_log.h"
#include "lutil.h"
#include "disptmpl.h"
......@@ -110,12 +113,7 @@ main (int argc, char **argv )
break;
case 'd': /* debugging level */
debug = atoi( optarg );
#ifdef LDAP_DEBUG
ldap_debug = debug;
#else
fprintf( stderr, "warning: ldap debugging requires LDAP_DEBUG\n" );
#endif
debug |= atoi( optarg );
break;
case 'f': /* ldap filter file */
......@@ -194,6 +192,12 @@ main (int argc, char **argv )
else
myname = strdup( myname + 1 );
if ( debug ) {
lber_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
}
if ( dosyslog ) {
#ifdef LOG_LOCAL3
openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL3 );
......
......@@ -33,9 +33,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;
......@@ -74,11 +74,7 @@ main( int argc, char **argv )
}
break;
case 'd':
#ifdef LDAP_DEBUG
ldap_debug = lber_debug = atoi( optarg ); /* */
#else /* LDAP_DEBUG */
fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" );
#endif /* LDAP_DEBUG */
debug |= atoi( optarg );
break;
case 'p':
ldapport = atoi( optarg );
......@@ -104,6 +100,11 @@ main( int argc, char **argv )
}
}
if ( debug ) {
lber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug );
ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug );
}
if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) {
perror( "ldap_open" );
exit( 1 );
......
......@@ -68,7 +68,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 ) {
......@@ -79,7 +79,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 ) {
......@@ -123,12 +123,7 @@ main( int argc, char **argv )
passwd = strdup( optarg );
break;
case 'd':
#ifdef LDAP_DEBUG
ldap_debug = lber_debug = atoi( optarg ); /* */
#else /* LDAP_DEBUG */
fprintf( stderr, "%s: compile with -DLDAP_DEBUG for debugging\n",
prog );
#endif /* LDAP_DEBUG */
debug |= atoi( optarg );
break;
case 'f': /* read from file */
infile = strdup( optarg );
......@@ -165,6 +160,11 @@ main( int argc, char **argv )
fp = stdin;
}
if ( debug ) {
lber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug );
ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug );
ldif_debug = debug;
}
if ( !not ) {
if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) {
......@@ -173,7 +173,10 @@ main( int argc, char **argv )
}
/* this seems prudent */
ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
{
int deref = LDAP_DEREF_NEVER;
ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
}
if (want_bindpw)
passwd = getpass("Enter LDAP Password: ");
......
......@@ -35,10 +35,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;
......@@ -72,11 +72,7 @@ main(int argc, char **argv)
passwd = strdup( optarg );
break;
case 'd':
#ifdef LDAP_DEBUG
ldap_debug = lber_debug = atoi( optarg ); /* */
#else /* LDAP_DEBUG */
fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" );
#endif /* LDAP_DEBUG */
debug |= atoi( optarg );
break;
case 'f': /* read from file */
infile = strdup( optarg );
......@@ -128,13 +124,21 @@ main(int argc, char **argv)
fp = stdin;
}
if ( debug ) {
lber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug );
ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug );
}
if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) {
perror( "ldap_open" );
exit( 1 );
}
/* this seems prudent */
ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
{
int deref = LDAP_DEREF_NEVER;
ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
}
if (want_bindpw)
passwd = getpass("Enter LDAP Password: ");
......
......@@ -388,6 +388,7 @@ main (int argc, char *argv[])
int hashtype = HASHTYPE_CRYPT;
int i, j;
int ldapport = 0;
int debug = 0;
int scope = LDAP_SCOPE_SUBTREE;
int sizelimit = LDAP_NO_LIMIT;
int timelimit = LDAP_NO_LIMIT;
......@@ -423,11 +424,7 @@ main (int argc, char *argv[])
break;
case 'd': /* debugging option */
#ifdef LDAP_DEBUG
ldap_debug = lber_debug = atoi (optarg); /* */
#else
fprintf (stderr, "compile with -DLDAP_DEBUG for debugging\n");
#endif
debug |= atoi (optarg);
break;
case 'E': /* prompt for new password */
......@@ -565,6 +562,11 @@ main (int argc, char *argv[])
}
}
if ( debug ) {
lber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug );
ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug );
}
/* connect to server */
if ((ld = ldap_open (ldaphost, ldapport)) == NULL)
{
......@@ -576,6 +578,13 @@ main (int argc, char *argv[])
ldap_set_option (ld, LDAP_OPT_TIMELIMIT, (void *)&timelimit);
ldap_set_option (ld, LDAP_OPT_SIZELIMIT, (void *)&sizelimit);
/* this seems prudent */
{
int deref = LDAP_DEREF_NEVER;
ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
}
/* authenticate to server */
if (ldap_bind_s (ld, binddn, bindpw, authmethod) != LDAP_SUCCESS)
{
......
......@@ -87,14 +87,15 @@ main( int argc, char **argv )
char *infile, *filtpattern, **attrs, line[ BUFSIZ ];
FILE *fp;
int rc, i, first, scope, deref, attrsonly;
int referrals, timelimit, sizelimit, authmethod, want_bindpw;
int referrals, timelimit, sizelimit, debug;
int authmethod, want_bindpw;
LDAP *ld;
infile = NULL;
deref = verbose = allow_binary = not = vals2tmp =
attrsonly = ldif = want_bindpw = 0;
referrals = (int) LDAP_OPT_ON;
sizelimit = timelimit = 0;
sizelimit = timelimit = debug = 0;
scope = LDAP_SCOPE_SUBTREE;
authmethod = LDAP_AUTH_SIMPLE;
......@@ -107,11 +108,7 @@ main( int argc, char **argv )
++verbose;
break;
case 'd':
#ifdef LDAP_DEBUG
ldap_debug = lber_debug = atoi( optarg ); /* */
#else /* LDAP_DEBUG */
fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" );
#endif /* LDAP_DEBUG */
debug |= atoi( optarg );
break;
case 'k': /* use kerberos bind */
#ifdef HAVE_KERBEROS
......@@ -247,6 +244,12 @@ main( int argc, char **argv )
printf( "ldap_open( %s, %d )\n", ldaphost, ldapport );
}
if ( debug ) {
lber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug );
ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug );
ldif_debug = debug;
}
if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) {
perror( ldaphost );
exit( 1 );
......
......@@ -81,6 +81,7 @@ LDAPFiltDesc *lfdp; /* LDAP filter descriptor */
#ifdef DEBUG
int debug; /* debug flag */
#endif
int ldebug; /* library debug flag */
int
......@@ -95,14 +96,11 @@ main( int argc, char **argv )
while ((c = getopt(argc, argv, "c:d:Df:l:p:s:u:vV")) != -1) {
switch (c) {
case 'l' :
#ifdef LDAP_DEBUG
ldap_debug = (int) strtol(optarg, (char **) NULL, 0);
lber_debug = ldap_debug;
#endif
ldebug |= (int) strtol(optarg, (char **) NULL, 0);
break;
case 'd' :
#ifdef DEBUG
debug = (int) strtol(optarg, (char **) NULL, 0);
debug |= (int) strtol(optarg, (char **) NULL, 0);
#endif
break;
case 's' :
......@@ -549,6 +547,12 @@ initialize_client( void )
if (debug & D_TRACE)
printf("->initialize_client()\n");
#endif
if (ldebug) {
lber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &ldebug);
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &ldebug);
}
/*
* A per-user config file has precedence over any system-wide
* config file, if one exists.
......
......@@ -42,7 +42,6 @@ OL_ARG_ENABLE(debug,[ --enable-debug enable debugging], yes)dnl
ol_enable_syslog=no
dnl OL_ARG_ENABLE(syslog,[ --enable-syslog enable syslog support], auto)dnl
OL_ARG_ENABLE(proctitle,[ --enable-proctitle enable proctitle support], yes)dnl
OL_ARG_ENABLE(libui,[ --enable-libui enable library user interface], yes)dnl
OL_ARG_ENABLE(cache,[ --enable-cache enable caching], yes)dnl
OL_ARG_ENABLE(dns,[ --enable-dns enable V2 DNS extension], no)dnl
OL_ARG_ENABLE(referrals,[ --enable-referrals enable V2 Referrals extension], yes)dnl
......
......@@ -40,6 +40,7 @@ Modify libraries to use application specified logging routines
Modify libraries to use application specified memory allocation routines
Extend configure.in to support autodetect of ISODE features.
Port slurpd to NT
Update manual page
Small projects
......
......@@ -10,23 +10,13 @@ ber_get_next, ber_skiptag, ber_peek_tag, ber_scanf, ber_get_int, ber_get_stringb
.LP
.nf
.ft B
typedef struct berelement {
char *ber_buf;
char *ber_ptr;
char *ber_end;
struct seqorset *ber_sos;
int ber_tag;
int ber_usertag;
} BerElement;
typedef struct berelement BerElement;
.ft
.fi
.LP
.nf
.ft B
typedef struct sockbuf {
int sb_sd;
BerElement sb_ber;
} Sockbuf;
typedef struct sockbuf Sockbuf;
.ft
.fi
.LP
......
ber_get_next.3
ber_skip_tag.3
ber_peek_tag.3
ber_scanf.3
ber_get_int.3
ber_get_stringa.3
ber_get_stringb.3
ber_get_null.3
ber_get_boolean.3
ber_get_bitstring.3
ber_first_element.3
ber_next_element.3
......@@ -10,23 +10,13 @@ ber_alloc, ber_flush, ber_printf, ber_put_int, ber_put_ostring, ber_put_string,
.LP
.nf
.ft B
typedef struct berelement {
char *ber_buf;
char *ber_ptr;
char *ber_end;
struct seqorset *ber_sos;
int ber_tag;
int ber_usertag;
} BerElement;
typedef struct berelement BerElement;
.ft
.fi
.LP
.nf
.ft B
typedef struct sockbuf {
int sb_sd;
BerElement sb_ber;
} Sockbuf;
typedef struct sockbuf Sockbuf;
.ft
.fi
.LP
......
ber_alloc.3
ber_flush.3
ber_printf.3
ber_put_int.3
ber_put_ostring.3
ber_put_string.3
ber_put_null.3
ber_start_set.3
ber_put_seq.3
ber_put_set.3
......@@ -55,33 +55,42 @@ LDAP_BEGIN_DECL
#define OLD_LBER_SEQUENCE 0x10L /* w/o constructed bit - broken */
#define OLD_LBER_SET 0x11L /* w/o constructed bit - broken */
/* get/set options for BerElement */
#define LBER_SOCKBUF_OPT_TO_FILE 0x01
#define LBER_SOCKBUF_OPT_TO_FILE_ONLY 0x02
#define LBER_SOCKBUF_OPT_TO_MAX_INCOMING_SIZE 0x04
#define LBER_SOCKBUF_OPT_TO_NO_READ_AHEAD 0x08
#define LBER_SOCKBUF_OPT_TO_DESC 0x10
#define LBER_SOCKBUF_OPT_TO_COPYDESC 0x20
#define LBER_SOCKBUF_OPT_TO_READFN 0x40
#define LBER_SOCKBUF_OPT_TO_WRITE_FN 0x80
/* LBER on/off values */
#define LBER_OPT_ON ((void *) 1)
#define LBER_OPT_OFF ((void *) 0)
typedef int (*BERTranslateProc) LDAP_P(( char **bufp,
unsigned long *buflenp,
int free_input ));
/* LBER BerElement options */
#define LBER_USE_DER 0x01
#define LBER_USE_INDEFINITE_LEN 0x02
#define LBER_TRANSLATE_STRINGS 0x04
/* get/set options for BerElement */
#define LBER_OPT_BER_OPTIONS 0x01
#define LBER_OPT_BER_DEBUG 0x02
#define LBER_OPT_DEBUG_LEVEL LBER_OPT_BER_DEBUG
/* LBER Sockbuf options */
#define LBER_TO_FILE 0x01 /* to a file referenced by sb_fd */
#define LBER_TO_FILE_ONLY 0x02 /* only write to file, not network */
#define LBER_MAX_INCOMING_SIZE 0x04 /* impose limit on incoming stuff */
#define LBER_NO_READ_AHEAD 0x08 /* read only as much as requested */
/* get/set options for Sockbuf */
#define LBER_OPT_SOCKBUF_DESC 0x1000
#define LBER_OPT_SOCKBUF_OPTIONS 0x1001
#define LBER_OPT_SOCKBUF_DEBUG 0x1002
/* on/off values */
#define LBER_OPT_ON ((void *) 1)
#define LBER_OPT_OFF ((void *) 0)
#define LBER_OPT_SUCCESS 0
#define LBER_OPT_ERROR (-1)
typedef struct berelement BerElement;
#define NULLBER ((BerElement *) 0)
typedef struct sockbuf Sockbuf;
#define READBUFSIZ 8192
typedef struct seqorset Seqorset;
#define NULLSEQORSET ((Seqorset *) 0)
......@@ -92,16 +101,16 @@ struct berval {
char *bv_val;
};
#ifdef LDAP_DEBUG
extern int lber_debug;
#endif
/*
* in bprint.c:
*/
LDAP_F void ber_print_error LDAP_P(( char *data ));
LDAP_F void ber_bprint LDAP_P(( char *data, int len ));
#define lber_bprint(d,l) ber_bprint((d),(l))
#define lber_bprint(d,l) ber_bprint((d),(l))
LDAP_F void ber_dump LDAP_P(( BerElement *ber, int inout ));
LDAP_F void ber_sos_dump LDAP_P(( Seqorset *sos ));
/*
* in decode.c:
......@@ -160,19 +169,33 @@ LDAP_F BerElement *ber_alloc LDAP_P(( void ));
LDAP_F BerElement *der_alloc LDAP_P(( void ));
LDAP_F BerElement *ber_alloc_t LDAP_P(( int options ));
LDAP_F BerElement *ber_dup LDAP_P(( BerElement *ber ));
LDAP_F void ber_dump LDAP_P(( BerElement *ber, int inout ));
LDAP_F void ber_sos_dump LDAP_P(( Seqorset *sos ));
LDAP_F unsigned long ber_get_next LDAP_P(( Sockbuf *sb, unsigned long *len,
BerElement *ber ));
LDAP_F void ber_init_w_nullc LDAP_P(( BerElement *ber, int options ));
LDAP_F void ber_reset LDAP_P(( BerElement *ber, int was_writing ));
/*
* LDAP draft-ietf-ldapext-ldap-c-api-01 routines
* LBER draft-ietf-ldapext-ldap-c-api-01 routines
*/
LDAP_F BerElement *ber_init LDAP_P(( struct berval *bv ));
LDAP_F int ber_flatten LDAP_P(( BerElement *ber, struct berval **bvPtr ));
/*
* LBER ber accessor functions
*/
LDAP_F int
lber_get_option LDAP_P((void *item, int option, void *outvalue));
LDAP_F int
lber_set_option LDAP_P((void *item, int option, void *invalue));
/*
* LBER Sockbuf functions
*/
LDAP_F Sockbuf *lber_sockbuf_alloc LDAP_P((void));
LDAP_F Sockbuf *lber_sockbuf_alloc_fd LDAP_P((int fd));
LDAP_F void lber_sockbuf_free LDAP_P((Sockbuf *sb));
LDAP_END_DECL
#endif /* _LBER_H */
......@@ -85,6 +85,9 @@ LDAP_BEGIN_DECL
/* for LDAPv2 compatibility */
#define LDAP_OPT_DNS 0x1001 /* use DN & DNS */
/* OpenLDAP specific options */
#define LDAP_OPT_DEBUG_LEVEL 0x4001 /* OpenLDAP - debug level */
/* on/off values */
#define LDAP_OPT_ON ((void *) 1)
#define LDAP_OPT_OFF ((void *) 0)
......@@ -92,10 +95,6 @@ LDAP_BEGIN_DECL
#define LDAP_OPT_SUCCESS 0
#define LDAP_OPT_ERROR (-1)
#ifdef LDAP_DEBUG
extern int ldap_debug;
#endif
#define LDAP_API_INFO_VERSION 1
typedef struct ldapapiinfo {
int ldapai_info_version; /* version of LDAPAPIInfo (1) */
......
......@@ -19,25 +19,31 @@ LDAP_BEGIN_DECL
/* debugging stuff */
#ifdef LDAP_DEBUG
#ifndef ldap_debug
extern int ldap_debug;
#endif /* !ldap_debug */
#ifdef LDAP_SYSLOG
extern int ldap_syslog;
extern int ldap_syslog_level;
#endif /* LDAP_SYSLOG */
#define LDAP_DEBUG_TRACE 0x001
#define LDAP_DEBUG_PACKETS 0x002
#define LDAP_DEBUG_ARGS 0x004
#define LDAP_DEBUG_CONNS 0x008
#define LDAP_DEBUG_BER 0x010
#define LDAP_DEBUG_FILTER 0x020
#define LDAP_DEBUG_CONFIG 0x040
#define LDAP_DEBUG_ACL 0x080
#define LDAP_DEBUG_STATS 0x100
#define LDAP_DEBUG_STATS2 0x200
#define LDAP_DEBUG_SHELL 0x400