]> git.sur5r.net Git - openldap/commitdiff
struct ldap is now opaque to clients.
authorKurt Zeilenga <kurt@openldap.org>
Wed, 4 Nov 1998 01:41:00 +0000 (01:41 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 4 Nov 1998 01:41:00 +0000 (01:41 +0000)
updated clients to use ldap_get/set_options
ld_options is renamed ld_booleans.  ldap-int.h has accessor macros.
updated libldap to use new accessor macros.

35 files changed:
clients/fax500/main.c
clients/fax500/rp500.c
clients/finger/main.c
clients/gopher/Makefile.in
clients/gopher/go500.c
clients/gopher/go500gw.c
clients/gopher/setproctitle.c [deleted file]
clients/mail500/main.c
clients/rcpt500/query.c
clients/tools/ldapmodify.c
clients/tools/ldapmodrdn.c
clients/tools/ldapsearch.c
clients/ud/auth.c
clients/ud/find.c
clients/ud/group.c
clients/ud/main.c
clients/ud/mod.c
clients/ud/ud.h
include/ldap.h
libraries/liblber/decode.c
libraries/liblber/encode.c
libraries/libldap/Makefile.in
libraries/libldap/init.c [new file with mode: 0644]
libraries/libldap/ldap-int.h
libraries/libldap/open.c
libraries/libldap/options.c [new file with mode: 0644]
libraries/libldap/result.c
libraries/libldap/test.c
libraries/libldap/tmplout.c
servers/ldapd/main.c
servers/ldapd/setproctitle.c [deleted file]
servers/slapd/slap.h
servers/slurpd/ldap_op.c
servers/slurpd/ri.c
servers/slurpd/slurp.h

index 7f526dd794c943b4b818b60f2b32ec7a760af384..da4d63b9d940761e06887e01ca5278bd7160e8b9 100644 (file)
 #include "lber.h"
 #include "ldap.h"
 
-#if LDAP_VERSION < LDAP_VERSION3
-/* quick fix until we have ldap_set_options */
-#include "../libraries/libldap/ldap-int.h"
-#endif
-
 #include <ldapconfig.h>
 
 #define USER           0
@@ -310,12 +305,16 @@ char      **argv;
 
 connect_to_x500()
 {
+       int sizelimit = FAX_MAXAMBIGUOUS;
+       int deref = LDAP_DEREF_ALWAYS;
+
        if ( (ld = ldap_open( LDAPHOST, LDAP_PORT )) == NULL ) {
                syslog( LOG_ALERT, "ldap_open failed" );
                return( -1 );
        }
-       ld->ld_sizelimit = FAX_MAXAMBIGUOUS;
-       ld->ld_deref = LDAP_DEREF_ALWAYS;
+
+       ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &sizelimit);
+       ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
 
        if ( ldap_simple_bind_s( ld, FAX_BINDDN, FAX_BIND_CRED ) != LDAP_SUCCESS ) {
                syslog( LOG_ALERT, "ldap_simple_bind_s failed" );
@@ -685,7 +684,10 @@ do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
                timeout.tv_usec = 0;
 
                /* for each subtree to look in... */
-               ld->ld_sizelimit = FAX_MAXMEMBERS;
+               {
+                       int sizelimit = FAX_MAXMEMBERS;
+                       ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &sizelimit);
+               }       
                for ( i = 0; base[i].b_dn != NULL; i++ ) {
                        /* find entries that have joined this group... */
                        rc = ldap_search_st( ld, base[i].b_dn,
@@ -784,7 +786,10 @@ do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
 
                        ldap_msgfree( res );
                }
-               ld->ld_sizelimit = FAX_MAXAMBIGUOUS;
+               {
+                       int sizelimit = FAX_MAXAMBIGUOUS;
+                       ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &sizelimit);
+               }       
        }
 
        return;
index f29f23fab6f07a60c03c10d0b62320e284a79d6c..df4271b25daa58da9e0b52c1640ba45717b5b0c2 100644 (file)
 #include <lber.h>
 #include <ldap.h>
 
-#if LDAP_VERSION < LDAP_VERSION3
-/* quick fix until we have ldap_set_options */
-#include "../libraries/libldap/ldap-int.h"
-#endif
-
 #include <ldapconfig.h>
 
 #define DEFAULT_PORT           79
@@ -39,8 +34,8 @@
 int            debug;
 char   *ldaphost = LDAPHOST;
 char   *base = RP_BASE;
-int            deref;
-int            sizelimit;
+int            deref = LDAP_DEREF_ALWAYS;
+int            sizelimit = DEFAULT_SIZELIMIT;
 LDAPFiltDesc   *filtd;
 
 static print_entry();
@@ -72,7 +67,6 @@ main (argc, argv)
        extern char     *optarg;
        extern int      optind;
 
-       deref = LDAP_DEREF_ALWAYS;
        while ( (i = getopt( argc, argv, "ab:d:f:x:z:" )) != EOF ) {
                switch( i ) {
                case 'a':       /* do not deref aliases when searching */
@@ -118,8 +112,9 @@ main (argc, argv)
                perror( "ldap_open" );
                exit( -1 );
        }
-       ld->ld_sizelimit = sizelimit ? sizelimit : DEFAULT_SIZELIMIT;
-       ld->ld_deref = deref;
+
+       ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &sizelimit);
+       ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
 
        if ( ldap_simple_bind_s( ld, RP_BINDDN, RP_BIND_CRED ) != LDAP_SUCCESS ) {
                fprintf( stderr, "X.500 is temporarily unavailable.\n" );
@@ -129,7 +124,8 @@ main (argc, argv)
 
        result = NULL;
        if ( strchr( key, ',' ) != NULL ) {
-               ld->ld_deref = LDAP_DEREF_FINDING;
+               int ld_deref = LDAP_DEREF_FINDING;
+               ldap_set_option(ld, LDAP_OPT_DEREF, &ld_deref);
                if ( (rc = ldap_ufn_search_s( ld, key, attrs, 0, &result ))
                    != LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED &&
                    rc != LDAP_TIMELIMIT_EXCEEDED )
index be4e7778caeaf8ee075bbec2d408b720966ff9f8..739f56abe9c5bbf286809021023e684ecb95d76f 100644 (file)
 #include "lber.h"
 #include "ldap.h"
 
-#if LDAP_VERSION < LDAP_VERSION3
-/* quick fix until we have ldap_set_options */
-#include "../libraries/libldap/ldap-int.h"
-#endif
-
 #include "disptmpl.h"
 
 #include "ldapconfig.h"
@@ -165,8 +160,12 @@ static do_query()
                perror( "ldap_open" );
                exit( 1 );
        }
-       ld->ld_sizelimit = FINGER_SIZELIMIT;
-       ld->ld_deref = deref;
+
+       {
+               int limit = FINGER_SIZELIMIT;
+               ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &limit);
+       }
+       ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
 
        if ( ldap_simple_bind_s( ld, FINGER_BINDDN, FINGER_BIND_CRED )
                != LDAP_SUCCESS )
@@ -258,6 +257,7 @@ char        *buf;
        char            **title;
        int             rc, matches, i, ufn;
        struct timeval  tv;
+       LDAPFiltDesc    *fd;
        LDAPFiltInfo    *fi;
        LDAPMessage     *result, *e;
        static char     *attrs[] = { "cn", "title", "objectClass", "joinable",
@@ -286,16 +286,16 @@ char      *buf;
                ufn = 1;
        } else {
 #endif
-               if ( (ld->ld_filtd = ldap_init_getfilter( filterfile ))
+               if ( (fd = ldap_init_getfilter( filterfile ))
                    == NULL ) {
                        fprintf( stderr, "Cannot open filter file (%s)\n",
                            filterfile );
                        exit( 1 );
                }
 
-               for ( fi = ldap_getfirstfilter( ld->ld_filtd, "finger", buf );
+               for ( fi = ldap_getfirstfilter( fd, "finger", buf );
                    fi != NULL;
-                   fi = ldap_getnextfilter( ld->ld_filtd ) )
+                   fi = ldap_getnextfilter( fd ) )
                {
                        tv.tv_sec = FINGER_TIMEOUT;
                        tv.tv_usec = 0;
index d6f4aacf8e367635d894da37d0e40491fc9abf35..baa5437cb0b2055898a087405ce00826e8dc8920 100644 (file)
@@ -3,14 +3,15 @@
 ##
 PROGRAMS= go500gw go500
 
-SRCS=  detach.c go500.c go500gw.c setproctitle.c
+SRCS=  detach.c go500.c go500gw.c 
 XSRCS= gwversion.o goversion.o
-GOOBJS =  go500.o detach.o setproctitle.o
-GWOBJS =  go500gw.o detach.o setproctitle.o
+GOOBJS =  go500.o detach.o
+GWOBJS =  go500gw.o detach.o
 
 LDAP_INCDIR= ../../include
 LDAP_LIBDIR= ../../libraries
 
+XLIBS = -llutil @LUTIL_LIBS@
 
 go500 : goversion.o
        $(CC) $(LDFLAGS) -o $@ $(GOOBJS) goversion.o $(LIBS)
index bbd64abefed641be2cee7a96655fae3455839391..3a951d9a6f06b944ba03d1db48e1bc027c4431b4 100644 (file)
@@ -23,6 +23,8 @@
 #include <ac/unistd.h>
 #include <ac/wait.h>
 
+#include <ac/setproctitle.h>
+
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
 #include "ldapconfig.h"
 #include "lber.h"
 #include "ldap.h"
-
-#if LDAP_VERSION < LDAP_VERSION3
-/* quick fix until we have ldap_set_options */
-#include "../libraries/libldap/ldap-int.h"
-#endif
+#include "ldap_log.h"
 
 #include "disptmpl.h"
 
@@ -83,12 +81,12 @@ char        **argv;
        int                     fromlen;
        RETSIGTYPE                      wait4child();
        extern char             *optarg;
-       extern char             **Argv;
-       extern int              Argc;
 
+#if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
        /* for setproctitle */
-        Argv = argv;
-        Argc = argc;
+       Argv = argv;
+       Argc = argc;
+#endif
 
        while ( (i = getopt( argc, argv, "b:d:f:lp:c:t:x:I" )) != EOF ) {
                switch( i ) {
@@ -201,8 +199,10 @@ char       **argv;
                                    inet_ntoa( from.sin_addr ) );
                        }
 
+#ifdef LDAP_PROCTITLE
                        setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
                            hp->h_name );
+#endif
                }
 
                do_queries( 0 );
@@ -387,7 +387,11 @@ int        s;
                        exit( 1 );
                }
 
