#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
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" );
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,
ldap_msgfree( res );
}
- ld->ld_sizelimit = FAX_MAXAMBIGUOUS;
+ {
+ int sizelimit = FAX_MAXAMBIGUOUS;
+ ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &sizelimit);
+ }
}
return;
#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
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();
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 */
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" );
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 )
#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"
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 )
char **title;
int rc, matches, i, ufn;
struct timeval tv;
+ LDAPFiltDesc *fd;
LDAPFiltInfo *fi;
LDAPMessage *result, *e;
static char *attrs[] = { "cn", "title", "objectClass", "joinable",
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;
##
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)
#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"
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 ) {
inet_ntoa( from.sin_addr ) );
}
+#ifdef LDAP_PROCTITLE
setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
hp->h_name );
+#endif
}
do_queries( 0 );
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,
#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"
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 ) {
inet_ntoa( from.sin_addr ) );
}
+#ifdef LDAP_PROCTITLE
setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
hp->h_name );
+#endif
}
do_queries( 0 );
int len;
FILE *fp;
int rc;
+ int deref;
struct timeval timeout;
fd_set readfds;
LDAP *ld;
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 ) {
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 )
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 ) {
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;
FILE *fp;
char *query;
{
+ int deref;
int scope;
char *base, *filter;
char *filtertype;
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 ) {
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;
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
}
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 ) {
+++ /dev/null
-/*
- * 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++ = ' ';
-}
#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
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" );
char filter[1024];
LDAPMessage *ee, *res;
struct timeval timeout;
+ int opt;
/*
* if all has gone according to plan, we've already arranged for
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,
ldap_msgfree( res );
}
- ld->ld_sizelimit = MAIL500_MAXAMBIGUOUS;
+ opt = MAIL500_MAXAMBIGUOUS;
+ ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &opt);
}
if ( ! anymembers ) {
#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"
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;
/*
* 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;
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" );
}
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" );
}
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;
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;
#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 "="
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;
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;
++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;
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;
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;
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");
{
LDAPMessage *results;
static char *attrs[2] = { "objectClass", NULL };
+ int ld_errno = 0;
#ifdef DEBUG
if (debug & D_TRACE)
/* 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");
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
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");
* 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);
}
/*
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);
#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);
* 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");
#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);
#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;
* 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;
}
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();
{
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);
}
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" );
}
}
* 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");
}
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);
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();
*/
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");
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" );
#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
#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)
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;
#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));
#ifdef STDC_HEADERS
#include <stdlib.h>
+#endif
+
+#if defined( HAVE_STDARG_H ) && __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
/* VARARGS */
unsigned long
ber_scanf
-#ifdef STDC_HEADERS
+#if defined( HAVE_STDARG_H ) && __STDC__
( BerElement *ber, char *fmt, ... )
#else
( va_alist )
#endif
{
va_list ap;
-#ifndef STDC_HEADERS
+#if !(defined( HAVE_STDARG_H ) && __STDC__)
BerElement *ber;
char *fmt;
#endif
long *l, rc, tag;
unsigned long len;
-#if STDC_HEADERS
+#if defined( HAVE_STDARG_H ) && __STDC__
va_start( ap, fmt );
#else
va_start( ap );
#include <stdio.h>
#include <stdlib.h>
-#ifdef STDC_HEADERS
+#if defined( HAVE_STDARG_H ) && __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
/* VARARGS */
int
ber_printf
-#ifdef STDC_HEADERS
+#if defined( HAVE_STDARG_H ) && __STDC__
( BerElement *ber, char *fmt, ... )
#else
( va_alist )
#endif
{
va_list ap;
-#ifndef STDC_HEADERS
+#if !(defined( HAVE_STDARG_H ) && __STDC__)
BerElement *ber;
char *fmt;
#endif
int rc, i;
unsigned long len;
-#ifdef STDC_HEADERS
+#if defined( HAVE_STDARG_H ) && __STDC__
va_start( ap, fmt );
#else
va_start( ap );
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
--- /dev/null
+#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;
+}
#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,
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 */
#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
*/
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 ) {
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 )
--- /dev/null
+#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;
+}
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 );
}
#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 );
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 )
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,
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 */
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 ) {
#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((
#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>
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;
}
#endif /* FD_SETSIZE */
-#ifndef NOSETPROCTITLE
+#if defined(LDAP_PROCTITLE) && !defined( HAVE_SETPROCTITLE )
/* for setproctitle */
Argv = argv;
Argc = argc;
* that have exited
*/
if (!RunFromInetd) {
-#ifndef NOSETPROCTITLE
+#ifdef LDAP_SETPROCTITLE
setproctitle( "initializing" );
#endif
#ifndef VMS
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 );
* 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 );
#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
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 );
+++ /dev/null
-#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 */
#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"
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,
int rc = 0;
Mi *mi;
int i;
+ int lderr = 0;
int state = 0;
int drdnflag = -1;
char *newrdn;
/* 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 );
}
* 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:
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 );
#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"