-               ld->ld_deref = GO500_DEREF;
+               {
+                       int deref = GO500_DEREF;
+                       ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
+               }
+
                if ( (rc = ldap_simple_bind_s( ld, GO500_BINDDN, GO500_BIND_CRED ))
                    != LDAP_SUCCESS ) {
                        fprintf(fp,
index 0fa939cccd3e0139c18de8c736609dfd5e1dd5dc..3a0dab6775a71e63296c19c61607a0577d42dda4 100644 (file)
@@ -23,6 +23,8 @@
 #include <ac/unistd.h>
 #include <ac/wait.h>
 
+#include <ac/setproctitle.h>
+
 #include <sys/resource.h>
 
 #ifdef HAVE_SYS_PARAM_H
 
 #include "lber.h"
 #include "ldap.h"
-
-#if LDAP_VERSION < LDAP_VERSION3
-/* quick fix until we have ldap_set_options */
-#include "../libraries/libldap/ldap-int.h"
-#endif
+#include "ldap_log.h"
 
 #include "disptmpl.h"
 
@@ -91,12 +89,12 @@ char        **argv;
        int                     fromlen;
        RETSIGTYPE                      wait4child();
        extern char             *optarg;
-       extern char             **Argv;
-       extern int              Argc;
 
+#if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
        /* for setproctitle */
-        Argv = argv;
-        Argc = argc;
+       Argv = argv;
+       Argc = argc;
+#endif
 
        while ( (i = getopt( argc, argv, "P:ad:f:h:lp:t:x:Ic:" )) != EOF ) {
                switch( i ) {
@@ -223,8 +221,10 @@ char       **argv;
                                    inet_ntoa( from.sin_addr ) );
                        }
 
+#ifdef LDAP_PROCTITLE
                        setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
                            hp->h_name );
+#endif
                }
 
                do_queries( 0 );
@@ -355,6 +355,7 @@ int s;
        int             len;
        FILE            *fp;
        int             rc;
+       int             deref;
        struct timeval  timeout;
        fd_set          readfds;
        LDAP            *ld;
@@ -432,9 +433,11 @@ int        s;
                exit( 1 );
        }
 
-       ld->ld_deref = LDAP_DEREF_ALWAYS;
+       deref = LDAP_DEREF_ALWAYS;
        if ( !searchaliases )
-               ld->ld_deref = LDAP_DEREF_FINDING;
+               deref = LDAP_DEREF_FINDING;
+
+       ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
 
        if ( (rc = ldap_simple_bind_s( ld, GO500GW_BINDDN, NULL ))
            != LDAP_SUCCESS ) {
@@ -521,14 +524,16 @@ char      *dn;
                struct timeval  timeout;
                LDAPMessage     *res = NULL;
                static char     *attrs[] = { "objectClass", 0 };
+               int sizelimit = 1;
 
                timeout.tv_sec = GO500GW_TIMEOUT;
                timeout.tv_usec = 0;
-               ld->ld_sizelimit = 1;
+               ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &sizelimit);
                if ( (rc = ldap_search_st( ld, dn, LDAP_SCOPE_ONELEVEL,
                    "(objectClass=*)", attrs, 0, &timeout, &res ))
                    == LDAP_SUCCESS || rc == LDAP_SIZELIMIT_EXCEEDED ) {
-                       ld->ld_sizelimit = LDAP_NO_LIMIT;
+                       sizelimit = LDAP_NO_LIMIT;
+                       ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &sizelimit);
 
                        numentries = ldap_count_entries( ld, res );
                        if ( res != NULL )
@@ -584,10 +589,13 @@ char      *dn;
        struct timeval  timeout;
        FriendlyMap     *fm = NULL;
        static char     *attrs[] = { "objectClass", 0 };
+       int deref = LDAP_DEREF_FINDING;
 
        timeout.tv_sec = GO500GW_TIMEOUT;
        timeout.tv_usec = 0;
-       ld->ld_deref = LDAP_DEREF_FINDING;
+
+       ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
+
        if ( (rc = ldap_search_st( ld, dn, LDAP_SCOPE_ONELEVEL,
            "(!(objectClass=dSA))", attrs, 0, &timeout, &res )) != LDAP_SUCCESS
            && rc != LDAP_SIZELIMIT_EXCEEDED ) {
@@ -595,7 +603,9 @@ char        *dn;
                    rc, myhost, myport );
                return;
        }
-       ld->ld_deref = LDAP_DEREF_ALWAYS;
+
+       deref = LDAP_DEREF_ALWAYS;
+       ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
 
        if ( ldap_count_entries( ld, res ) < 1 ) {
                return;
@@ -699,6 +709,7 @@ LDAP        *ld;
 FILE   *fp;
 char   *query;
 {
+       int deref;
        int             scope;
        char            *base, *filter;
        char            *filtertype;
@@ -722,7 +733,9 @@ char        *query;
                timeout.tv_sec = GO500GW_TIMEOUT;
                timeout.tv_usec = 0;
                ldap_ufn_timeout( (void *) &timeout );
-               ld->ld_deref = LDAP_DEREF_FINDING;
+
+               deref = LDAP_DEREF_FINDING;
+               ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
 
                if ( (rc = ldap_ufn_search_s( ld, filter, attrs, 0, &res ))
                    != LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED ) {
@@ -742,8 +755,9 @@ char        *query;
 
                filtertype = (scope == LDAP_SCOPE_ONELEVEL ?
                    "go500gw onelevel" : "go500gw subtree");
-               ld->ld_deref = (scope == LDAP_SCOPE_ONELEVEL ?
+               deref = (scope == LDAP_SCOPE_ONELEVEL ?
                    LDAP_DEREF_FINDING : LDAP_DEREF_ALWAYS);
+               ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
                timeout.tv_sec = GO500GW_TIMEOUT;
                timeout.tv_usec = 0;
 
@@ -768,7 +782,8 @@ char        *query;
                        if ( (count = ldap_count_entries( ld, res )) != 0 )
                                break;
                }
-               ld->ld_deref = LDAP_DEREF_ALWAYS;
+               deref = LDAP_DEREF_ALWAYS;
+               ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
                ldap_getfilter_free( filtd );
 #ifdef GO500GW_UFN
        }
@@ -847,9 +862,12 @@ char       *dn;
        if ( ldap_entry2text_search( ld, dn, NULL, NULL, tmpllist, NULL, NULL,
            entry2textwrite,(void *) fp, "\r\n", rdncount, 0 )
            != LDAP_SUCCESS ) {
+               int ld_errno = 0;
+               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+
                fprintf(fp,
                    "0An error occurred (explanation)\t@%d\t%s\t%d\r\n",
-                   ld->ld_errno, myhost, myport );
+                   ld_errno, myhost, myport );
        }
 
        if ( tmpllist != NULL ) {
diff --git a/clients/gopher/setproctitle.c b/clients/gopher/setproctitle.c
deleted file mode 100644 (file)
index 555b8a9..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1990,1991 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include "portable.h"
-
-char   **Argv;         /* pointer to original (main's) argv */
-int    Argc;           /* original argc */
-
-/*
- * takes a printf-style format string (fmt) and up to three parameters (a,b,c)
- * this clobbers the original argv...
- */
-
-/* VARARGS */
-setproctitle( fmt, a, b, c )
-char *fmt;
-char *a, *b, *c;
-{
-       static char *endargv = (char *)0;
-       char    *s;
-       int             i;
-       char    buf[ 1024 ];
-
-       if ( endargv == (char *)0 ) {
-               /* set pointer to end of original argv */
-               endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
-       }
-       sprintf( buf, fmt, a, b, c );
-       /* make ps print "([prog name])" */
-       s = Argv[0];
-       *s++ = '-';
-       i = strlen( buf );
-       if ( i > endargv - s - 2 ) {
-               i = endargv - s - 2;
-               buf[ i ] = '\0';
-       }
-       strcpy( s, buf );
-       s += i;
-       while ( s < endargv ) *s++ = ' ';
-}
index a994d52fc4725c0c748689384972ad2bf85029ef..d7cfe3e62fa0ff66caf4cba5147e1652ac56f867 100644 (file)
 #include "lber.h"
 #include "ldap.h"
 
-#if LDAP_VERSION < LDAP_VERSION3
-/* quick fix until we have ldap_set_options */
-#include "../libraries/libldap/ldap-int.h"
-#endif
-
 #include "ldapconfig.h"
 
 #define USER           0x01
@@ -345,12 +340,17 @@ char      **argv;
 
 connect_to_x500()
 {
+       int opt;
+
        if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
                syslog( LOG_ALERT, "ldap_open failed" );
                return( -1 );
        }
-       ld->ld_sizelimit = MAIL500_MAXAMBIGUOUS;
-       ld->ld_deref = LDAP_DEREF_ALWAYS;
+
+       opt = MAIL500_MAXAMBIGUOUS;
+       ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &opt);
+       opt = LDAP_DEREF_ALWAYS;
+       ldap_set_option(ld, LDAP_OPT_DEREF, &opt);
 
        if ( ldap_simple_bind_s( ld, MAIL500_BINDDN, NULL ) != LDAP_SUCCESS ) {
                syslog( LOG_ALERT, "ldap_simple_bind_s failed" );
@@ -774,6 +774,7 @@ do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
        char            filter[1024];
        LDAPMessage     *ee, *res;
        struct timeval  timeout;
+       int             opt;
 
        /*
         * if all has gone according to plan, we've already arranged for
@@ -832,7 +833,8 @@ do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
                timeout.tv_usec = 0;
 
                /* for each subtree to look in... */
-               ld->ld_sizelimit = MAIL500_MAXGROUPMEMBERS;
+               opt = MAIL500_MAXAMBIGUOUS;
+               ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &opt);
                for ( i = 0; base[i].b_dn != NULL; i++ ) {
                        /* find entries that have joined this group... */
                        rc = ldap_search_st( ld, base[i].b_dn,
@@ -892,7 +894,8 @@ do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
 
                        ldap_msgfree( res );
                }
-               ld->ld_sizelimit = MAIL500_MAXAMBIGUOUS;
+               opt = MAIL500_MAXAMBIGUOUS;
+               ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &opt);
        }
 
        if ( ! anymembers ) {
index aac3e2253224aefff8d8b80ddf538e14f360c92f..fe9c7e88e8954e5b89cfdf09a374ffc4a5aff261 100644 (file)
 #include "lber.h"
 #include "ldap.h"
 
-#if LDAP_VERSION < LDAP_VERSION3
-/* quick fix until we have ldap_set_options */
-#include "../libraries/libldap/ldap-int.h"
-#endif
-
 #include "disptmpl.h"
 
 #include "rcpt500.h"
@@ -56,7 +51,7 @@ query_cmd( msgp, reply )
     LDAP                       *ldp;
     LDAPMessage                        *ldmsgp, *entry;
     char                       *s, *dn;
-    int                                matches, rc, ufn;
+    int                                matches, rc, ld_errno, ufn;
     LDAPFiltDesc               *lfdp;
     LDAPFiltInfo               *lfi;
     struct ldap_disptmpl       *tmpllist = NULL;
@@ -113,8 +108,8 @@ query_cmd( msgp, reply )
     /*
      * set options for search and build filter
      */
-    ldp->ld_deref = derefaliases;
-    ldp->ld_sizelimit = sizelimit;
+       ldap_set_option(ldp, LDAP_OPT_DEREF, &derefaliases);
+       ldap_set_option(ldp, LDAP_OPT_SIZELIMIT, &sizelimit);
 
     matches = 0;
 
@@ -179,8 +174,11 @@ query_cmd( msgp, reply )
        return( 0 );
     }
 
-    if ( ldp->ld_errno == LDAP_TIMELIMIT_EXCEEDED
-           || ldp->ld_errno == LDAP_SIZELIMIT_EXCEEDED ) {
+       ld_errno = 0;
+       ldap_get_option(ldp, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+
+    if ( ld_errno == LDAP_TIMELIMIT_EXCEEDED
+           || ld_errno == LDAP_SIZELIMIT_EXCEEDED ) {
        strcat( reply, "(Partial results only - a limit was exceeded)\n" );
     }
 
@@ -339,8 +337,11 @@ report_ldap_err( ldp, reply )
     LDAP       *ldp;
     char       *reply;
 {
+       int ld_errno = 0;
+       ldap_get_option(ldp, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+
     strcat( reply, errpreface );
-    strcat( reply, ldap_err2string( ldp->ld_errno ));
+    strcat( reply, ldap_err2string( ld_errno ));
     strcat( reply, "\n" );
 }
 
index fcceca84615375d0156e9a65634af77503dec463..9e8546248d946d0b41edbaf91b8291ff8372e3ed 100644 (file)
@@ -168,10 +168,8 @@ main( int argc, char **argv )
            exit( 1 );
        }
 
-#if LDAP_VERSION > LDAP_VERSION2
        /* this seems prudent */
-       ldap_set_option( LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
-#endif
+       ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
 
        if ( !kerberos ) {
            authmethod = LDAP_AUTH_SIMPLE;
index d2450103b947345129f04cf0bf7a4a0e83f46cec..bbfead056c5934cb2e0433c4a5993cdc577d603a 100644 (file)
@@ -131,10 +131,8 @@ main( argc, argv )
        exit( 1 );
     }
 
-#if LDAP_VERSION > LDAP_VERSION2
        /* this seems prudent */
-       ldap_set_option( LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
-#endif
+       ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
 
     if ( !kerberos ) {
        authmethod = LDAP_AUTH_SIMPLE;
index 314af0e3ec8bbc0ac6c40092cec80ea76f954ad7..a73f0c6bf19983d588572739135f6f8254fc2466 100644 (file)
 #include <ldap.h>
 #include <ldif.h>
 
-#if LDAP_VERSION == LDAP_VERSION2
-/* until we implement ldap_set_options() */
-#include "../libraries/libldap/ldap-int.h"
-#endif
-
 #include "ldapconfig.h"
 
 #define DEFSEP         "="
@@ -98,7 +93,7 @@ char  **argv;
     char               *infile, *filtpattern, **attrs, line[ BUFSIZ ];
     FILE               *fp;
     int                        rc, i, first, scope, kerberos, deref, attrsonly;
-    int                        ldap_options, timelimit, sizelimit, authmethod;
+    int                        referrals, timelimit, sizelimit, authmethod;
     LDAP               *ld;
     extern char                *optarg;
     extern int         optind;
@@ -106,11 +101,7 @@ char       **argv;
     infile = NULL;
     deref = verbose = allow_binary = not = kerberos = vals2tmp =
            attrsonly = ldif = 0;
-#ifdef LDAP_REFERRALS
-    ldap_options = LDAP_OPT_REFERRALS;
-#else /* LDAP_REFERRALS */
-    ldap_options = 0;
-#endif /* LDAP_REFERRALS */
+    referrals = (int) LDAP_OPT_ON;
     sizelimit = timelimit = 0;
     scope = LDAP_SCOPE_SUBTREE;
 
@@ -150,12 +141,7 @@ char       **argv;
            ++vals2tmp;
            break;
        case 'R':       /* don't automatically chase referrals */
-#ifdef LDAP_REFERRALS
-           ldap_options &= ~LDAP_OPT_REFERRALS;
-#else /* LDAP_REFERRALS */
-           fprintf( stderr,
-                   "compile with -DLDAP_REFERRALS for referral support\n" );
-#endif /* LDAP_REFERRALS */
+               referrals = (int) LDAP_OPT_OFF;
            break;
        case 'A':       /* retrieve attribute names only -- no values */
            ++attrsonly;
@@ -270,10 +256,18 @@ char      **argv;
        exit( 1 );
     }
 
-    ld->ld_deref = deref;
-    ld->ld_timelimit = timelimit;
-    ld->ld_sizelimit = sizelimit;
-    ld->ld_options = ldap_options;
+       if (ldap_set_option( ld, LDAP_OPT_DEREF, (void *) &deref ) == -1 ) {
+               /* set option error */
+       }
+       if (ldap_set_option( ld, LDAP_OPT_TIMELIMIT, (void *) &timelimit ) == -1 ) {
+               /* set option error */
+       }
+       if (ldap_set_option( ld, LDAP_OPT_SIZELIMIT, (void *) &sizelimit ) == -1 ) {
+               /* set option error */
+       }
+       if (ldap_set_option( ld, LDAP_OPT_REFERRALS, (void *) referrals ) == -1 ) {
+               /* set option error */
+       }
 
     if ( !kerberos ) {
        authmethod = LDAP_AUTH_SIMPLE;
@@ -349,7 +343,11 @@ static int dosearch(
 
     if ( ldap_search( ld, base, scope, filter, attrs, attrsonly ) == -1 ) {
        ldap_perror( ld, "ldap_search" );
-       return( ld->ld_errno );
+#ifdef HAVE_LDERRNO
+       return( ldap_lderrno(ld) );
+#else
+       return( -1 );
+#endif
     }
 
     matches = 0;
index 8f14aa7a2fc069b7578c59607cf3fbfd23cf7263..44b74d824f382ce12ee8f6ffadf8702c4c36995a 100644 (file)
@@ -240,9 +240,11 @@ int implicit;
        ldap_flush_cache( ld );
        rc = ldap_bind_s(ld, Entry.DN, passwd, authmethod);
        if (rc != LDAP_SUCCESS) {
-               if (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE)
+               int ld_errno;
+               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+               if (ld_errno == LDAP_NO_SUCH_ATTRIBUTE)
                        fprintf(stderr, "  Entry has no password\n");
-               else if (ld->ld_errno == LDAP_INVALID_CREDENTIALS)
+               else if (ld_errno == LDAP_INVALID_CREDENTIALS)
 #ifdef HAVE_KERBEROS
                        if ( authmethod == LDAP_AUTH_KRBV4 ) {
                                fprintf(stderr, "  The Kerberos credentials are invalid.\n");
index e7ad965c508aadd4a131a26f4049771fc5927b28..334ce9db907daf68d437788824eddee0dc72ade7 100644 (file)
@@ -38,6 +38,7 @@ char *dn;
 {
        LDAPMessage *results;
        static char *attrs[2] = { "objectClass", NULL };
+       int ld_errno = 0;
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -46,9 +47,12 @@ char *dn;
        /* verify that this DN exists in the directory */
        (void) ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", attrs, TRUE, &results);
        (void) ldap_msgfree(results);
-       if ((ld->ld_errno == LDAP_NO_SUCH_OBJECT) || (ld->ld_errno == LDAP_INVALID_DN_SYNTAX))
+
+       ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+
+       if ((ld_errno == LDAP_NO_SUCH_OBJECT) || (ld_errno == LDAP_INVALID_DN_SYNTAX))
                return(0);
-       else if (ld->ld_errno == LDAP_SUCCESS)
+       else if (ld_errno == LDAP_SUCCESS)
                return(1);
        else {
                ldap_perror(ld, "ldap_search");
@@ -69,6 +73,7 @@ char *who;
        char response[SMALL_BUF_SIZE];  /* results from user */
        char *name = NULL;              /* DN to lookup */
        LDAPMessage *mp;
+       int ld_errno = 0;
        extern void Free();
 
 #ifdef DEBUG
@@ -76,11 +81,14 @@ char *who;
                printf("->disambiguate(%x, %d, %x, %s)\n", result, matches, 
                                                        read_attrs, who);
 #endif
+
+       ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+
        /*
         *  If we are here, it means that we got back multiple answers.
         */
-       if ((ld->ld_errno == LDAP_TIMELIMIT_EXCEEDED)
-           || (ld->ld_errno == LDAP_SIZELIMIT_EXCEEDED)) {
+       if ((ld_errno == LDAP_TIMELIMIT_EXCEEDED)
+           || (ld_errno == LDAP_SIZELIMIT_EXCEEDED)) {
                if (verbose) {
                        printf("  Your query was too general and a limit was exceeded.  The results listed\n");
                        printf("  are not complete.  You may want to try again with a more refined query.\n\n");
@@ -206,39 +214,43 @@ int quiet;
         *  here.  If we don't find it, treat it as NOT a UFN.
         */
        if (strchr(who, ',') != NULL) {
-               int     savederef;
+               int     savederef, deref;
 #ifdef DEBUG
                if (debug & D_FIND)
                        printf("\"%s\" appears to be a UFN\n", who);
 #endif
-               savederef = ld->ld_deref;
-               ld->ld_deref = LDAP_DEREF_FINDING;
+               ldap_get_option(ld, LDAP_OPT_DEREF, &savederef);
+               deref = LDAP_DEREF_FINDING;
+               ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
+
                if ((rc = ldap_ufn_search_s(ld, who, search_attrs, FALSE, &res)) !=
                    LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED &&
                    rc != LDAP_TIMELIMIT_EXCEEDED) {
                        ldap_perror(ld, "ldap_ufn_search_s");
-                       ld->ld_deref = savederef;
+                       ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
                        return(NULL);
                }
                if ((matches = ldap_count_entries(ld, res)) < 0) {
                        ldap_perror(ld, "ldap_count_entries");
-                       ld->ld_deref = savederef;
+                       ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
                        return(NULL);
                } else if (matches == 1) {
                        if (ldap_search_s(ld, ldap_get_dn(ld, ldap_first_entry(ld, res)), LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res) != LDAP_SUCCESS) {
-                               if (ld->ld_errno == LDAP_UNAVAILABLE)
+                               int ld_errno = 0;
+                               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+                               if (ld_errno == LDAP_UNAVAILABLE)
                                        printf("  Could not contact the LDAP server to find \"%s\".\n", who);
                                else
                                        ldap_perror(ld, "ldap_search_s");
                                return(NULL);
                        }
-                       ld->ld_deref = savederef;
+                       ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
                        return(res);
                } else if (matches > 1 ) {
                        return( disambiguate( ld, res, matches, read_attrs,
                            who ) );
                }
-               ld->ld_deref = savederef;
+               ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
        }
 
        /*
@@ -419,7 +431,9 @@ char *group;
 
        sprintf(filter, "%s=%s", "memberOfGroup", group);
        if (ldap_search_s(ld, search_base, LDAP_SCOPE_SUBTREE, filter, attributes, FALSE, &result) != LDAP_SUCCESS) {
-               if (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE)
+               int ld_errno = 0;
+               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+               if (ld_errno == LDAP_NO_SUCH_ATTRIBUTE)
                        return(0);
                ldap_perror(ld, "ldap_search_s");
                return(0);
@@ -461,7 +475,9 @@ struct attribute attr;
 #endif
        attributes[0] = attr.quipu_name;
        if (ldap_search_s(ld, who, LDAP_SCOPE_BASE, "objectClass=*", attributes, FALSE, &result) != LDAP_SUCCESS) {
-               if (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE)
+               int ld_errno = 0;
+               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+               if (ld_errno == LDAP_NO_SUCH_ATTRIBUTE)
                        return("FALSE");
                ldap_perror(ld, "ldap_search_s");
                ldap_msgfree(result);
index eee8a6b6215c59d9376e5a796281fdb6ab0670a9..a573d19e5b97c30a6098fa853fac687b4a7cf773 100644 (file)
@@ -235,7 +235,9 @@ char *name;
         *  Now remove this from the LDAP Directory.
         */
        if (ldap_delete_s(ld, dn) != 0) {
-               if (ld->ld_errno == LDAP_INSUFFICIENT_ACCESS)
+               int ld_errno = 0;
+               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+               if (ld_errno == LDAP_INSUFFICIENT_ACCESS)
                        printf("  You do not own the group \"%s\".\n", name);
                else
                        ldap_perror(ld, "  ldap_delete_s");
@@ -326,9 +328,11 @@ char *name;
 #endif
 
        if (ldap_modify_s(ld, bound_dn, mods)) {
-               if ((action == G_JOIN) && (ld->ld_errno == LDAP_TYPE_OR_VALUE_EXISTS))
+               int ld_errno = 0;
+               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+               if ((action == G_JOIN) && (ld_errno == LDAP_TYPE_OR_VALUE_EXISTS))
                        printf("  You are already subscribed to \"%s\"\n", group_name);
-               else if ((action == G_RESIGN) && (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE))
+               else if ((action == G_RESIGN) && (ld_errno == LDAP_NO_SUCH_ATTRIBUTE))
                        printf("  You are not subscribed to \"%s\"\n", group_name);
                else
                        mod_perror(ld);
@@ -928,7 +932,9 @@ int offset;
 #endif
 
                if (my_ldap_modify_s(ld, group, mods)) {
-                       if (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE) {
+                       int ld_errno = 0;
+                       ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+                       if (ld_errno == LDAP_NO_SUCH_ATTRIBUTE) {
                                printf("  Could not locate value \"%s\"\n", 
                                                                new_value);
                                continue;
@@ -987,7 +993,9 @@ int offset;
                                *  A "No such attribute" error is no big deal.
                                *  We only wanted to clear the attribute anyhow.
                                */
-                               if (ld->ld_errno != LDAP_NO_SUCH_ATTRIBUTE) {
+                               int ld_errno = 0;
+                               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+                               if (ld_errno != LDAP_NO_SUCH_ATTRIBUTE) {
                                        mod_perror(ld);
                                        return;
                                }
index 2eb650b64eee43a63c4da9fdff851456b07fa96a..4e82430a8e748e18b6394d731bcc7fd94ee7b7d4 100644 (file)
@@ -255,11 +255,14 @@ do_commands()
                                printf("  Verbose mode has been turned on.\n");
                }
                else if (!strncasecmp("dereference", cmd, strlen(cmd))) {
+                       int deref;
                        dereference = 1 - dereference;
-                       if (dereference == 1)
-                               ld->ld_deref = LDAP_DEREF_ALWAYS;
-                       else
-                               ld->ld_deref = LDAP_DEREF_NEVER;
+                       if (dereference == 1) {
+                               deref = LDAP_DEREF_ALWAYS;
+                       } else {
+                               deref = LDAP_DEREF_NEVER;
+                       }
+                       ldap_set_option(ld, LDAP_OPT_DEREF, (void *) &deref);
                }
                else if (!strncasecmp("tidy", cmd, strlen(cmd)))
                        tidy_up();
@@ -282,15 +285,22 @@ status()
 {
        void printbase();
        register char **rdns;
+       char *host;
 
 #ifdef DEBUG
        if (debug & D_TRACE)
                printf("->status()\n");
 #endif
        printf("  Current server is %s", server);
-       if ( ld != NULL && ld->ld_host != NULL && strcasecmp( ld->ld_host,
-           server ) != 0 )
-               printf( " (%s)", ld->ld_host );
+       if ( ld != NULL ) {
+               char *host = NULL;
+               
+               ldap_get_option(ld, LDAP_OPT_HOST_NAME, &host);
+
+               if (( host != NULL ) && (strcasecmp( host, server ) != 0 )) {
+                       printf( " (%s)", host );
+               }
+       }
        putchar( '\n' );
        printbase("  Search base is ", search_base);
        printbase("  Group  base is ", group_base);
@@ -303,7 +313,10 @@ status()
        }
        printf( "  Verbose mode is %sabled\n", ( verbose ? "en" : "dis" ));
        if ( ld != NULL ) {
-               printf( "  Aliases are %sbeing dereferenced\n", ( ld->ld_deref == LDAP_DEREF_ALWAYS ) ? "" : "not" );
+               int deref = LDAP_DEREF_NEVER;
+               ldap_get_option(ld, LDAP_OPT_DEREF, &deref);
+               printf( "  Aliases are %sbeing dereferenced\n",
+                       ( deref == LDAP_DEREF_ALWAYS ) ? "" : "not" );
        }
 }
 
@@ -419,8 +432,10 @@ char **base, *s;
                 *  type a number at that point too.
                 */
                if (ldap_search_s(ld, *base, LDAP_SCOPE_ONELEVEL, "(|(objectClass=quipuNonLeafObject)(objectClass=externalNonLeafObject))", attrs, FALSE, &mp) != LDAP_SUCCESS) {
-                       if ((ld->ld_errno == LDAP_TIMELIMIT_EXCEEDED) ||
-                           (ld->ld_errno == LDAP_SIZELIMIT_EXCEEDED)) {
+                       int ld_errno = 0;
+                       ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+                       if ((ld_errno == LDAP_TIMELIMIT_EXCEEDED) ||
+                           (ld_errno == LDAP_SIZELIMIT_EXCEEDED)) {
                                if (verbose) {
                                        printf("  Your query was too general and a limit was exceeded.  The results listed\n");
                                        printf("  are not complete.  You may want to try again with a more refined query.\n\n");
@@ -626,13 +641,19 @@ initialize_client()
        }
        if (ldap_bind_s(ld, (char *) default_bind_object, (char *) UD_BIND_CRED,
            LDAP_AUTH_SIMPLE) != LDAP_SUCCESS) {
+               int ld_errno = 0;
+               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+
                fprintf(stderr, "  The LDAP Directory is temporarily unavailable.  Please try again later.\n");
-               if (ld->ld_errno != LDAP_UNAVAILABLE)
+               if (ld_errno != LDAP_UNAVAILABLE)
                        ldap_perror(ld, "  ldap_bind_s");
                exit(0);
                /* NOTREACHED */
        }
-       ld->ld_deref = LDAP_DEREF_ALWAYS;
+       {
+               int deref = LDAP_DEREF_ALWAYS;
+               ldap_set_option(ld, LDAP_OPT_DEREF, (void *) &deref);
+       }
        bind_status = UD_NOT_BOUND;
        if ( default_bind_object != NULL ) {
                bound_dn = strdup(default_bind_object);
index c946bb8045c23bd99e90d7a97d58afd3b8ab41ef..b4a7c1f75e4d49272b600acf329d769f14925c8a 100644 (file)
@@ -52,6 +52,7 @@ char *who;
        static char printed_warning = 0;        /* for use with the */
        struct attribute no_batch_update_attr;
        extern char * fetch_boolean_value();
+       int ld_errno;
 #endif
        int is_a_group;         /* TRUE if it is; FALSE otherwise */
        extern void Free();
@@ -111,7 +112,10 @@ char *who;
         */
        no_batch_update_attr.quipu_name = "noBatchUpdates";
        (void) fetch_boolean_value(dn, no_batch_update_attr);
-       if (verbose && !printed_warning && (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE)) {
+
+       ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+
+       if (verbose && !printed_warning && (ld_errno == LDAP_NO_SUCH_ATTRIBUTE)) {
                printed_warning = 1;
                printf("\n  WARNING!\n");
                printf("  You are about to make a modification to an LDAP entry\n");
@@ -799,15 +803,22 @@ char *url;
 
 mod_perror( LDAP *ld )
 {
-       if ( ld == NULL || ( ld->ld_errno != LDAP_UNAVAILABLE &&
-           ld->ld_errno != LDAP_UNWILLING_TO_PERFORM )) {
+       int ld_errno = 0;
+
+       if(ld != NULL) {
+               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+       }
+
+       if (( ld == NULL ) || ( ld_errno != LDAP_UNAVAILABLE &&
+           ld_errno != LDAP_UNWILLING_TO_PERFORM ))
+       {
                ldap_perror( ld, "modify" );
                return;
        }
 
        fprintf( stderr, "\n  modify: failed because part of the online directory is not able\n" );
        fprintf( stderr, "  to be modified right now" );
-       if ( ld->ld_errno == LDAP_UNAVAILABLE ) {
+       if ( ld_errno == LDAP_UNAVAILABLE ) {
                fprintf( stderr, " or is temporarily unavailable" );
        }
        fprintf( stderr, ".\n  Please try again later.\n" );
index f381e9e2001206482231c3019daf9cd821995cbb..9a54cafae3a57255f666be3b676e40288f75730c 100644 (file)
 
 #include "portable.h"
 
-#if LDAP_VERSION < LDAP_VERSION3
-/* quick fix until we have ldap_set_options */
-#include "../libraries/libldap/ldap-int.h"
-#endif
-
 #ifdef DOS
 #define MAX_VALUES     8
 #else
index b919b6bbc6e19cb77ada3b73e13556f9ad3895d6..e2d8d4fca048dfedc9bfd85e3f1bd61833d1cc71 100644 (file)
@@ -24,32 +24,42 @@ LDAP_BEGIN_DECL
 #define LDAP_VERSION           LDAP_VERSION2
 #define LDAP_VERSION_MAX       LDAP_VERSION2
 
+/*
+ * We'll use 2000+draft revision for our API version number
+ * As such, the number will be above the old RFC but below 
+ * whatever number does finally get assigned
+ */
+#define LDAP_API_VERSION       2001
+#define LDAP_VENDOR                    "OpenLDAP"
+/* We'll eventually release as 200 */
+#define LDAP_VENDOR_VERSION    190
+
 #define LDAP_COMPAT20
 #define LDAP_COMPAT30
 #if defined(LDAP_COMPAT20) || defined(LDAP_COMPAT30)
 #define LDAP_COMPAT
 #endif
 
-#define LDAP_OPT_API_INFO                      0x00
-#define LDAP_OPT_DESC                          0x01
-#define LDAP_OPT_DEREF                         0x02
-#define LDAP_OPT_SIZELIMIT                     0x03
-#define LDAP_OPT_TIMELIMIT                     0x04
-#define LDAP_OPT_REFERRALS                     0x08
-#define LDAP_OPT_RESTART                       0x09
-#define LDAP_OPT_PROTOCOL_VERSION      0x11
-#define LDAP_OPT_SERVER_CONTROLS       0x12
-#define LDAP_OPT_CLIENT_CONTROLS       0x13
-#define LDAP_OPT_HOST_NAME                     0x30
-#define        LDAP_OPT_ERROR_NUMBER           0x31
-#define LDAP_OPT_ERROR_STRING          0x32
+#define LDAP_OPT_API_INFO                      0x0000
+#define LDAP_OPT_DESC                          0x0001
+#define LDAP_OPT_DEREF                         0x0002
+#define LDAP_OPT_SIZELIMIT                     0x0003
+#define LDAP_OPT_TIMELIMIT                     0x0004
+#define LDAP_OPT_REFERRALS                     0x0008
+#define LDAP_OPT_RESTART                       0x0009
+#define LDAP_OPT_PROTOCOL_VERSION      0x0011
+#define LDAP_OPT_SERVER_CONTROLS       0x0012
+#define LDAP_OPT_CLIENT_CONTROLS       0x0013
+#define LDAP_OPT_HOST_NAME                     0x0030
+#define        LDAP_OPT_ERROR_NUMBER           0x0031
+#define LDAP_OPT_ERROR_STRING          0x0032
 
 /* for LDAPv2 compatibility */
-#define LDAP_OPT_DNS                           0x40    /* use DN & DNS */
+#define LDAP_OPT_DNS                           0x0101  /* use DN & DNS */
 
 /* on/off values */
 #define LDAP_OPT_ON            ((void *) 1)
-#define LDAP_OPT_OFF   ((void *)) 0)
+#define LDAP_OPT_OFF   ((void *) 0)
 
 #define LDAP_OPT_SUCCESS       0
 #define        LDAP_OPT_ERROR          (-1)
@@ -61,7 +71,7 @@ typedef struct ldapapiinfo {
        int             ldapai_api_version;                     /* revision of API supported */
        int             ldapai_protocol_version;        /* highest LDAP version supported */
        char    **ldapai_extensions;            /* names of API extensions */
-       char    *ldapi_vendor_name;                     /* name of supplier */
+       char    *ldapai_vendor_name;            /* name of supplier */
        int             ldapai_vendor_version;          /* supplier-specific version times 100 */
 } LDAPAPIInfo;
 
@@ -448,9 +458,8 @@ typedef struct ldap_url_desc {
 #define LDAP_URL_ERR_BADSCOPE  3       /* URL scope string is invalid */
 #define LDAP_URL_ERR_MEM       4       /* can't allocate memory space */
 
-/* this typedef is never used, only exists to rid of declaration
- in function param list warning */
-typedef struct timeval LDAPtv;
+/* avoid pulling in headers */
+struct timeval;
 
 LDAP_F int ldap_get_option LDAP_P((LDAP *ld, int option, void *outvalue));
 LDAP_F int ldap_set_option LDAP_P((LDAP *ld, int option, void *invalue));
index 48effc5b7e2917aa4bcba84f6f7f5c4c3a78e9f3..0b49037b71e363eb50c6b8e863ec1c0b1d8e13e6 100644 (file)
@@ -17,6 +17,9 @@
 
 #ifdef STDC_HEADERS
 #include <stdlib.h>
+#endif
+
+#if defined( HAVE_STDARG_H ) && __STDC__
 #include <stdarg.h>
 #else
 #include <varargs.h>
@@ -367,7 +370,7 @@ ber_next_element( BerElement *ber, unsigned long *len, char *last )
 /* VARARGS */
 unsigned long
 ber_scanf
-#ifdef STDC_HEADERS
+#if defined( HAVE_STDARG_H ) && __STDC__
        ( BerElement *ber, char *fmt, ... )
 #else
        ( va_alist )
@@ -375,7 +378,7 @@ va_dcl
 #endif
 {
        va_list         ap;
-#ifndef STDC_HEADERS
+#if !(defined( HAVE_STDARG_H ) && __STDC__)
        BerElement      *ber;
        char            *fmt;
 #endif
@@ -386,7 +389,7 @@ va_dcl
        long            *l, rc, tag;
        unsigned long   len;
 
-#if STDC_HEADERS
+#if defined( HAVE_STDARG_H ) && __STDC__
        va_start( ap, fmt );
 #else
        va_start( ap );
index f036dfeef46690acdca602bf21e668148de449cd..d81b851e58d9e1b694c4813e855d064d380e470f 100644 (file)
@@ -16,7 +16,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#ifdef STDC_HEADERS
+#if defined( HAVE_STDARG_H ) && __STDC__
 #include <stdarg.h>
 #else
 #include <varargs.h>
@@ -509,7 +509,7 @@ ber_put_set( BerElement *ber )
 /* VARARGS */
 int
 ber_printf
-#ifdef STDC_HEADERS
+#if defined( HAVE_STDARG_H ) && __STDC__
        ( BerElement *ber, char *fmt, ... )
 #else
        ( va_alist )
@@ -517,7 +517,7 @@ va_dcl
 #endif
 {
        va_list         ap;
-#ifndef STDC_HEADERS
+#if !(defined( HAVE_STDARG_H ) && __STDC__)
        BerElement      *ber;
        char            *fmt;
 #endif
@@ -526,7 +526,7 @@ va_dcl
        int             rc, i;
        unsigned long   len;
 
-#ifdef STDC_HEADERS 
+#if defined( HAVE_STDARG_H ) && __STDC__
        va_start( ap, fmt );
 #else
        va_start( ap );
index d18c4e0a9f1a8d195bfb545b32539ea3cebf4c32..b12d1df5d04985e8765173f08887013a051aa38a 100644 (file)
@@ -13,13 +13,15 @@ SRCS        = bind.c open.c result.c error.c compare.c search.c \
        getfilter.c sbind.c kbind.c unbind.c friendly.c cldap.c \
        free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \
        getdn.c getentry.c getattr.c getvalues.c addentry.c \
-       request.c getdxbyname.c os-ip.c url.c charset.c
+       request.c getdxbyname.c os-ip.c url.c charset.c \
+       init.c options.c
 OBJS   = bind.o open.o result.o error.o compare.o search.o \
        modify.o add.o modrdn.o delete.o abandon.o ufn.o cache.o \
        getfilter.o sbind.o kbind.o unbind.o friendly.o cldap.o \
        free.o disptmpl.o srchpref.o dsparse.o tmplout.o sort.o \
        getdn.o getentry.o getattr.o getvalues.o addentry.o \
-       request.o getdxbyname.o os-ip.o url.o charset.o
+       request.o getdxbyname.o os-ip.o url.o charset.o \
+       init.o options.o
 
 LIBS = -L$(LDAP_LIBDIR) -lldap -llber $(AC_LIBS)
 LIBLBER = ../liblber/liblber.a
diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c
new file mode 100644 (file)
index 0000000..1074bf9
--- /dev/null
@@ -0,0 +1,23 @@
+#include "portable.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+struct ldap openldap_ld_globals;
+
+int    openldap_ldap_initialized = 0;
+
+void openldap_ldap_initialize( void )
+{
+       if ( openldap_ldap_initialized ) {
+               return;
+       }
+
+       openldap_ldap_initialized = 1;
+}
index dfe459f2414e3b7b9e4ead1c0ff3923608ba1ad3..5bed6b379b113e7777832924c3539ca6077697d9 100644 (file)
@@ -30,6 +30,17 @@ LDAP_BEGIN_DECL
 #endif /* LDAP_DNS */
 #endif /* LDAP_REFERRALS */
 
+#define LDAP_BOOL_REFERRALS            0
+#define LDAP_BOOL_RESTART              1
+#define LDAP_BOOL_DNS                  2
+
+#define LDAP_BOOL(n)   (1 << (n))
+#define LDAP_BOOL_GET(ld, bool)        ((ld)->ld_booleans & LDAP_BOOL(bool) \
+                                                                       ?  LDAP_OPT_ON : LDAP_OPT_OFF)
+#define LDAP_BOOL_SET(ld, bool) ((ld)->ld_booleans |= LDAP_BOOL(bool))
+#define LDAP_BOOL_CLR(ld, bool) ((ld)->ld_booleans &= ~LDAP_BOOL(bool))
+#define LDAP_BOOL_ZERO(ld) ((ld)->ld_booleans = 0)
+
 /*
  * This structure represents both ldap messages and ldap responses.
  * These are really the same, except in the case of search responses,
@@ -82,7 +93,7 @@ struct ldap {
        int             ld_cldaptries;  /* connectionless search retry count */
        int             ld_cldaptimeout;/* time between retries */
        int             ld_refhoplimit; /* limit on referral nesting */
-       unsigned long   ld_options;     /* boolean options */
+       unsigned long   ld_booleans;    /* boolean options */
 
        /* do not mess with the rest though */
        char            *ld_defhost;    /* full name of default server */
@@ -99,6 +110,14 @@ struct ldap {
 #endif /* LDAP_REFERRALS */
 };
 
+
+/*
+ * in init.c
+ */
+extern int openldap_ldap_initialized;
+extern struct ldap openldap_ld_globals;
+void openldap_ldap_initialize LDAP_P((void));
+
 /*
  * in cache.c
  */
index ad2ba4d1b0bd11d3ddc418e33ab9a79dfaea6676..303c3ef4f7a8c14146a71295ef148db461098049 100644 (file)
@@ -148,8 +148,12 @@ ldap_init( char *defhost, int defport )
            WSACleanup( );
                return( NULL );
        }
-       ld->ld_options = LDAP_OPT_REFERRALS;
-#endif /* LDAP_REFERRALS */
+
+       LDAP_BOOL_ZERO(ld);
+       LDAP_BOOL_SET(ld, LDAP_BOOL_REFERRALS);
+#else
+       LDAP_BOOL_ZERO(ld);
+#endif
 
        if ( defhost != NULL &&
            ( ld->ld_defhost = strdup( defhost )) == NULL ) {
@@ -168,7 +172,7 @@ ldap_init( char *defhost, int defport )
        ld->ld_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT;
 
 #ifdef LDAP_REFERRALS
-        ld->ld_options |= LDAP_OPT_REFERRALS;
+       LDAP_BOOL_SET(ld, LDAP_BOOL_REFERRALS);
 #endif /* LDAP_REFERRALS */
 
 #if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c
new file mode 100644 (file)
index 0000000..2e48818
--- /dev/null
@@ -0,0 +1,197 @@
+#include "portable.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "ldap-int.h"
+
+int
+ldap_get_option(
+       LDAP    *ldp,
+       int             option,
+       void    *outvalue)
+{
+       LDAP *ld;
+
+       if(!openldap_ldap_initialized) {
+               openldap_ldap_initialize();
+       }
+
+       if(outvalue == NULL) {
+               /* no place to get to */
+               return -1;
+       }
+
+       if(ldp == NULL) {
+               ld = &openldap_ld_globals;
+       } else {
+               ld = ld;
+       }
+
+       switch(option) {
+       case LDAP_OPT_API_INFO: {
+                       struct ldapapiinfo *info = (struct ldapapiinfo *) outvalue;
+
+                       if(info == NULL) {
+                               /* outvalue must point to an apiinfo structure */
+                               return -1;
+                       }
+
+                       if(info->ldapai_info_version != 1) {
+                               /* version mismatch */
+                               return -1;
+                       }
+
+                       info->ldapai_api_version = LDAP_API_VERSION;
+                       info->ldapai_protocol_version = LDAP_VERSION_MAX;
+                       info->ldapai_extensions = NULL;
+                       info->ldapai_vendor_name = strdup(LDAP_VENDOR);
+                       info->ldapai_vendor_version = LDAP_VENDOR_VERSION;
+
+                       return 0;
+               } break;
+
+       case LDAP_OPT_DESC:
+               if(ldp == NULL) {
+                       /* bad param */
+                       break;
+               } 
+
+               * (int *) outvalue = ld->ld_sb.sb_sd;
+               return 0;
+
+       case LDAP_OPT_DEREF:
+               * (int *) outvalue = ld->ld_deref;
+               return 0;
+
+       case LDAP_OPT_SIZELIMIT:
+               * (int *) outvalue = ld->ld_sizelimit;
+               return 0;
+
+       case LDAP_OPT_TIMELIMIT:
+               * (int *) outvalue = ld->ld_timelimit;
+               return 0;
+
+       case LDAP_OPT_REFERRALS:
+               * (int *) outvalue = (int) LDAP_BOOL_GET(ld, LDAP_BOOL_REFERRALS);
+               return 0;
+               
+       case LDAP_OPT_RESTART:
+               * (int *) outvalue = (int) LDAP_BOOL_GET(ld, LDAP_BOOL_RESTART);
+               return 0;
+
+       case LDAP_OPT_DNS:      /* LDAPv2 */
+               * (int *) outvalue = (int) LDAP_BOOL_GET(ld, LDAP_BOOL_DNS);
+               return 0;
+
+       case LDAP_OPT_PROTOCOL_VERSION:
+               * (int *) outvalue = ld->ld_version;
+               return 0;
+
+       case LDAP_OPT_SERVER_CONTROLS:
+       case LDAP_OPT_CLIENT_CONTROLS:
+               /* not yet supported */
+               break;
+
+       case LDAP_OPT_HOST_NAME:
+               * (char **) outvalue = ld->ld_host;
+               return 0;
+
+       case LDAP_OPT_ERROR_NUMBER:
+               * (int *) outvalue = ld->ld_errno;
+               return 0;
+
+       case LDAP_OPT_ERROR_STRING:
+               /* not yet supported */
+               break;
+
+       default:
+               /* bad param */
+               break;
+       }
+
+       return -1;
+}
+
+int
+ldap_set_option(
+       LDAP    *ldp,
+       int             option,
+       void    *invalue)
+{
+       LDAP *ld;
+
+       if(!openldap_ldap_initialized) {
+               openldap_ldap_initialize();
+       }
+
+       if(invalue == NULL) {
+               /* no place to set from */
+               return -1;
+       }
+
+       if(ldp == NULL) {
+               ld = &openldap_ld_globals;
+       } else {
+               ld = ld;
+       }
+
+       switch(option) {
+       case LDAP_OPT_API_INFO:
+       case LDAP_OPT_DESC:
+               /* READ ONLY */
+               break;
+
+       case LDAP_OPT_DEREF:
+               ld->ld_deref = * (int *) invalue;
+               return 0;
+
+       case LDAP_OPT_SIZELIMIT:
+               ld->ld_sizelimit = * (int *) invalue;
+               return 0;
+
+       case LDAP_OPT_TIMELIMIT:
+               ld->ld_timelimit = * (int *) invalue;
+               return 0;
+
+       case LDAP_OPT_REFERRALS:
+               if((int) invalue == (int) LDAP_OPT_ON) {
+                       LDAP_BOOL_SET(ld, LDAP_BOOL_REFERRALS);
+               } else {
+                       LDAP_BOOL_CLR(ld, LDAP_BOOL_REFERRALS);
+               }
+               return 0;
+
+       case LDAP_OPT_RESTART:
+               if((int) invalue == (int) LDAP_OPT_ON) {
+                       LDAP_BOOL_SET(ld, LDAP_BOOL_RESTART);
+               } else {
+                       LDAP_BOOL_CLR(ld, LDAP_BOOL_RESTART);
+               }
+               return 0;
+
+       case LDAP_OPT_PROTOCOL_VERSION: {
+                       int vers = * (int *) invalue;
+                       if (vers > LDAP_VERSION_MAX) {
+                               /* not supported */
+                               break;
+                       }
+                       ld->ld_version = vers;
+               } return 0;
+
+       case LDAP_OPT_SERVER_CONTROLS:
+       case LDAP_OPT_CLIENT_CONTROLS:
+       case LDAP_OPT_HOST_NAME:
+       case LDAP_OPT_ERROR_NUMBER:
+       case LDAP_OPT_ERROR_STRING:
+               /* not yet supported */
+               break;
+       default:
+               /* bad param */
+               break;
+       }
+       return -1;
+}
index 571902ab5f2fbe566b87282509faf9be19ebb480..21adc2728794a8ef9851626210a237a764e53cd0 100644 (file)
@@ -168,8 +168,9 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                if ( ld->ld_sb.sb_ber.ber_ptr >= ld->ld_sb.sb_ber.ber_end ) {
                        rc = ldap_select1( ld, tvp );
 
-                       if ( rc == 0 || ( rc == -1 && (( ld->ld_options &
-                           LDAP_OPT_RESTART ) == 0 || errno != EINTR ))) {
+                       if ( rc == 0 || ( rc == -1 && (
+                               (LDAP_BOOL_GET(ld, LDAP_BOOL_RESTART) = LDAP_OPT_OFF)
+                           || errno != EINTR ))) {
                                ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
                                    LDAP_TIMEOUT);
                                return( rc );
@@ -209,8 +210,9 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                        }
 #endif
 
-                       if ( rc == 0 || ( rc == -1 && (( ld->ld_options &
-                           LDAP_OPT_RESTART ) == 0 || errno != EINTR ))) {
+                       if ( rc == 0 || ( rc == -1 && (
+                               (LDAP_BOOL_GET(ld, LDAP_BOOL_RESTART) == LDAP_OPT_OFF)
+                               || errno != EINTR ))) {
                                ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
                                    LDAP_TIMEOUT);
                                return( rc );
@@ -326,7 +328,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
        if ( tag != LDAP_RES_SEARCH_ENTRY ) {
                if ( ld->ld_version >= LDAP_VERSION2 &&
                            ( lr->lr_parent != NULL ||
-                           ( ld->ld_options & LDAP_OPT_REFERRALS ) != 0 )) {
+                               (LDAP_BOOL_GET(ld, LDAP_BOOL_REFERRALS) != LDAP_OPT_OFF))) {
                        tmpber = ber;   /* struct copy */
                        if ( ber_scanf( &tmpber, "{iaa}", &lderr,
                            &lr->lr_res_matched, &lr->lr_res_error )
index f530906555a2ffc54a5c976bd6196df02b311396..6abfbe2bf7e7ddec3ab95b986cac8091df491797 100644 (file)
@@ -750,7 +750,7 @@ main( int argc, char **argv )
                        getline( line, sizeof(line), stdin, "sizelimit?" );
                        ld->ld_sizelimit = atoi( line );
 
-                       ld->ld_options = 0;
+                       LDAP_BOOL_ZERO(ld);
 
 #ifdef STR_TRANSLATION
                        getline( line, sizeof(line), stdin,
@@ -775,7 +775,7 @@ main( int argc, char **argv )
                        getline( line, sizeof(line), stdin,
                                "Use DN & DNS to determine where to send requests (0=no, 1=yes)?" );
                        if ( atoi( line ) != 0 ) {
-                               ld->ld_options |= LDAP_OPT_DNS;
+                               LDAP_BOOL_SET(ld, LDAP_BOOL_DNS);
                        }
 #endif /* LDAP_DNS */
 
@@ -783,7 +783,7 @@ main( int argc, char **argv )
                        getline( line, sizeof(line), stdin,
                                "Recognize and chase referrals (0=no, 1=yes)?" );
                        if ( atoi( line ) != 0 ) {
-                               ld->ld_options |= LDAP_OPT_REFERRALS;
+                               LDAP_BOOL_SET(ld, LDAP_BOOL_REFERRALS);
                                getline( line, sizeof(line), stdin,
                                        "Prompt for bind credentials when chasing referrals (0=no, 1=yes)?" );
                                if ( atoi( line ) != 0 ) {
index 84ae94c90e78f8c22e25ff7a822175e179def668..4eac35344fc8b94eb27492a1019c2f03a30ec8bc 100644 (file)
 #endif
 
 #include "lber.h"
-#include "ldap-int.h"
+#include "ldap.h"
+
 #include "ldap_log.h"
 #include "disptmpl.h"
 
+#include "ldap-int.h"
 #include "ldapconfig.h"
 
 static int do_entry2text LDAP_P((
index f5f421e512b35f1d77bfc803e1386f8283fa4710..abcbf2c4d8912097b7392032dc050c86e60199ce 100644 (file)
 #include <ac/unistd.h>
 #include <ac/wait.h>
 
+#ifdef LDAP_PROCTITLE
+#include <ac/setproctitle.h>
+#endif
+
 #include <quipu/commonarg.h>
 #include <quipu/ds_error.h>
 
@@ -113,10 +117,8 @@ char       **argv;
        int                     dsapargc;
        char                    **dsapargv;
        RETSIGTYPE                      wait4child();
-#ifndef NOSETPROCTITLE
+#ifdef LDAP_PROCTITLE
        char                    title[80];
-       extern char             **Argv;
-       extern int              Argc;
 #endif
        extern char             *optarg;
        extern int              optind;
@@ -243,7 +245,7 @@ char        **argv;
        }
 #endif /* FD_SETSIZE */
 
-#ifndef NOSETPROCTITLE
+#if defined(LDAP_PROCTITLE) && !defined( HAVE_SETPROCTITLE )
        /* for setproctitle */
        Argv = argv;
        Argc = argc;
@@ -260,7 +262,7 @@ char        **argv;
         * that have exited
         */
        if (!RunFromInetd) {
-#ifndef NOSETPROCTITLE
+#ifdef LDAP_SETPROCTITLE
                setproctitle( "initializing" );
 #endif
 #ifndef VMS
@@ -330,7 +332,7 @@ char        **argv;
                                    inet_ntoa( from.sin_addr ) );
                        }
 
-#ifndef NOSETPROCTITLE
+#ifdef LDAP_SETPROCTITLE
                        sprintf( title, "%s %d\n", hp == NULL ?
                            inet_ntoa( from.sin_addr ) : hp->h_name, myport );
                        setproctitle( title );
@@ -355,7 +357,7 @@ char        **argv;
         * if we are doing CLDAP as well, handle those requests on the fly
         */
 
-#ifndef NOSETPROCTITLE
+#ifdef LDAP_SETPROCTITLE
 #ifdef LDAP_CONNECTIONLESS
         sprintf( title, "listening %s/%s %d", do_tcp ? "tcp" : "",
             do_udp ? "udp" : "", myport );
@@ -436,7 +438,7 @@ char        **argv;
 #ifdef VMS
                /* This is for debug on terminal on VMS */
                close( tcps );
-#ifndef NOSETPROCTITLE
+#ifdef LDAP_SETPROCTITLE
                setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
                    hp->h_name );
 #endif
@@ -450,7 +452,7 @@ char        **argv;
                switch( pid = fork() ) {
                case 0:         /* child */
                        close( tcps );
-#ifndef NOSETPROCTITLE
+#ifdef LDAP_SETPROCTITLE
                         sprintf( title, "%s (%d)\n", hp == NULL ?
                                inet_ntoa( from.sin_addr ) : hp->h_name,
                                myport );
diff --git a/servers/ldapd/setproctitle.c b/servers/ldapd/setproctitle.c
deleted file mode 100644 (file)
index a3f4bc3..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "portable.h"
-
-#ifndef NOSETPROCTITLE
-/*
- * Copyright (c) 1990,1991 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-char   **Argv;         /* pointer to original (main's) argv */
-int    Argc;           /* original argc */
-
-/*
- * takes a printf-style format string (fmt) and up to three parameters (a,b,c)
- * this clobbers the original argv...
- */
-
-/* VARARGS */
-setproctitle( fmt, a, b, c )
-char *fmt;
-{
-       static char *endargv = (char *)0;
-       char    *s;
-       int             i;
-       char    buf[ 1024 ];
-
-       if ( endargv == (char *)0 ) {
-               /* set pointer to end of original argv */
-               endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
-       }
-       sprintf( buf, fmt, a, b, c );
-       /* make ps print "([prog name])" */
-       s = Argv[0];
-       *s++ = '-';
-       i = strlen( buf );
-       if ( i > endargv - s - 2 ) {
-               i = endargv - s - 2;
-               buf[ i ] = '\0';
-       }
-       strcpy( s, buf );
-       s += i;
-       while ( s < endargv ) *s++ = ' ';
-}
-#endif /* NOSETPROCTITLE */
index 7e2ea45014ca83ff12d2fb8fbf16b82cc9346365..912a97c596621c01beac50745b24a77044044e4a 100644 (file)
 #include <assert.h>
 
 #include "avl.h"
-#include "lber.h"
+#include "../../libraries/liblber/lber-int.h"
 #include "ldap.h"
 #include "ldap_log.h"
 
-#include "../libraries/libldap/ldap-int.h"
-
 #include "lthread.h"
 #include "lthread_rdwr.h"
 #include "ldif.h"
index 636b1207930fdeeb091a52df4a94ee8c3ef15c85..486360fc0c5651a3227621de27bd9c84627ba2e4 100644 (file)
@@ -194,7 +194,9 @@ op_ldap_add(
        Debug( LDAP_DEBUG_ARGS, "replica %s:%d - add dn \"%s\"\n",
                ri->ri_hostname, ri->ri_port, re->re_dn );
        rc = ldap_add_s( ri->ri_ldp, re->re_dn, ldmarr );
-       lderr = ri->ri_ldp->ld_errno;
+
+       ldap_get_option( ri->ri_ldp, LDAP_OPT_ERROR_NUMBER, &lderr);
+
     } else {
        *errmsg = "No modifications to do";
        Debug( LDAP_DEBUG_ANY,
@@ -362,6 +364,7 @@ op_ldap_modrdn(
     int                rc = 0;
     Mi         *mi;
     int                i;
+       int             lderr = 0;
     int                state = 0;
     int                drdnflag = -1;
     char       *newrdn;
@@ -429,7 +432,8 @@ op_ldap_modrdn(
     /* Do the modrdn */
     rc = ldap_modrdn2_s( ri->ri_ldp, re->re_dn, mi->mi_val, drdnflag );
 
-    return( ri->ri_ldp->ld_errno );
+       ldap_get_option( ri->ri_ldp, LDAP_OPT_ERROR_NUMBER, &lderr);
+    return( lderr );
 }
 
 
@@ -622,10 +626,8 @@ do_bind(
      * Set ldap library options to (1) not follow referrals, and 
      * (2) restart the select() system call.
      */
-#ifdef LDAP_REFERRALS
-    ri->ri_ldp->ld_options &= ~LDAP_OPT_REFERRALS;
-#endif /* LDAP_REFERRALS */
-    ri->ri_ldp->ld_options |= LDAP_OPT_RESTART;
+       ldap_set_option(ri->ri_ldp, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
+       ldap_set_option(ri->ri_ldp, LDAP_OPT_RESTART, LDAP_OPT_ON);
 
     switch ( ri->ri_bind_method ) {
     case AUTH_KERBEROS:
index 4356c85cee41389f2f758e323552274ac2738ad7..529438e31b6eb0a603e87cbe9ed1efaad5942583 100644 (file)
@@ -99,14 +99,16 @@ Ri_process(
                            re->re_dn, ri->ri_hostname, ri->ri_port );
                    continue;
                    break;
-               case DO_LDAP_ERR_FATAL:
+               case DO_LDAP_ERR_FATAL: {
                    /* Non-retryable error.  Write rejection log. */
-                   write_reject( ri, re, ri->ri_ldp->ld_errno, errmsg );
+                       int ld_errno = 0;
+                       ldap_get_option(ri->ri_ldp, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+                   write_reject( ri, re, ld_errno, errmsg );
                    /* Update status ... */
                    (void) sglob->st->st_update( sglob->st, ri->ri_stel, re );
                    /* ... and write to disk */
                    (void) sglob->st->st_write( sglob->st );
-                   break;
+                   break;
                default:
                    /* LDAP op completed ok - update status... */
                    (void) sglob->st->st_update( sglob->st, ri->ri_stel, re );
index 8c298378752787447868d60a35038c0e368c94d5..f055a36c956d09500f1eb34ed6bff0c75a14c810 100644 (file)
@@ -27,7 +27,7 @@
 #include "lber.h"
 #include "ldap.h"
 #include "ldap_log.h"
-#include "../libraries/libldap/ldap-int.h"
+
 #include "lthread.h"
 #include "ldapconfig.h"
 #include "ldif.h"