From: Kurt Zeilenga Date: Thu, 5 Nov 1998 21:27:15 +0000 (+0000) Subject: Update with latest from -devel. X-Git-Tag: OPENLDAP_REL_ENG_1_1_ALPHA2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f0bc8c99713a64c6b65de9b8cd1e30c014b370f;p=thirdparty%2Fopenldap.git Update with latest from -devel. --- diff --git a/INSTALL b/INSTALL index 958d72e704..3e76e3a34f 100644 --- a/INSTALL +++ b/INSTALL @@ -1,87 +1,67 @@ -Making and Installing the U-M LDAP Distribution +Making and Installing the OpenLDAP Distribution ** It is recommended that you read or at least skim through ALL of the ** instructions in this file before attempting to build the software. If you want to build binaries for more than one platform from a single source tree, skip ahead to the "Building LDAP For More Than One Platform" -section near the end of this file. If you are planning to run slapd, -you should read the "SLAPD and SLURPD Administrator's Guide", found in -the doc/guides/ directory within the distribution. +section near the end of this file. If you simply want to build LDAP for a single machine platform, follow these steps: 1. untar the distribution and cd to the top: - % zcat ldap-3.3.tar.Z | tar xf - - % cd ldap-3.3 + % tar xfz openldap-VERSION.tgz + % cd ldap If you are reading this file, you probably have already done this! + 2. Type: + % ./configure --help - 2. edit the files Make-common and include/ldapconfig.h.edit to configure - the software for your site (the files are well-commented): + to list available configuration options. A description of + these options is provided in the 'CONFIGURE OPTIONS' section + below. - % vi Make-common - % vi include/ldapconfig.h.edit + The configure script uses environmental variables for + determining compiler/linker options. See the HINTS + section for commonly used settings. - Note that you should NOT need to edit the Makefile located at the - top of the distribution. + These environment variables are used: + CC C Compiler (cc, ecgs) + CFLAGS C Flags (-ansi) + CPPFLAGS CPP Flags (-I/path/include -Ddef) + LDFLAGS LDFLAGS (-L/path/lib -llib) - If you just want to see if things will build, you can leave the - configuration alone and change it later. + See the 'USING ENVIRONMENT VARIABLES' section for information + on how to use the variables. - If you have the ISODE package built and want to build the - LDAP-to-X.500 server (ldapd), be sure to uncomment the appropriate - lines near the end of the Make-common file. By default only the - stand-alone server, LDAP libraries and client software are built. + 3. edit the file include/ldapconfig.h.edit to configure + the software for your site (the files are well-commented): - 3. make the software: + % vi include/ldapconfig.h.edit - % make + 4. Configure the build system - If all goes well, then make will figure out what platform you are on, - pick a compiler to use, construct Makefiles, and build everything. - If you see a message like "unknown platform..." LDAP has probably not - been set up to build on your machine. See the file build/PORTS for - hints on what to do in that case. - - Note that if your make does not use the Bourne (sh) shell by - default when executing internal scripts (reportedly the case on SGI - machines at least), you will need to run the make explicitly from - within a Bourne shell. If you a syntax error such as "Missing ]" - when you do the make under your usual shell, try this: - - % sh - $ make - - If you don't like the some of the platform-specific options chosen - by the automatic build process (such as the compiler to use, etc), - you can intervene and edit them before anything is actually compiled - by explicitly doing a "make platform" step, editing the .make-platform - file (actually a link to the file to be edited), and then doing a - regular make: - - % make platform - % vi .make-platform - % make + % [env settings] ./configure [options] - If you want to choose the build platform yourself from among those that - the distribution supports, cd to the appropriate directory underneath - build/platforms and make from there. For example, if you are on a - machine running SunOS 4.1.4 and you want to force the use of the cc - compiler, you would do this: + If all goes well, the configure script with auto-detect the + appropriate settings. Use configure enable/with options and/or + environment variables to obtain desired results. - % cd build/platforms/sunos4-cc - % make + 5. Build dependencies - If you want to run some simple tests after the build is complete, you - can do this: + % make depend - % make test + 6. Build the system + + % make - 4. install the binaries and man pages. You may need to be superuser to + If all goes well, the system will build as configured. If not, + return to step 4 after reviewing the enable/with options settings. + + 7. install the binaries and man pages. You may need to be superuser to do this (depending on where you are installing things): % su @@ -103,34 +83,102 @@ these steps: Building LDAP For More Than One Platform It is now possible to build LDAP for more than one platform from the same -source tree. This is accomplished by some rules in the Makefiles that -create a shadow (linked) directory tree where the binaries are placed. +source tree. This is accomplished by using make(1) VPATH support. If +your make(1) program is old and doesn't have VPATH support, install GNU +Make. Follow these steps for each different platform: - 1. move to the directory that matches the platform and compiler you - want to build for and type make. The directories are all located - underneath the build/platforms directory. If your platform is not - there, you may need to do a port - see the build/PORTS file for - more information. For a Sun running SunOS 4.1.4, you might do - this: + 1. Create a directory for the platform object files. - % cd build/platforms/sunos4-cc - % make links + % mkdir obj-platform - This will create a linked source area. + 2. Change your working directory to the platform object directory. + % cd obj-platform - 2. move to the new directory and make as for a single platform. Follow steps - 1-4 above to accomplish this. For example: + 3. Configure the build system - % cd obj-sunos4-cc - % make + % [env settings] ../configure --src-dir=.. [options] + + ( replace ".." with the appropriate path ) + + 4. Continue as above (starting at step 6). + + Note: make depend in VPATH environment is not yet supported. + + +CONFIGURE OPTIONS + +Regrettably, this section has not been written (yet). See +"./configure --help" for current list of options. + + +USING ENVIRONMENT VARIABLES + +The configure script will also use your environmental +variables for determining compiler/linker options. This can +be used to manual specify features and compilation options. + +Supported Environmental Variables + CC C Compiler (cc, ecgs) + CFLAGS C Flags (-ansi) + CPPFLAGS CPP Flags (-I/path/include -Ddef) + LDFLAGS LDFLAGS (-L/path/lib -llib) + PATH command path /usr/local/bin:/usr/bin:/bin + +* Including alternative compilers + Use the CC environment variable to tell configure to + use a specific compiler. For example, to use ecgs + instead of the compiler configure choose, use: + + [env] CC=ecgs ./configure + + You can also use CC use specific flags with the + specified compiler. For example, to require strict + ANSI C using the GNU C Compiler, use: + + [env] CC="gcc -ansi -predantic" ./configure + + (you can use CFLAGS to specify compiler flags) + +* Preprocessor Flags + You may specify additional preprocessor flags by setting + CPPFLAGS. For example, if you would like to use headers + installed in /usr/local/include, use: + + [env] CPPFLAGS="-I/usr/local/include" ./configure + + You can also use CPPFLAGS to specify preprocessor macros. + + [env] CPPFLAGS="-D__SPECIAL_FLAG__" ./configure + +* Linker Flags + You may specify additional linker flags by setting LDFLAGS. + For example, if you would like to use libraries installed + in /usr/local/lib, use: + + [env] LDFLAGS="-L/usr/local/lib" ./configure + + You can also use CPPFLAGS to specify linker flags: + + [env] LDFLAGS="-Bstatic" ./configure + +* Path + You may alter your path to affect configure ability to + find (or not find) commands. For example, to have configure + additionally look in /usr/css/bin for commands, use: + + [env] PATH="/usr/css/bin:$PATH" ./configure + + +HINTS - That's all there is to it. You can also create the linked source area(s) - by just typing "make links" at the top of the distribution, in which case - the Makefile will try to automatically determine the platform and - compiler. +* use software under installed in /usr/local/{include,lib} + [env] \ + CPPFLAGS="-I/usr/local/include" \ + LDFLAGS="-L/usr/local/lib" \ + ./configure -End of LDAP INSTALL file. +End of OpenLDAP INSTALL file. diff --git a/README b/README index fb8dd8ab36..f251681a9c 100644 --- a/README +++ b/README @@ -1,39 +1,73 @@ -UM-LDAP 3.3 README file +OpenLDAP 1.1 Alpha README - This is the UM-LDAP version 3.3 distribution. For a description of - what this distribution contains, see the ANNOUNCEMENT file in this - directory. For a description of changes from previous releases, - see the CHANGES file in this directory. For a more detailed - description of how to make and install the distribution, see the - INSTALL file in this directory. For more information on making and - installing slapd, see the "SLAPD and SLURPD Administrator's Guide" - in the doc/guides/ directory. + This is the OpenLDAP version 1.1 Alpha. + + For a description of what this distribution contains, see the + ANNOUNCEMENT file in this directory. For a description of + changes from previous releases, see the CHANGES file in this + directory. For a more detailed description of how to make an + install the distribution, see the INSTALL file in this directory. + + For more information: + http://www.OpenLDAP.org/ + +REQUIRED SOFTWARE + Build OpenLDAP requires the following software components: + + Base system (libraries and tools): + Standard C compiler, headers, and libraries + POSIX REGEX headers and libraries + + SLAPD: + LDBM compatible datastore + (Berkeley DB, Sleepycat DB2, or GDBM) + SLURPD: + LTHREAD compatible thread package + (POSIX pthreads, MIT pthreads, Mach Cthreads or Sun LWP) + + LDAPD: + ISODE compatible ldap distribution + + CLIENTS/CONTRIBware: + Depends on package. See per package READMEs. + MAKING AND INSTALLING THE DISTRIBUTION - You should be able to make and install the distribution with a pretty - standard default configuration by typing the following commands + You should be able to make and install the distribution with a + default configuration by typing the following commands: + + % ./configure --help + This will list the available options. + The configure script will also use your environmental + variables for determining compiler/linker options. + These environment variables are used: + CC C compiler (cc, ecgs) + CFLAGS C Flags (-ansi) + CPPFLAGS CPP Flags (-I -D) + LDFLAGS LDFLAGS (-L -l) + + % [env settings] ./configure [options] + this will configure the build system + + % make depend + this will create dependency information + + % make + this will build the system - % make % su # make install in this directory. This should produce something that basically - works. + works. You can "cd tests; make" to verify the build. You will probably want to do a little configuration to suit your - site, though. There are two files you might want to edit: + site, though. There are one file you might want to edit: - Make-common This file contains definitions for - where things will be installed, where - to find various things, etc. If you - want to build an ldap server, you'll - definitely need to edit this file - - include/ldapconfig.h.edit This file contains #defines used - by many parts of the distribution. - You'll at least want to change - DEFAULT_BASE. + include/ldapconfig.h.edit + This file contains #defines used by many parts of the + distribution. You'll at least want to change DEFAULT_BASE. See the INSTALL file in this directory for more information. @@ -42,18 +76,16 @@ DOCUMENTATION There are man pages for most programs in the distribution and routines in the various libraries. See ldap(3) for details. - There is a postscript version of an administrator's guide for - slapd in doc/guides/slapd.ps. - - There is an LDAP homepage available that contains the latest + There is an OpenLDAP homepage available that contains the latest LDAP news, releases announcements, pointers to other LDAP resources, etc. You can access it at this URL: - http://www.umich.edu/~rsug/ldap/ + http://www.OpenLDAP.org/ -FEEDBACK / PROBLEM REPORTS +FEEDBACK / PROBLEM REPORTS / DISCUSSIONS We would appreciate any feedback you can provide. If you have problems, report them to this address: - ldap-support@umich.edu + OpenLDAP-bugs@OpenLDAP.org + diff --git a/acconfig.h b/acconfig.h index 73a9fb430c..ae871c6f03 100644 --- a/acconfig.h +++ b/acconfig.h @@ -5,6 +5,13 @@ Leave the following blank line there!! Autoheader needs it. */ + +/* define this if needed to get reentrant functions */ +#undef _REENTRANT + +/* define this if needed to get threadsafe functions */ +#undef _THREAD_SAFE + /* define this if toupper() requires tolower() check */ #undef C_UPPER_LOWER @@ -56,6 +63,15 @@ /* define if your POSIX Threads implementation is circa Draft 4 */ #undef HAVE_PTHREADS_D4 +/* define if you have sched_yield() */ +#ifdef __notdef__ +/* see second sched_yield define */ +#undef HAVE_SCHED_YIELD +#endif + +/* define if you have setproctitle() */ +#undef HAVE_SETPROCTITLE + /* define if you have -lwrap */ #undef HAVE_TCPD @@ -77,6 +93,9 @@ /* define this to remove -lldap cache support */ #undef LDAP_NOCACHE +/* define this for LDAP process title support */ +#undef LDAP_PROCTITLE + /* define this for LDAP referrals support */ #undef LDAP_REFERRALS diff --git a/build/version b/build/version index eb39e5382f..273e63228c 100644 --- a/build/version +++ b/build/version @@ -1 +1 @@ -3.3 +1.1-alpha2 diff --git a/clients/gopher/Makefile.in b/clients/gopher/Makefile.in new file mode 100644 index 0000000000..6ce58c5014 --- /dev/null +++ b/clients/gopher/Makefile.in @@ -0,0 +1,43 @@ +## +## Makefile for gopher clients +## +PROGRAMS= go500gw go500 + +SRCS= go500.c go500gw.c +XSRCS= gwversion.o goversion.o +GOOBJS = go500.o +GWOBJS = go500gw.o + +LDAP_INCDIR= ../../include +LDAP_LIBDIR= ../../libraries + +XLIBS = -llutil @LUTIL_LIBS@ + +go500 : goversion.o + $(CC) $(LDFLAGS) -o $@ $(GOOBJS) goversion.o $(LIBS) + +go500gw : gwversion.o + $(CC) $(LDFLAGS) -o $@ $(GWOBJS) gwversion.o $(LIBS) + +goversion.c: ${GOOBJS} $(LDAP_LIBDEPEND) + $(RM) $@ + (u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \ + t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < $(srcdir)/Version.c > $@) + +gwversion.c: ${GWOBJS} $(LDAP_LIBDEPEND) + $(RM) $@ + (u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \ + t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < $(srcdir)/Versiongw.c > $@) + +install: $(PROGRAMS) go500gw.help FORCE + -$(MKDIR) -p $(libexecdir) $(sysconfdir) + $(INSTALL) $(INSTALLFLAGS) -m 755 go500 $(libexecdir) + $(INSTALL) $(INSTALLFLAGS) -m 755 go500gw $(libexecdir) + -$(MV) $(sysconfdir)/go500gw.help $(sysconfdir)/go500gw.help- + $(INSTALL) $(INSTALLFLAGS) -m 644 go500gw.help $(sysconfdir) diff --git a/clients/gopher/go500.c b/clients/gopher/go500.c index 333787677a..5b4c7aa1ca 100644 --- a/clients/gopher/go500.c +++ b/clients/gopher/go500.c @@ -10,32 +10,33 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include -#include -#include -#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef HAVE_SYS_PARAM_H #include -#include -#include -#include -#include -#include -#include +#endif + #include -#include -#ifdef aix -#include -#endif /* aix */ -#include -#include "portable.h" + #include "ldapconfig.h" #include "lber.h" #include "ldap.h" -#include "disptmpl.h" +#include "lutil.h" -#ifdef USE_SYSCONF -#include -#endif /* USE_SYSCONF */ +#include "disptmpl.h" int debug; int dosyslog; @@ -52,7 +53,7 @@ char myhost[MAXHOSTNAMELEN]; int myport; static set_socket(); -static SIG_FN wait4child(); +static RETSIGTYPE wait4child(); static do_queries(); static do_error(); static do_search(); @@ -78,14 +79,14 @@ char **argv; struct hostent *hp; struct sockaddr_in from; int fromlen; - SIG_FN wait4child(); + 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 ) { @@ -140,15 +141,24 @@ char **argv; } #endif -#ifdef USE_SYSCONF +#ifdef HAVE_SYSCONF dtblsize = sysconf( _SC_OPEN_MAX ); -#else /* USE_SYSCONF */ +#elif HAVE_GETDTABLESIZE dtblsize = getdtablesize(); -#endif /* USE_SYSCONF */ +#else + dtblsize = FD_SETSIZE; +#endif + +#ifdef FD_SETSIZE + if (dtblsize > FD_SETSIZE) { + dtblsize = FD_SETSIZE; + } +#endif /* FD_SETSIZE*/ + /* detach if stderr is redirected or no debugging */ if ( inetd == 0 ) - (void) detach( debug ); + lutil_detach( debug && !isatty( 1 ), 1 ); if ( (myname = strrchr( argv[0], '/' )) == NULL ) myname = strdup( argv[0] ); @@ -170,7 +180,7 @@ char **argv; s = set_socket( port ); /* arrange to reap children */ - (void) signal( SIGCHLD, (void *) wait4child ); + (void) SIGNAL( SIGCHLD, wait4child ); } else { myport = GO500_PORT; @@ -189,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 ); @@ -292,20 +304,24 @@ int port; return( s ); } -static SIG_FN +static RETSIGTYPE wait4child() { +#ifndef HAVE_WAITPID WAITSTATUSTYPE status; +#endif if ( debug ) printf( "parent: catching child status\n" ); -#ifdef USE_WAITPID + +#ifdef HAVE_WAITPID while (waitpid ((pid_t) -1, 0, WAIT_FLAGS) > 0) -#else /* USE_WAITPID */ - while ( wait3( &status, WAIT_FLAGS, 0 ) > 0 ) -#endif /* USE_WAITPID */ - ; /* NULL */ + ; /* NULL */ +#else + while ( wait3( &status, WAIT_FLAGS, 0 ) > 0 ) + ; /* NULL */ +#endif - (void) signal( SIGCHLD, (void *) wait4child ); + (void) SIGNAL( SIGCHLD, wait4child ); } static @@ -372,7 +388,7 @@ int s; } ld->ld_deref = GO500_DEREF; - if ( (rc = ldap_simple_bind_s( ld, GO500_BINDDN, NULL )) + if ( (rc = ldap_simple_bind_s( ld, GO500_BINDDN, GO500_BIND_CRED )) != LDAP_SUCCESS ) { fprintf(fp, "0An error occurred (explanation)\t@%d\t%s\t%d\r\n", diff --git a/clients/gopher/go500gw.c b/clients/gopher/go500gw.c index 7f74fbf57c..8846d0080e 100644 --- a/clients/gopher/go500gw.c +++ b/clients/gopher/go500gw.c @@ -10,32 +10,34 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + #include "lber.h" #include "ldap.h" +#include "lutil.h" + #include "disptmpl.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef aix -#include -#endif /* aix */ -#include "portable.h" -#include "ldapconfig.h" -#ifdef USE_SYSCONF -#include -#endif /* USE_SYSCONF */ +#include "ldapconfig.h" int debug; int dosyslog; @@ -52,7 +54,7 @@ char *friendlyfile = FRIENDLYFILE; int rdncount = GO500GW_RDNCOUNT; static set_socket(); -static SIG_FN wait4child(); +static RETSIGTYPE wait4child(); static do_queries(); static do_menu(); static do_list(); @@ -85,14 +87,14 @@ char **argv; struct hostent *hp; struct sockaddr_in from; int fromlen; - SIG_FN wait4child(); + 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 ) { @@ -150,11 +152,21 @@ char **argv; } } -#ifdef USE_SYSCONF +#ifdef HAVE_SYSCONF dtblsize = sysconf( _SC_OPEN_MAX ); -#else /* USE_SYSCONF */ +#elif HAVE_GETDTABLESIZE dtblsize = getdtablesize(); -#endif /* USE_SYSCONF */ +#else + dtblsize = FD_SETSIZE; +#endif + +#ifdef FD_SETSIZE + if ( dtblsize > FD_SETSIZE ) { + dtblsize = FD_SETSIZE; + } +#endif /* FD_SETSIZE*/ + + #ifdef GO500GW_HOSTNAME strcpy( myhost, GO500GW_HOSTNAME ); @@ -168,7 +180,7 @@ char **argv; /* detach if stderr is redirected or no debugging */ if ( inetd == 0 ) - (void) detach( debug ); + lutil_detach( debug && !isatty( 1 ), 1 ); if ( (myname = strrchr( argv[0], '/' )) == NULL ) myname = strdup( argv[0] ); @@ -190,7 +202,7 @@ char **argv; s = set_socket( port ); /* arrange to reap children */ - (void) signal( SIGCHLD, (void *) wait4child ); + (void) SIGNAL( SIGCHLD, wait4child ); } if ( inetd ) { @@ -209,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 ); @@ -314,20 +328,24 @@ int port; return( s ); } -static SIG_FN +static RETSIGTYPE wait4child() { - WAITSTATUSTYPE status; +#ifndef HAVE_WAITPID + WAITSTATUSTYPE status; +#endif - if ( debug ) printf( "parent: catching child status\n" ); -#ifdef USE_WAITPID - while (waitpid ((pid_t) -1, 0, WAIT_FLAGS) > 0) -#else /* USE_WAITPID */ - while ( wait3( &status, WAIT_FLAGS, 0 ) > 0 ) -#endif /* USE_WAITPID */ - ; /* NULL */ + if ( debug ) printf( "parent: catching child status\n" ); - (void) signal( SIGCHLD, (void *) wait4child ); +#ifdef HAVE_WAITPID + while (waitpid ((pid_t) -1, NULL, WAIT_FLAGS) > 0) + ; /* NULL */ +#else + while (wait3( &status, WAIT_FLAGS, 0 ) > 0 ) + ; /* NULL */ +#endif + + (void) SIGNAL( SIGCHLD, wait4child ); } static do_queries( s ) @@ -506,7 +524,9 @@ char *dn; timeout.tv_sec = GO500GW_TIMEOUT; timeout.tv_usec = 0; + ld->ld_sizelimit = 1; + if ( (rc = ldap_search_st( ld, dn, LDAP_SCOPE_ONELEVEL, "(objectClass=*)", attrs, 0, &timeout, &res )) == LDAP_SUCCESS || rc == LDAP_SIZELIMIT_EXCEEDED ) { @@ -570,6 +590,7 @@ char *dn; timeout.tv_sec = GO500GW_TIMEOUT; timeout.tv_usec = 0; ld->ld_deref = LDAP_DEREF_FINDING; + if ( (rc = ldap_search_st( ld, dn, LDAP_SCOPE_ONELEVEL, "(!(objectClass=dSA))", attrs, 0, &timeout, &res )) != LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED ) { @@ -577,6 +598,7 @@ char *dn; rc, myhost, myport ); return; } + ld->ld_deref = LDAP_DEREF_ALWAYS; if ( ldap_count_entries( ld, res ) < 1 ) { @@ -704,6 +726,7 @@ char *query; timeout.tv_sec = GO500GW_TIMEOUT; timeout.tv_usec = 0; ldap_ufn_timeout( (void *) &timeout ); + ld->ld_deref = LDAP_DEREF_FINDING; if ( (rc = ldap_ufn_search_s( ld, filter, attrs, 0, &res )) @@ -766,15 +789,16 @@ char *query; e = ldap_first_entry( ld, res ); oc = ldap_get_values( ld, e, "objectClass" ); - if ( isnonleaf( ld, oc, dn ) ) { - dn = ldap_get_dn( ld, e ); + dn = ldap_get_dn( ld, e ); + if ( isnonleaf( ld, oc, dn ) ) { rc = do_menu( ld, fp, dn ); free( dn ); return( rc ); } + free( dn ); ldap_value_free( oc ); } @@ -828,6 +852,7 @@ char *dn; if ( ldap_entry2text_search( ld, dn, NULL, NULL, tmpllist, NULL, NULL, entry2textwrite,(void *) fp, "\r\n", rdncount, 0 ) != LDAP_SUCCESS ) { + fprintf(fp, "0An error occurred (explanation)\t@%d\t%s\t%d\r\n", ld->ld_errno, myhost, myport ); diff --git a/clients/rcpt500/main.c b/clients/rcpt500/main.c index 3e65ac233b..b6bf01636e 100644 --- a/clients/rcpt500/main.c +++ b/clients/rcpt500/main.c @@ -6,24 +6,23 @@ * All Rights Reserved */ +#include "portable.h" + #include #include -#include -#include -#include -#include "portable.h" +#include +#include +#include + #include "ldapconfig.h" #include "rcpt500.h" -#ifdef ultrix -extern char *strdup(); -#endif - int dosyslog = 0; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS int do_cldap = 0; -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ + int derefaliases = 1; int sizelimit = RCPT500_SIZELIMIT; int rdncount = RCPT500_RDNCOUNT; @@ -78,11 +77,12 @@ main( argc, argv ) dosyslog = 1; break; case 'U': -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS do_cldap = 1; -#else /* CLDAP */ - fprintf( stderr, "Compile with -DCLDAP for -U support\n" ); -#endif /* CLDAP */ +#else /* LDAP_CONNECTIONLESS */ + fprintf( stderr, + "Compile with -DLDAP_CONNECTIONLESS for -U support\n" ); +#endif /* LDAP_CONNECTIONLESS */ break; case 'b': searchbase = optarg; @@ -364,7 +364,7 @@ find_command( text, argp ) p = text; for ( s = argbuf; *p != '\0'; ++p ) { - *s++ = tolower( *p ); + *s++ = TOLOWER( *p ); } *s = '\0'; diff --git a/clients/tools/Makefile.in b/clients/tools/Makefile.in new file mode 100644 index 0000000000..863471baa0 --- /dev/null +++ b/clients/tools/Makefile.in @@ -0,0 +1,70 @@ +## +## Makefile for LDAP tools +## +SRCS = ldapsearch.c ldapmodify.c ldapdelete.c ldapmodrdn.c +OBJS = ldapsearch.o ldapmodify.o ldapdelete.o ldapmodrdn.o +XLIBS = -llber -lldap + +LDAP_INCDIR= ../../include +LDAP_LIBDIR= ../../libraries + +XSRCS = ldsversion.c ldmversion.c lddversion.c ldrversion.c + +PROGRAMS = ldapsearch ldapmodify ldapdelete ldapmodrdn ldapadd + +ldapsearch: ldsversion.o + $(CC) $(LDFLAGS) -o $@ ldapsearch.o ldsversion.o $(LIBS) + +ldapmodify: ldmversion.o + $(CC) $(LDFLAGS) -o $@ ldapmodify.o ldmversion.o $(LIBS) + +ldapdelete: lddversion.o + $(CC) $(LDFLAGS) -o $@ ldapdelete.o lddversion.o $(LIBS) + +ldapmodrdn: ldrversion.o + $(CC) $(LDFLAGS) -o $@ ldapmodrdn.o ldrversion.o $(LIBS) + +ldapadd: ldapmodify + $(RM) $@ + $(LN) ldapmodify ldapadd + +ldsversion.c: ldapsearch.o $(LDAP_LIBDEPEND) + $(RM) $@ + (u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \ + t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < $(srcdir)/Versionlds.c > $@) + +ldmversion.c: ldapmodify.o $(LDAP_LIBDEPEND) + $(RM) $@ + (u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \ + t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < $(srcdir)/Versionldm.c > $@) + +lddversion.c: ldapdelete.o $(LDAP_LIBDEPEND) + $(RM) $@ + (u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \ + t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < $(srcdir)/Versionldd.c > $@) + +ldrversion.c: ldapmodrdn.o $(LDAP_LIBDEPEND) + $(RM) $@ + (u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \ + t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < $(srcdir)/Versionldr.c > $@) + +install-local: ldapsearch ldapmodify ldapdelete ldapmodrdn ldapadd FORCE + -$(MKDIR) -p $(bindir) + $(INSTALL) $(INSTALLFLAGS) -m 755 ldapsearch $(bindir) + $(INSTALL) $(INSTALLFLAGS) -m 755 ldapmodify $(bindir) + $(INSTALL) $(INSTALLFLAGS) -m 755 ldapdelete $(bindir) + $(INSTALL) $(INSTALLFLAGS) -m 755 ldapmodrdn $(bindir) + $(RM) $(BINDIR)/ldapadd + $(LN) $(BINDIR)/ldapmodify $(bindir)/ldapadd diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index d09b9ad839..fa87c3d571 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -1,16 +1,24 @@ /* ldapmodify.c - generic program to modify or add entries using LDAP */ +#include "portable.h" + #include -#include #include -#include -#include + +#include +#include +#include +#include + #include + +#ifdef HAVE_SYS_FILE_H #include +#endif +#ifdef HAVE_FCNTL_H #include -#ifndef VMS -#include -#endif /* VMS */ +#endif + #include #include #include @@ -19,7 +27,7 @@ static char *prog; static char *binddn = LDAPMODIFY_BINDDN; -static char *passwd = NULL; +static char *passwd = LDAPMODIFY_BIND_CRED; static char *ldaphost = LDAPHOST; static int ldapport = LDAP_PORT; static int new, replace, not, verbose, contoper, force, valsfromfiles; @@ -50,33 +58,20 @@ extern int ldap_debug, lber_debug; #define T_DELETEOLDRDNSTR "deleteoldrdn" -#ifdef NEEDPROTOS -static int process_ldapmod_rec( char *rbuf ); -static int process_ldif_rec( char *rbuf ); -static void addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, - char *value, int vlen ); -static int domodify( char *dn, LDAPMod **pmods, int newentry ); -static int dodelete( char *dn ); -static int domodrdn( char *dn, char *newrdn, int deleteoldrdn ); -static void freepmods( LDAPMod **pmods ); -static int fromfile( char *path, struct berval *bv ); -static char *read_one_record( FILE *fp ); -#else /* NEEDPROTOS */ -static int process_ldapmod_rec(); -static int process_ldif_rec(); -static void addmodifyop(); -static int domodify(); -static int dodelete(); -static int domodrdn(); -static void freepmods(); -static int fromfile(); -static char *read_one_record(); -#endif /* NEEDPROTOS */ - - -main( argc, argv ) - int argc; - char **argv; +static int process_ldapmod_rec LDAP_P(( char *rbuf )); +static int process_ldif_rec LDAP_P(( char *rbuf )); +static void addmodifyop LDAP_P(( LDAPMod ***pmodsp, int modop, char *attr, + char *value, int vlen )); +static int domodify LDAP_P(( char *dn, LDAPMod **pmods, int newentry )); +static int dodelete LDAP_P(( char *dn )); +static int domodrdn LDAP_P(( char *dn, char *newrdn, int deleteoldrdn )); +static void freepmods LDAP_P(( LDAPMod **pmods )); +static int fromfile LDAP_P(( char *path, struct berval *bv )); +static char *read_one_record LDAP_P(( FILE *fp )); + + +int +main( int argc, char **argv ) { char *infile, *rbuf, *start, *p, *q; FILE *fp; @@ -612,7 +607,7 @@ domodify( char *dn, LDAPMod **pmods, int newentry ) for ( j = 0; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) { bvp = pmods[ i ]->mod_bvalues[ j ]; notascii = 0; - for ( k = 0; k < bvp->bv_len; ++k ) { + for ( k = 0; (unsigned long) k < bvp->bv_len; ++k ) { if ( !isascii( bvp->bv_val[ k ] )) { notascii = 1; break; @@ -760,7 +755,7 @@ fromfile( char *path, struct berval *bv ) eof = feof( fp ); fclose( fp ); - if ( rlen != bv->bv_len ) { + if ( (unsigned long) rlen != bv->bv_len ) { perror( path ); free( bv->bv_val ); return( -1 ); diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c index 69d99e7f5a..aaffe4c170 100644 --- a/clients/tools/ldapmodrdn.c +++ b/clients/tools/ldapmodrdn.c @@ -1,17 +1,22 @@ /* ldapmodrdn.c - generic program to modify an entry's RDN using LDAP */ +#include "portable.h" + #include -#include #include -#include + +#include +#include +#include + #include #include #include "ldapconfig.h" static char *binddn = LDAPMODRDN_BINDDN; +static char *passwd = LDAPMODRDN_BIND_CRED; static char *base = LDAPMODRDN_BASE; -static char *passwd = NULL; static char *ldaphost = LDAPHOST; static int ldapport = LDAP_PORT; static int not, verbose, contoper; @@ -24,16 +29,20 @@ extern int ldap_debug, lber_debug; #define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \ realloc( ptr, size )) +static int domodrdn LDAP_P(( + LDAP *ld, + char *dn, + char *rdn, + int remove)); /* flag: remove old RDN */ main( argc, argv ) int argc; char **argv; { char *usage = "usage: %s [-nvkc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n"; - char *myname,*infile, *p, *entrydn, *rdn, buf[ 4096 ]; + char *myname,*infile, *entrydn, *rdn, buf[ 4096 ]; FILE *fp; int rc, i, kerberos, remove, havedn, authmethod; - LDAPMod **pmods; extern char *optarg; extern int optind; @@ -165,11 +174,11 @@ main( argc, argv ) exit( rc ); } -domodrdn( ld, dn, rdn, remove ) - LDAP *ld; - char *dn; - char *rdn; - int remove; /* flag: remove old RDN */ +static int domodrdn( + LDAP *ld, + char *dn, + char *rdn, + int remove) /* flag: remove old RDN */ { int i; diff --git a/configure b/configure index a20b967c60..376440b8e5 100755 --- a/configure +++ b/configure @@ -14,16 +14,20 @@ ac_default_prefix=/usr/local ac_default_prefix=/usr/local ac_help="$ac_help --enable-debug enable debugging (yes)" +ac_help="$ac_help + --enable-proctitle enable proctitle support (yes)" ac_help="$ac_help --enable-libui enable library user interface (yes)" ac_help="$ac_help --enable-cache enable caching (yes)" ac_help="$ac_help - --enable-dns enable dns support (no)" + --enable-dns enable dns support (no)" ac_help="$ac_help --enable-referrals enable referrals (yes)" ac_help="$ac_help --enable-cldap enable connectionless ldap (no)" +ac_help="$ac_help + --enable-x-compile enable cross compiling (no)" ac_help="$ac_help --with-kerberos use Kerberos (auto)" ac_help="$ac_help @@ -587,7 +591,7 @@ ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. echo $ac_n "checking configure arguments""... $ac_c" 1>&6 -echo "configure:591: checking configure arguments" >&5 +echo "configure:595: checking configure arguments" >&5 # OpenLDAP --enable-debug @@ -610,6 +614,26 @@ else ol_enable_debug="yes" fi # end --enable-debug +# OpenLDAP --enable-proctitle + # Check whether --enable-proctitle or --disable-proctitle was given. +if test "${enable_proctitle+set}" = set; then + enableval="$enable_proctitle" + + ol_arg=invalid + for ol_val in auto yes no ; do + if test "$enableval" = "$ol_val" ; then + ol_arg="$ol_val" + fi + done + if test "$ol_arg" = "invalid" ; then + { echo "configure: error: bad value $enableval for --enable-proctitle" 1>&2; exit 1; } + fi + ol_enable_proctitle="$ol_arg" + +else + ol_enable_proctitle="yes" +fi +# end --enable-proctitle # OpenLDAP --enable-libui # Check whether --enable-libui or --disable-libui was given. if test "${enable_libui+set}" = set; then @@ -710,6 +734,26 @@ else ol_enable_cldap="no" fi # end --enable-cldap +# OpenLDAP --enable-x_compile + # Check whether --enable-x_compile or --disable-x_compile was given. +if test "${enable_x_compile+set}" = set; then + enableval="$enable_x_compile" + + ol_arg=invalid + for ol_val in yes no ; do + if test "$enableval" = "$ol_val" ; then + ol_arg="$ol_val" + fi + done + if test "$ol_arg" = "invalid" ; then + { echo "configure: error: bad value $enableval for --enable-x_compile" 1>&2; exit 1; } + fi + ol_enable_x_compile="$ol_arg" + +else + ol_enable_x_compile="no" +fi +# end --enable-x_compile # OpenLDAP --with-kerberos # Check whether --with-kerberos or --without-kerberos was given. @@ -1199,7 +1243,7 @@ TERMCAP_LIBS= echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1203: checking whether ln -s works" >&5 +echo "configure:1247: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1230,7 +1274,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1234: checking for a BSD compatible install" >&5 +echo "configure:1278: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1282,7 +1326,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1286: checking for $ac_word" >&5 +echo "configure:1330: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1309,7 +1353,7 @@ else fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:1313: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:1357: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1339,7 +1383,7 @@ fi # Extract the first word of "sendmail", so it can be a program name with args. set dummy sendmail; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1343: checking for $ac_word" >&5 +echo "configure:1387: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_SENDMAIL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1371,7 +1415,7 @@ fi # Extract the first word of "vi", so it can be a program name with args. set dummy vi; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1375: checking for $ac_word" >&5 +echo "configure:1419: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_EDITOR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1403,7 +1447,7 @@ fi # Extract the first word of "finger", so it can be a program name with args. set dummy finger; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1407: checking for $ac_word" >&5 +echo "configure:1451: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_FINGER'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1436,7 +1480,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1440: checking for $ac_word" >&5 +echo "configure:1484: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1465,7 +1509,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1469: checking for $ac_word" >&5 +echo "configure:1513: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1513,7 +1557,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1517: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1561: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1523,11 +1567,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1547,12 +1591,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1551: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1595: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1556: checking whether we are using GNU C" >&5 +echo "configure:1600: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1561,7 +1605,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1565: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1609: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1576,7 +1620,7 @@ if test $ac_cv_prog_gcc = yes; then ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1580: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1624: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1603,8 +1647,21 @@ else test "${CFLAGS+set}" = set || CFLAGS="-g" fi + +if test $cross_compiling = yes -a $ol_enable_x_compile = yes; then + echo "configure: warning: cross compiling.... go for it" 1>&2 + +elif test $cross_compiling = no -a $ol_enable_x_compile = yes; then + echo "configure: warning: programs compiled here do run here..." 1>&2 + { echo "configure: error: if not cross compiling, use --disable-x-compile." 1>&2; exit 1; } + +elif test $cross_compiling = yes -a $ol_enable_x_compile = no; then + echo "configure: warning: programs compiled here do not run here..." 1>&2 + { echo "configure: error: if cross compiling, add --enable-x-compile." 1>&2; exit 1; } +fi + echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1608: checking how to run the C preprocessor" >&5 +echo "configure:1665: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1619,13 +1676,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1629: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1686: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : @@ -1636,13 +1693,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1646: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1703: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : @@ -1666,13 +1723,13 @@ echo "$ac_t""$CPP" 1>&6 if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:1670: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:1727: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext < Autoconf TIOCGETP @@ -1690,7 +1747,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < Autoconf TCGETA @@ -1711,11 +1768,73 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 fi fi +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1773: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1794: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + + echo $ac_n "checking for AIX""... $ac_c" 1>&6 -echo "configure:1717: checking for AIX" >&5 +echo "configure:1836: checking for AIX" >&5 cat > conftest.$ac_ext <&6 -echo "configure:1741: checking for POSIXized ISC" >&5 +echo "configure:1860: checking for POSIXized ISC" >&5 if test -d /etc/conf/kconfig.d && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 then @@ -1759,17 +1878,17 @@ fi ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 -echo "configure:1763: checking for minix/config.h" >&5 +echo "configure:1882: checking for minix/config.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1773: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1892: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1810,12 +1929,12 @@ fi echo $ac_n "checking for socket""... $ac_c" 1>&6 -echo "configure:1814: checking for socket" >&5 +echo "configure:1933: checking for socket" >&5 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_socket=yes" else @@ -1857,7 +1976,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6 -echo "configure:1861: checking for main in -lsocket" >&5 +echo "configure:1980: checking for main in -lsocket" >&5 ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1865,14 +1984,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1995: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1900,7 +2019,7 @@ else fi echo $ac_n "checking for main in -lnet""... $ac_c" 1>&6 -echo "configure:1904: checking for main in -lnet" >&5 +echo "configure:2023: checking for main in -lnet" >&5 ac_lib_var=`echo net'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1908,14 +2027,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2038: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1943,7 +2062,7 @@ else fi echo $ac_n "checking for main in -lnsl_s""... $ac_c" 1>&6 -echo "configure:1947: checking for main in -lnsl_s" >&5 +echo "configure:2066: checking for main in -lnsl_s" >&5 ac_lib_var=`echo nsl_s'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1951,14 +2070,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl_s $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1986,7 +2105,7 @@ else fi echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 -echo "configure:1990: checking for main in -lnsl" >&5 +echo "configure:2109: checking for main in -lnsl" >&5 ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1994,14 +2113,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2124: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2029,7 +2148,7 @@ else fi echo $ac_n "checking for socket in -linet""... $ac_c" 1>&6 -echo "configure:2033: checking for socket in -linet" >&5 +echo "configure:2152: checking for socket in -linet" >&5 ac_lib_var=`echo inet'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2037,7 +2156,7 @@ else ac_save_LIBS="$LIBS" LIBS="-linet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2171: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2076,7 +2195,7 @@ else fi echo $ac_n "checking for main in -lgen""... $ac_c" 1>&6 -echo "configure:2080: checking for main in -lgen" >&5 +echo "configure:2199: checking for main in -lgen" >&5 ac_lib_var=`echo gen'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2084,14 +2203,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lgen $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2123,7 +2242,7 @@ fi echo $ac_n "checking for sigset in -lV3""... $ac_c" 1>&6 -echo "configure:2127: checking for sigset in -lV3" >&5 +echo "configure:2246: checking for sigset in -lV3" >&5 ac_lib_var=`echo V3'_'sigset | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2131,7 +2250,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lV3 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2175,17 +2294,17 @@ if test $ol_with_kerberos = auto -o $ol_with_kerberos = k5 ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2179: checking for $ac_hdr" >&5 +echo "configure:2298: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2189: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2308: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -2214,7 +2333,7 @@ done if test $ac_cv_header_kerberosIV_krb_h = yes ; then echo $ac_n "checking for main in -lkrb4""... $ac_c" 1>&6 -echo "configure:2218: checking for main in -lkrb4" >&5 +echo "configure:2337: checking for main in -lkrb4" >&5 ac_lib_var=`echo krb4'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2222,14 +2341,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lkrb4 -lkrb5 -ldes425 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2269,17 +2388,17 @@ if test $ol_with_kerberos = auto -o $ol_with_kerberos = k4 ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2273: checking for $ac_hdr" >&5 +echo "configure:2392: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2283: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2402: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -2308,7 +2427,7 @@ done if test $ac_cv_header_krb_h = yes ; then echo $ac_n "checking for main in -lkrb""... $ac_c" 1>&6 -echo "configure:2312: checking for main in -lkrb" >&5 +echo "configure:2431: checking for main in -lkrb" >&5 ac_lib_var=`echo krb'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2316,14 +2435,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lkrb -ldes $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2446: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2366,17 +2485,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = posix ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2370: checking for $ac_hdr" >&5 +echo "configure:2489: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2380: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2499: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -2405,13 +2524,13 @@ done if test $ac_cv_header_pthread_h = yes ; then echo $ac_n "checking POSIX thread version""... $ac_c" 1>&6 -echo "configure:2409: checking POSIX thread version" >&5 +echo "configure:2528: checking POSIX thread version" >&5 if eval "test \"`echo '$''{'ol_cv_pthread_version'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -2433,7 +2552,7 @@ rm -f conftest* cat > conftest.$ac_ext < @@ -2486,7 +2605,7 @@ EOF echo $ac_n "checking for LinuxThreads""... $ac_c" 1>&6 -echo "configure:2490: checking for LinuxThreads" >&5 +echo "configure:2609: checking for LinuxThreads" >&5 if eval "test \"`echo '$''{'ol_cv_linux_threads'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2512,12 +2631,12 @@ EOF echo $ac_n "checking for pthread_create""... $ac_c" 1>&6 -echo "configure:2516: checking for pthread_create" >&5 +echo "configure:2635: checking for pthread_create" >&5 if eval "test \"`echo '$''{'ac_cv_func_pthread_create'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_pthread_create=yes" else @@ -2562,7 +2681,7 @@ fi if test $ol_link_threads = no ; then echo $ac_n "checking for pthread_create with -pthread""... $ac_c" 1>&6 -echo "configure:2566: checking for pthread_create with -pthread" >&5 +echo "configure:2685: checking for pthread_create with -pthread" >&5 if eval "test \"`echo '$''{'ol_cv_pthread_flag'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2570,7 +2689,7 @@ else save_LIBS="$LIBS" LIBS="-pthread $LIBS" cat > conftest.$ac_ext < int main() { @@ -2580,7 +2699,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2584: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ol_cv_pthread_flag=yes else @@ -2605,7 +2724,7 @@ echo "$ac_t""$ol_cv_pthread_flag" 1>&6 if test $ol_link_threads = no ; then save_LIBS="$LIBS" echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:2609: checking for pthread_create in -lpthread" >&5 +echo "configure:2728: checking for pthread_create in -lpthread" >&5 ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2613,7 +2732,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2652,7 +2771,7 @@ fi if test $ol_link_threads = no ; then save_LIBS="$LIBS" echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:2656: checking for pthread_create in -lc_r" >&5 +echo "configure:2775: checking for pthread_create in -lc_r" >&5 ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2660,7 +2779,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lc_r $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2699,18 +2818,15 @@ fi if test $ol_link_threads = no ; then save_LIBS="$LIBS" echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:2703: checking for pthread_create in -lpthread" >&5 +echo "configure:2822: checking for pthread_create in -lpthread" >&5 ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" -LIBS="-lpthread if test $ol_with_preemptive = auto ; then - ol_with_preemptive=yes - fi - -lmach -lexc -lc $LIBS" +LIBS="-lpthread -lmach -lexc -lc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2841: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2743,6 +2859,10 @@ EOF ol_link_threads=posix LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc" + if test $ol_with_preemptive = auto ; then + ol_with_preemptive=yes + fi + else echo "$ac_t""no" 1>&6 fi @@ -2763,12 +2883,12 @@ EOF for ac_func in sched_yield pthread_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2767: checking for $ac_func" >&5 +echo "configure:2887: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2915: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2818,7 +2938,104 @@ done if test $ac_cv_func_sched_yield = no -a \ $ac_cv_func_pthread_yield = no ; then + echo $ac_n "checking for sched_yield in -lrt""... $ac_c" 1>&6 +echo "configure:2943: checking for sched_yield in -lrt" >&5 +ac_lib_var=`echo rt'_'sched_yield | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lrt $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LTHREAD_LIBS="$LTHREAD_LIBS -lrt" + cat >> confdefs.h <<\EOF +#define HAVE_SCHED_YIELD 1 +EOF + + ac_cv_func_sched_yield=yes +else + echo "$ac_t""no" 1>&6 +ac_cv_func_sched_yield=no +fi + + fi + if test $ac_cv_func_sched_yield = no -a \ + $ac_cv_func_pthread_yield = no ; then + echo $ac_n "checking for sched_yield in -lposix4""... $ac_c" 1>&6 +echo "configure:2992: checking for sched_yield in -lposix4" >&5 +ac_lib_var=`echo posix4'_'sched_yield | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lposix4 $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LTHREAD_LIBS="$LTHREAD_LIBS -lposix4" + cat >> confdefs.h <<\EOF +#define HAVE_SCHED_YIELD 1 +EOF + + ac_cv_func_sched_yield=yes +else + echo "$ac_t""no" 1>&6 +ac_cv_func_sched_yield=no +fi + + fi + if test $ac_cv_func_sched_yield = no -a \ + $ac_cv_func_pthread_yield = no ; then echo "configure: warning: could not locate sched_yield() or pthread_yield()" 1>&2 { echo "configure: error: POSIX Threads are not usable" 1>&2; exit 1; } fi @@ -2826,12 +3043,12 @@ done for ac_func in pthread_kill do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2830: checking for $ac_func" >&5 +echo "configure:3047: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + + + for ac_func in \ + pthread_setconcurrency \ + thr_setconcurrency \ + +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:3106: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:3134: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2881,13 +3157,13 @@ done if test $ol_with_preemptive = auto ; then echo $ac_n "checking for preemptive Pthread implementation""... $ac_c" 1>&6 -echo "configure:2885: checking for preemptive Pthread implementation" >&5 +echo "configure:3161: checking for preemptive Pthread implementation" >&5 if test "$cross_compiling" = yes; then { echo "configure: error: crossing compiling: use --with-preemptive=yes|no|manual" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -2918,6 +3194,14 @@ main(argc, argv) int argc; char **argv; { pthread_t t; + +#ifdef HAVE_PTHREAD_SETCONCURRENCY + (void) pthread_setconcurrency(2); +#elif HAVE_THR_SETCONCURRENCY + /* Set Solaris LWP concurrency to 2 */ + thr_setconcurrency(2); +#endif + pthread_create(&t, NULL, (void *) task, NULL); #if HAVE_SCHED_YIELD @@ -2931,7 +3215,7 @@ int argc; char **argv; } EOF -if { (eval echo configure:2935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3219: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ol_pthread_preemptive=yes else @@ -2954,6 +3238,7 @@ EOF fi fi + CPPFLAGS="$save_CPPFLAGS" LIBS="$save_LIBS" else @@ -2966,22 +3251,22 @@ EOF fi fi -if test $ol_with_threads = auto -o $ol_with_threads = cthreads ; then +if test $ol_with_threads = auto -o $ol_with_threads = mach ; then for ac_hdr in mach/cthreads.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2975: checking for $ac_hdr" >&5 +echo "configure:3260: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2985: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3270: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -3007,57 +3292,109 @@ else fi done - if test $ac_cv_header_lwp_lwp_h = yes ; then - echo $ac_n "checking for cthread_fork in -llwp""... $ac_c" 1>&6 -echo "configure:3013: checking for cthread_fork in -llwp" >&5 -ac_lib_var=`echo lwp'_'cthread_fork | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + if test $ac_cv_header_mach_cthreads_h = yes ; then + ol_with_threads=found + + echo $ac_n "checking for cthread_fork""... $ac_c" 1>&6 +echo "configure:3300: checking for cthread_fork" >&5 +if eval "test \"`echo '$''{'ac_cv_func_cthread_fork'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - ac_save_LIBS="$LIBS" -LIBS="-llwp $LIBS" -cat > conftest.$ac_ext < conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char cthread_fork(); int main() { -cthread_fork() + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_cthread_fork) || defined (__stub___cthread_fork) +choke me +#else +cthread_fork(); +#endif + ; return 0; } EOF -if { (eval echo configure:3032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" + eval "ac_cv_func_cthread_fork=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" + eval "ac_cv_func_cthread_fork=no" fi rm -f conftest* -LIBS="$ac_save_LIBS" - fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + +if eval "test \"`echo '$ac_cv_func_'cthread_fork`\" = yes"; then echo "$ac_t""yes" 1>&6 - have_cthreads=yes + ol_link_threads=yes else echo "$ac_t""no" 1>&6 -have_cthreads=no fi - if test $have_cthreads = yes ; then - cat >> confdefs.h <<\EOF -#define HAVE_MACH_CTHREADS 1 + if test $ol_link_threads = no ; then + echo $ac_n "checking for cthread_fork with -all_load""... $ac_c" 1>&6 +echo "configure:3350: checking for cthread_fork with -all_load" >&5 +if eval "test \"`echo '$''{'ol_cv_cthread_all_load'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + save_LIBS="$LIBS" + LIBS="-all_load $LIBS" + cat > conftest.$ac_ext < +int main() { + + cthread_fork((void *)0, (void *)0); + +; return 0; } EOF +if { (eval echo configure:3367: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + ol_cv_cthread_all_load=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ol_cv_cthread_all_load=no +fi +rm -f conftest* + LIBS="$save_LIBS" + +fi - LTHREAD_LIBS="$LTHREAD_LIBS -llwp" +echo "$ac_t""$ol_cv_cthread_all_load" 1>&6 + + if test $ol_cv_cthread_all_load = yes ; then + LTHREAD_LIBS="$LTHREAD_LIBS -all_load" + ol_link_threads=mach + fi + fi + + if test $ol_link_threads != no ; then + : check for cthread specific functionality here + else + { echo "configure: error: could not link with Mach CThreads" 1>&2; exit 1; } fi fi + + if test $ol_with_threads = mach ; then + { echo "configure: error: could not locate Mach CThreads" 1>&2; exit 1; } + fi fi if test $ol_with_threads = auto -o $ol_with_threads = lwp ; then @@ -3065,17 +3402,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = lwp ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3069: checking for $ac_hdr" >&5 +echo "configure:3406: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3079: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3416: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -3101,9 +3438,9 @@ else fi done - if test $ac_cv_header_lwp_lwp_h = yes ; then + if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6 -echo "configure:3107: checking for thr_create in -lthread" >&5 +echo "configure:3444: checking for thr_create in -lthread" >&5 ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3111,7 +3448,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3463: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3161,17 +3498,17 @@ EOF do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3165: checking for $ac_hdr" >&5 +echo "configure:3502: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3175: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3512: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -3197,9 +3534,9 @@ else fi done - if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then + if test $ac_cv_header_lwp_lwp_h = yes ; then echo $ac_n "checking for lwp_create in -llwp""... $ac_c" 1>&6 -echo "configure:3203: checking for lwp_create in -llwp" >&5 +echo "configure:3540: checking for lwp_create in -llwp" >&5 ac_lib_var=`echo lwp'_'lwp_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3207,7 +3544,7 @@ else ac_save_LIBS="$LIBS" LIBS="-llwp $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3262,7 +3599,7 @@ EOF fi if test $ol_with_threads = manual ; then - $ol_link_threads=yes + ol_link_threads=yes echo "configure: warning: thread defines and link options must be set manually" 1>&2 @@ -3270,17 +3607,17 @@ if test $ol_with_threads = manual ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3274: checking for $ac_hdr" >&5 +echo "configure:3611: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3284: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3621: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -3309,12 +3646,12 @@ done for ac_func in sched_yield pthread_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3313: checking for $ac_func" >&5 +echo "configure:3650: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3363,7 +3700,7 @@ done echo $ac_n "checking for LinuxThreads""... $ac_c" 1>&6 -echo "configure:3367: checking for LinuxThreads" >&5 +echo "configure:3704: checking for LinuxThreads" >&5 if eval "test \"`echo '$''{'ol_cv_linux_threads'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3384,17 +3721,17 @@ echo "$ac_t""$ol_cv_linux_threads" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3388: checking for $ac_hdr" >&5 +echo "configure:3725: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3398: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3735: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -3424,17 +3761,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3428: checking for $ac_hdr" >&5 +echo "configure:3765: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3438: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3775: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -3464,17 +3801,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3468: checking for $ac_hdr" >&5 +echo "configure:3805: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3478: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3815: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -3502,6 +3839,18 @@ done fi +if test $ol_with_threads = yes ; then + cat >> confdefs.h <<\EOF +#define _REENTRANT 1 +EOF + + cat >> confdefs.h <<\EOF +#define _THREAD_SAFE 1 +EOF + +fi + + if test $ol_link_threads = no ; then if test $ol_with_threads = yes ; then { echo "configure: error: no suitable thread support" 1>&2; exit 1; } @@ -3509,7 +3858,7 @@ if test $ol_link_threads = no ; then if test $ol_with_threads = auto ; then echo "configure: warning: no suitable thread support, disabling threads" 1>&2 - $ol_with_threads = no + ol_with_threads=no fi cat >> confdefs.h <<\EOF @@ -3526,13 +3875,13 @@ fi ol_link_ldbm=no if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then echo $ac_n "checking for DB2 library""... $ac_c" 1>&6 -echo "configure:3530: checking for DB2 library" >&5 +echo "configure:3879: checking for DB2 library" >&5 if eval "test \"`echo '$''{'ol_cv_lib_db2'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for db_open in -ldb""... $ac_c" 1>&6 -echo "configure:3536: checking for db_open in -ldb" >&5 +echo "configure:3885: checking for db_open in -ldb" >&5 ac_lib_var=`echo db'_'db_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3540,7 +3889,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldb $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3904: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3582,17 +3931,17 @@ for ac_hdr in db.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3586: checking for $ac_hdr" >&5 +echo "configure:3935: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3596: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3945: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -3620,13 +3969,13 @@ done if test $ac_cv_header_db_h = yes ; then echo $ac_n "checking if db.h is DB2""... $ac_c" 1>&6 -echo "configure:3624: checking if db.h is DB2" >&5 +echo "configure:3973: checking if db.h is DB2" >&5 if eval "test \"`echo '$''{'ol_cv_header_db2'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -3658,7 +4007,7 @@ fi echo $ac_n "checking for Berkeley DB2""... $ac_c" 1>&6 -echo "configure:3662: checking for Berkeley DB2" >&5 +echo "configure:4011: checking for Berkeley DB2" >&5 if eval "test \"`echo '$''{'ol_cv_berkeley_db2'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3704,18 +4053,18 @@ fi if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db ; then echo $ac_n "checking for Berkeley DB library""... $ac_c" 1>&6 -echo "configure:3708: checking for Berkeley DB library" >&5 +echo "configure:4057: checking for Berkeley DB library" >&5 if eval "test \"`echo '$''{'ol_cv_lib_db'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for dbopen""... $ac_c" 1>&6 -echo "configure:3714: checking for dbopen" >&5 +echo "configure:4063: checking for dbopen" >&5 if eval "test \"`echo '$''{'ac_cv_func_dbopen'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_dbopen=yes" else @@ -3757,7 +4106,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbopen in -ldb""... $ac_c" 1>&6 -echo "configure:3761: checking for dbopen in -ldb" >&5 +echo "configure:4110: checking for dbopen in -ldb" >&5 ac_lib_var=`echo db'_'dbopen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3765,7 +4114,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldb $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3811,17 +4160,17 @@ for ac_hdr in db_185.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3815: checking for $ac_hdr" >&5 +echo "configure:4164: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3825: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4174: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -3857,7 +4206,7 @@ fi echo $ac_n "checking for Berkeley DB""... $ac_c" 1>&6 -echo "configure:3861: checking for Berkeley DB" >&5 +echo "configure:4210: checking for Berkeley DB" >&5 if eval "test \"`echo '$''{'ol_cv_berkeley_db'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3902,7 +4251,7 @@ EOF fi if test $ol_with_ldbm_api = manual ; then - $ol_link_ldbm=yes + ol_link_ldbm=yes echo "configure: warning: LDBM defines and link options must be set manually" 1>&2 @@ -3910,17 +4259,17 @@ if test $ol_with_ldbm_api = manual ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3914: checking for $ac_hdr" >&5 +echo "configure:4263: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3924: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4273: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -3950,23 +4299,23 @@ fi if test $ol_link_ldbm = no -a $ol_with_ldbm_type = btree ; then echo "configure: warning: Could not find LDBM with BTREE support" 1>&2 - $ol_with_ldbm_api=none + ol_with_ldbm_api=none fi if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then echo $ac_n "checking for GDBM library""... $ac_c" 1>&6 -echo "configure:3959: checking for GDBM library" >&5 +echo "configure:4308: checking for GDBM library" >&5 if eval "test \"`echo '$''{'ol_cv_lib_gdbm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for gdbm_open""... $ac_c" 1>&6 -echo "configure:3965: checking for gdbm_open" >&5 +echo "configure:4314: checking for gdbm_open" >&5 if eval "test \"`echo '$''{'ac_cv_func_gdbm_open'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4342: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_gdbm_open=yes" else @@ -4008,7 +4357,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for gdbm_open in -lgdbm""... $ac_c" 1>&6 -echo "configure:4012: checking for gdbm_open in -lgdbm" >&5 +echo "configure:4361: checking for gdbm_open in -lgdbm" >&5 ac_lib_var=`echo gdbm'_'gdbm_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4016,7 +4365,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lgdbm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4062,17 +4411,17 @@ echo "$ac_t""$ol_cv_lib_gdbm" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4066: checking for $ac_hdr" >&5 +echo "configure:4415: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4076: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4425: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -4099,7 +4448,7 @@ fi done echo $ac_n "checking for db""... $ac_c" 1>&6 -echo "configure:4103: checking for db" >&5 +echo "configure:4452: checking for db" >&5 if eval "test \"`echo '$''{'ol_cv_gdbm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4133,18 +4482,18 @@ fi if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = ndbm ; then echo $ac_n "checking for NDBM library""... $ac_c" 1>&6 -echo "configure:4137: checking for NDBM library" >&5 +echo "configure:4486: checking for NDBM library" >&5 if eval "test \"`echo '$''{'ol_cv_lib_ndbm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for dbm_open""... $ac_c" 1>&6 -echo "configure:4143: checking for dbm_open" >&5 +echo "configure:4492: checking for dbm_open" >&5 if eval "test \"`echo '$''{'ac_cv_func_dbm_open'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4520: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_dbm_open=yes" else @@ -4186,7 +4535,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbm_open in -lndbm""... $ac_c" 1>&6 -echo "configure:4190: checking for dbm_open in -lndbm" >&5 +echo "configure:4539: checking for dbm_open in -lndbm" >&5 ac_lib_var=`echo ndbm'_'dbm_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4194,7 +4543,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lndbm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4558: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4225,7 +4574,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6 -echo "configure:4229: checking for dbm_open in -ldbm" >&5 +echo "configure:4578: checking for dbm_open in -ldbm" >&5 ac_lib_var=`echo dbm'_'dbm_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4233,7 +4582,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldbm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4281,17 +4630,17 @@ echo "$ac_t""$ol_cv_lib_ndbm" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4285: checking for $ac_hdr" >&5 +echo "configure:4634: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4295: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4644: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -4318,7 +4667,7 @@ fi done echo $ac_n "checking for db""... $ac_c" 1>&6 -echo "configure:4322: checking for db" >&5 +echo "configure:4671: checking for db" >&5 if eval "test \"`echo '$''{'ol_cv_ndbm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4361,12 +4710,12 @@ if test $ol_link_ldbm = no -a $ol_enable_ldbm != no ; then fi echo "configure: warning: disabling LDBM" 1>&2 - $ol_enable_ldbm=no + ol_enable_ldbm=no fi if test $ol_enable_wrappers = yes ; then echo $ac_n "checking for hosts_access in -lwrap""... $ac_c" 1>&6 -echo "configure:4370: checking for hosts_access in -lwrap" >&5 +echo "configure:4719: checking for hosts_access in -lwrap" >&5 ac_lib_var=`echo wrap'_'hosts_access | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4374,7 +4723,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lwrap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4431,17 +4780,17 @@ for ac_hdr in termcap.h ncurses.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4435: checking for $ac_hdr" >&5 +echo "configure:4784: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4445: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4794: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -4470,7 +4819,7 @@ done if test $ol_link_termcap = no ; then echo $ac_n "checking for tputs in -ltermcap""... $ac_c" 1>&6 -echo "configure:4474: checking for tputs in -ltermcap" >&5 +echo "configure:4823: checking for tputs in -ltermcap" >&5 ac_lib_var=`echo termcap'_'tputs | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4478,7 +4827,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ltermcap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4842: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4522,7 +4871,7 @@ fi if test $ol_link_termcap = no ; then echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6 -echo "configure:4526: checking for initscr in -lncurses" >&5 +echo "configure:4875: checking for initscr in -lncurses" >&5 ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4530,7 +4879,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lncurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4894: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4583,12 +4932,12 @@ fi # FreeBSD (and others) have crypt(3) in -lcrypt if test $ol_enable_crypt != no ; then echo $ac_n "checking for crypt""... $ac_c" 1>&6 -echo "configure:4587: checking for crypt" >&5 +echo "configure:4936: checking for crypt" >&5 if eval "test \"`echo '$''{'ac_cv_func_crypt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_crypt=yes" else @@ -4630,7 +4979,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6 -echo "configure:4634: checking for crypt in -lcrypt" >&5 +echo "configure:4983: checking for crypt in -lcrypt" >&5 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4638,7 +4987,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcrypt $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:5002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4690,13 +5039,116 @@ EOF fi fi +# FreeBSD (and others) have setproctitle(3) in -lutil +if test $ol_enable_proctitle != no ; then + echo $ac_n "checking for setproctitle""... $ac_c" 1>&6 +echo "configure:5046: checking for setproctitle" >&5 +if eval "test \"`echo '$''{'ac_cv_func_setproctitle'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char setproctitle(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_setproctitle) || defined (__stub___setproctitle) +choke me +#else +setproctitle(); +#endif + +; return 0; } +EOF +if { (eval echo configure:5074: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_setproctitle=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_setproctitle=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'setproctitle`\" = yes"; then + echo "$ac_t""yes" 1>&6 + have_setproctitle=yes +else + echo "$ac_t""no" 1>&6 + + echo $ac_n "checking for setproctitle in -lutil""... $ac_c" 1>&6 +echo "configure:5093: checking for setproctitle in -lutil" >&5 +ac_lib_var=`echo util'_'setproctitle | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lutil $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + have_setproctitle=yes + LUTIL_LIBS="$LUTIL_LIBS -lutil" +else + echo "$ac_t""no" 1>&6 +have_setproctitle=no + LIBOBJS="$LIBOBJS setproctitle.o" +fi + +fi + + + if test $have_setproctitle = yes ; then + cat >> confdefs.h <<\EOF +#define HAVE_SETPROCTITLE 1 +EOF + + fi +fi + echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:4695: checking for ANSI C header files" >&5 +echo "configure:5147: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -4704,7 +5156,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4708: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5160: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -4721,7 +5173,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -4739,7 +5191,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -4760,7 +5212,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -4771,7 +5223,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:4775: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5227: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then : else @@ -4804,12 +5256,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:4808: checking for $ac_hdr that defines DIR" >&5 +echo "configure:5260: checking for $ac_hdr that defines DIR" >&5 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> @@ -4817,7 +5269,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:4821: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5273: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -4842,7 +5294,7 @@ done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:4846: checking for opendir in -ldir" >&5 +echo "configure:5298: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4850,7 +5302,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:5317: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4883,7 +5335,7 @@ fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:4887: checking for opendir in -lx" >&5 +echo "configure:5339: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4891,7 +5343,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:5358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4925,12 +5377,12 @@ fi fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:4929: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:5381: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -4946,7 +5398,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:4950: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5402: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -4967,16 +5419,19 @@ EOF fi for ac_hdr in \ + stdarg.h \ stddef.h \ errno.h \ fcntl.h \ filio.h \ getopt.h \ + libutil.h \ limits.h \ malloc.h \ regex.h \ sgtty.h \ sys/file.h \ + sys/filio.h \ sys/errno.h \ sys/ioctl.h \ sys/param.h \ @@ -4991,17 +5446,17 @@ for ac_hdr in \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4995: checking for $ac_hdr" >&5 +echo "configure:5450: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5005: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5460: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -5029,12 +5484,12 @@ done echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:5033: checking for uid_t in sys/types.h" >&5 +echo "configure:5488: checking for uid_t in sys/types.h" >&5 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -5063,7 +5518,7 @@ EOF fi echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6 -echo "configure:5067: checking type of array argument to getgroups" >&5 +echo "configure:5522: checking type of array argument to getgroups" >&5 if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5071,7 +5526,7 @@ else ac_cv_type_getgroups=cross else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5555: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_type_getgroups=gid_t else @@ -5110,7 +5565,7 @@ fi if test $ac_cv_type_getgroups = cross; then cat > conftest.$ac_ext < EOF @@ -5134,12 +5589,12 @@ EOF echo $ac_n "checking for mode_t""... $ac_c" 1>&6 -echo "configure:5138: checking for mode_t" >&5 +echo "configure:5593: checking for mode_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -5167,12 +5622,12 @@ EOF fi echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:5171: checking for off_t" >&5 +echo "configure:5626: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -5200,12 +5655,12 @@ EOF fi echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:5204: checking for pid_t" >&5 +echo "configure:5659: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -5233,12 +5688,12 @@ EOF fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:5237: checking return type of signal handlers" >&5 +echo "configure:5692: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -5255,7 +5710,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:5259: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5714: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -5274,12 +5729,12 @@ EOF echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:5278: checking for size_t" >&5 +echo "configure:5733: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -5307,12 +5762,12 @@ EOF fi echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:5311: checking for uid_t in sys/types.h" >&5 +echo "configure:5766: checking for uid_t in sys/types.h" >&5 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -5341,12 +5796,12 @@ EOF fi echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6 -echo "configure:5345: checking for st_blksize in struct stat" >&5 +echo "configure:5800: checking for st_blksize in struct stat" >&5 if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -5354,7 +5809,7 @@ int main() { struct stat s; s.st_blksize; ; return 0; } EOF -if { (eval echo configure:5358: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5813: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_blksize=yes else @@ -5375,12 +5830,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:5379: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:5834: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -5389,7 +5844,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:5393: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5848: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -5410,12 +5865,12 @@ EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:5414: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:5869: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -5423,7 +5878,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:5427: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5882: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -5446,7 +5901,7 @@ fi echo $ac_n "checking if toupper() requires islower()""... $ac_c" 1>&6 -echo "configure:5450: checking if toupper() requires islower()" >&5 +echo "configure:5905: checking if toupper() requires islower()" >&5 if eval "test \"`echo '$''{'ol_cv_c_upper_lower'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5455,7 +5910,7 @@ else ol_cv_c_upper_lower=safe else cat > conftest.$ac_ext < @@ -5467,7 +5922,7 @@ main() exit(1); } EOF -if { (eval echo configure:5471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ol_cv_c_upper_lower=no else @@ -5490,12 +5945,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:5494: checking for working const" >&5 +echo "configure:5949: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6003: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -5567,7 +6022,7 @@ fi echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 -echo "configure:5571: checking for 8-bit clean memcmp" >&5 +echo "configure:6026: checking for 8-bit clean memcmp" >&5 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5575,7 +6030,7 @@ else ac_cv_func_memcmp_clean=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_func_memcmp_clean=yes else @@ -5603,12 +6058,12 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.o" echo $ac_n "checking for strftime""... $ac_c" 1>&6 -echo "configure:5607: checking for strftime" >&5 +echo "configure:6062: checking for strftime" >&5 if eval "test \"`echo '$''{'ac_cv_func_strftime'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6090: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_strftime=yes" else @@ -5653,7 +6108,7 @@ else echo "$ac_t""no" 1>&6 # strftime is in -lintl on SCO UNIX. echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6 -echo "configure:5657: checking for strftime in -lintl" >&5 +echo "configure:6112: checking for strftime in -lintl" >&5 ac_lib_var=`echo intl'_'strftime | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5661,7 +6116,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6131: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5699,12 +6154,12 @@ fi fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:5703: checking for vprintf" >&5 +echo "configure:6158: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6186: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -5751,12 +6206,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:5755: checking for _doprnt" >&5 +echo "configure:6210: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -5803,8 +6258,67 @@ fi fi + +if test $ac_cv_func_vprintf = yes ; then + for ac_func in vsnprintf +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:6267: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:6295: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + +fi + echo $ac_n "checking for wait3 that fills in rusage""... $ac_c" 1>&6 -echo "configure:5808: checking for wait3 that fills in rusage" >&5 +echo "configure:6322: checking for wait3 that fills in rusage" >&5 if eval "test \"`echo '$''{'ac_cv_func_wait3_rusage'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5812,7 +6326,7 @@ else ac_cv_func_wait3_rusage=no else cat > conftest.$ac_ext < #include @@ -5843,7 +6357,7 @@ main() { } } EOF -if { (eval echo configure:5847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6361: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_func_wait3_rusage=yes else @@ -5883,6 +6397,7 @@ for ac_func in \ setsid \ signal \ sigset \ + snprintf \ socket \ strerror \ strstr \ @@ -5897,12 +6412,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5901: checking for $ac_func" >&5 +echo "configure:6416: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5953,12 +6468,12 @@ done for ac_func in getopt strdup tempnam do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5957: checking for $ac_func" >&5 +echo "configure:6472: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6500: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6011,13 +6526,13 @@ done # Check Configuration echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6 -echo "configure:6015: checking declaration of sys_errlist" >&5 +echo "configure:6530: checking declaration of sys_errlist" >&5 if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -6027,7 +6542,7 @@ int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:6031: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6546: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_dcl_sys_errlist=yes else @@ -6048,20 +6563,20 @@ if test $ol_cv_dcl_sys_errlist = no ; then EOF echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6 -echo "configure:6052: checking existence of sys_errlist" >&5 +echo "configure:6567: checking existence of sys_errlist" >&5 if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:6065: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ol_cv_have_sys_errlist=yes else @@ -6101,6 +6616,12 @@ if test $ol_enable_dns != no ; then #define LDAP_DNS 1 EOF +fi +if test $ol_enable_proctitle != no ; then + cat >> confdefs.h <<\EOF +#define LDAP_PROCTITLE 1 +EOF + fi if test $ol_enable_referrals != no ; then cat >> confdefs.h <<\EOF @@ -6184,6 +6705,10 @@ if test $ol_enable_slurpd != no -a $ol_link_threads != no -a \ BUILD_SLURPD=yes fi +if test $ol_enable_ldapd != no ; then + BUILD_LDAPD=yes +fi + @@ -6645,7 +7170,10 @@ cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + date > stamp-h +echo Please \"make depend\" to build dependencies + exit 0 EOF chmod +x $CONFIG_STATUS diff --git a/configure.in b/configure.in index 8b82576720..314d59a9ab 100644 --- a/configure.in +++ b/configure.in @@ -24,11 +24,14 @@ AC_PREFIX_DEFAULT(/usr/local) dnl General "enable" options OL_ARG_ENABLE(debug,[ --enable-debug enable debugging], yes)dnl dnl OL_ARG_ENABLE(syslog,[ --enable-syslog enable syslog support], auto)dnl +OL_ARG_ENABLE(proctitle,[ --enable-proctitle enable proctitle support], yes)dnl OL_ARG_ENABLE(libui,[ --enable-libui enable library user interface], yes)dnl OL_ARG_ENABLE(cache,[ --enable-cache enable caching], yes)dnl -OL_ARG_ENABLE(dns,[ --enable-dns enable dns support], no)dnl +OL_ARG_ENABLE(dns,[ --enable-dns enable dns support], no)dnl OL_ARG_ENABLE(referrals,[ --enable-referrals enable referrals], yes)dnl OL_ARG_ENABLE(cldap,[ --enable-cldap enable connectionless ldap], no)dnl +OL_ARG_ENABLE(x_compile,[ --enable-x-compile enable cross compiling], + no, [yes no])dnl dnl General "with" options OL_ARG_WITH(kerberos,[ --with-kerberos use Kerberos], @@ -199,13 +202,27 @@ AC_PATH_PROG(FINGER, finger, /usr/ucb/finger, $PATH:/usr/ucb) dnl Checks the compiler and UNIX Variants AC_PROG_CC + +if test $cross_compiling = yes -a $ol_enable_x_compile = yes; then + AC_WARN([cross compiling.... go for it]) + +elif test $cross_compiling = no -a $ol_enable_x_compile = yes; then + AC_WARN([programs compiled here do run here...]) + AC_ERROR([ if not cross compiling, use --disable-x-compile.]) + +elif test $cross_compiling = yes -a $ol_enable_x_compile = no; then + AC_WARN([programs compiled here do not run here...]) + AC_ERROR([ if cross compiling, add --enable-x-compile.]) +fi + AC_PROG_GCC_TRADITIONAL +AC_PROG_CPP + AC_AIX AC_ISC_POSIX AC_MINIX -dnl ---------------------------------------------------------------- dnl Checks for libraries dnl Find socket() @@ -337,11 +354,11 @@ if test $ol_with_threads = auto -o $ol_with_threads = posix ; then AC_CHECK_LIB(pthread, pthread_create, [ AC_DEFINE(HAVE_DCE) ol_link_threads=posix - LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc"],, + LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc" if test $ol_with_preemptive = auto ; then ol_with_preemptive=yes fi - [-lmach -lexc -lc]) + ],,[-lmach -lexc -lc]) LIBS="$save_LIBS" fi @@ -360,19 +377,42 @@ if test $ol_with_threads = auto -o $ol_with_threads = posix ; then if test $ac_cv_func_sched_yield = no -a \ $ac_cv_func_pthread_yield = no ; then - + dnl Digital UNIX has sched_yield() in -lrt + AC_CHECK_LIB(rt, sched_yield, + [LTHREAD_LIBS="$LTHREAD_LIBS -lrt" + AC_DEFINE(HAVE_SCHED_YIELD,1) + ac_cv_func_sched_yield=yes], + [ac_cv_func_sched_yield=no]) + fi + if test $ac_cv_func_sched_yield = no -a \ + $ac_cv_func_pthread_yield = no ; then + dnl Solaris has sched_yield() in -lposix4 + AC_CHECK_LIB(posix4, sched_yield, + [LTHREAD_LIBS="$LTHREAD_LIBS -lposix4" + AC_DEFINE(HAVE_SCHED_YIELD,1) + ac_cv_func_sched_yield=yes], + [ac_cv_func_sched_yield=no]) + fi + if test $ac_cv_func_sched_yield = no -a \ + $ac_cv_func_pthread_yield = no ; then AC_MSG_WARN([could not locate sched_yield() or pthread_yield()]) AC_MSG_ERROR([POSIX Threads are not usable]) fi dnl Check functions for compatibility AC_CHECK_FUNCS(pthread_kill) -dnl AC_CHECK_FUNCS( +dnl AC_CHECK_FUNCS( \ dnl pthread_attr_create pthread_attr_init \ dnl pthread_attr_destroy pthread_attr_delete \ dnl pthread_attr_setdetachstate pthread_attr_setdetach_np \ dnl ) + dnl Check for setconcurreny functions + AC_CHECK_FUNCS( \ + pthread_setconcurrency \ + thr_setconcurrency \ + ) + dnl Check PREEMPTIVE Implementation if test $ol_with_preemptive = auto ; then AC_MSG_CHECKING([for preemptive Pthread implementation]) @@ -405,6 +445,14 @@ main(argc, argv) int argc; char **argv; { pthread_t t; + +#ifdef HAVE_PTHREAD_SETCONCURRENCY + (void) pthread_setconcurrency(2); +#elif HAVE_THR_SETCONCURRENCY + /* Set Solaris LWP concurrency to 2 */ + thr_setconcurrency(2); +#endif + pthread_create(&t, NULL, (void *) task, NULL); #if HAVE_SCHED_YIELD @@ -426,6 +474,17 @@ int argc; char **argv; fi fi +dnl dnl check for reentrant/threadsafe functions +dnl AC_CHECK_FUNCS( \ +dnl feof_unlocked \ +dnl unlocked_feof \ +dnl ftrylockfile \ +dnl flockfile \ +dnl putc_unlocked \ +dnl gmtime_r \ +dnl strtok_r \ +dnl ) + dnl restore DEFS/LIBS CPPFLAGS="$save_CPPFLAGS" LIBS="$save_LIBS" @@ -439,23 +498,52 @@ int argc; char **argv; fi fi -if test $ol_with_threads = auto -o $ol_with_threads = cthreads ; then +if test $ol_with_threads = auto -o $ol_with_threads = mach ; then dnl check for Mach CThreads AC_CHECK_HEADERS(mach/cthreads.h) - if test $ac_cv_header_lwp_lwp_h = yes ; then - AC_CHECK_LIB(lwp, cthread_fork, [have_cthreads=yes], [have_cthreads=no]) + if test $ac_cv_header_mach_cthreads_h = yes ; then + ol_with_threads=found - if test $have_cthreads = yes ; then - AC_DEFINE(HAVE_MACH_CTHREADS) - LTHREAD_LIBS="$LTHREAD_LIBS -llwp" + dnl A few platforms have cthread support in standard libraries + AC_CHECK_FUNC(cthread_fork,[ol_link_threads=yes]) + + if test $ol_link_threads = no ; then + dnl try -all_load + dnl this test needs work + AC_CACHE_CHECK([for cthread_fork with -all_load], + [ol_cv_cthread_all_load], [ + dnl save the CPPFLAGS + save_LIBS="$LIBS" + LIBS="-all_load $LIBS" + AC_TRY_LINK([#include ],[ + cthread_fork((void *)0, (void *)0); + ], ol_cv_cthread_all_load=yes, ol_cv_cthread_all_load=no) + dnl restore the LIBS + LIBS="$save_LIBS" + ]) + + if test $ol_cv_cthread_all_load = yes ; then + LTHREAD_LIBS="$LTHREAD_LIBS -all_load" + ol_link_threads=mach + fi + fi + + if test $ol_link_threads != no ; then + : check for cthread specific functionality here + else + AC_MSG_ERROR([could not link with Mach CThreads]) fi fi + + if test $ol_with_threads = mach ; then + AC_MSG_ERROR([could not locate Mach CThreads]) + fi fi if test $ol_with_threads = auto -o $ol_with_threads = lwp ; then dnl check for SunOS5 LWP AC_CHECK_HEADERS(thread.h synch.h) - if test $ac_cv_header_lwp_lwp_h = yes ; then + if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then AC_CHECK_LIB(thread, thr_create, [have_lwp=yes], [have_lwp=no]) if test $have_lwp = yes ; then @@ -470,7 +558,7 @@ if test $ol_with_threads = auto -o $ol_with_threads = lwp ; then dnl check for SunOS4 LWP AC_CHECK_HEADERS(lwp/lwp.h) - if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then + if test $ac_cv_header_lwp_lwp_h = yes ; then AC_CHECK_LIB(lwp, lwp_create, [have_lwp=yes], [have_lwp=no]) if test $have_lwp = yes ; then @@ -490,7 +578,7 @@ fi if test $ol_with_threads = manual ; then dnl User thinks he can manually configure threads. - $ol_link_threads=yes + ol_link_threads=yes AC_MSG_WARN([thread defines and link options must be set manually]) @@ -503,6 +591,18 @@ if test $ol_with_threads = manual ; then AC_CHECK_HEADERS(thread.h synch.h) fi +if test $ol_with_threads = yes ; then + dnl needed to get reentrant/threadsafe versions + dnl + dnl hopefully this will not cause problems with + dnl non-threaded apps + dnl + AC_DEFINE(_REENTRANT,1) + AC_DEFINE(_THREAD_SAFE,1) +fi + +dnl ---------------------------------------------------------------- + if test $ol_link_threads = no ; then if test $ol_with_threads = yes ; then AC_MSG_ERROR([no suitable thread support]) @@ -510,7 +610,7 @@ if test $ol_link_threads = no ; then if test $ol_with_threads = auto ; then AC_MSG_WARN([no suitable thread support, disabling threads]) - $ol_with_threads = no + ol_with_threads=no fi AC_DEFINE(NO_THREADS,1) @@ -563,7 +663,7 @@ fi if test $ol_with_ldbm_api = manual ; then dnl User thinks he can manually configure LDBM api. - $ol_link_ldbm=yes + ol_link_ldbm=yes AC_MSG_WARN([LDBM defines and link options must be set manually]) @@ -572,7 +672,7 @@ fi if test $ol_link_ldbm = no -a $ol_with_ldbm_type = btree ; then AC_MSG_WARN(Could not find LDBM with BTREE support) - $ol_with_ldbm_api=none + ol_with_ldbm_api=none fi if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then @@ -612,7 +712,7 @@ if test $ol_link_ldbm = no -a $ol_enable_ldbm != no ; then fi AC_MSG_WARN(disabling LDBM) - $ol_enable_ldbm=no + ol_enable_ldbm=no fi if test $ol_enable_wrappers = yes ; then @@ -668,7 +768,7 @@ if test $ol_enable_crypt != no ; then have_crypt=yes], [have_crypt=no])]) if test $have_crypt = yes ; then - AC_DEFINE(HAVE_CRYPT) + AC_DEFINE(HAVE_CRYPT,1) else AC_MSG_WARN(could not find crypt) if test $ol_enable_crypt = yes ; then @@ -680,6 +780,20 @@ if test $ol_enable_crypt != no ; then fi fi +# FreeBSD (and others) have setproctitle(3) in -lutil +if test $ol_enable_proctitle != no ; then + AC_CHECK_FUNC(setproctitle, [have_setproctitle=yes], [ + AC_CHECK_LIB(util, setproctitle, + [have_setproctitle=yes + LUTIL_LIBS="$LUTIL_LIBS -lutil"], + [have_setproctitle=no + LIBOBJS="$LIBOBJS setproctitle.o"])]) + + if test $have_setproctitle = yes ; then + AC_DEFINE(HAVE_SETPROCTITLE,1) + fi +fi + dnl ---------------------------------------------------------------- dnl Checks for header files. AC_HEADER_STDC @@ -691,16 +805,19 @@ fi AC_HEADER_DIRENT AC_HEADER_SYS_WAIT AC_CHECK_HEADERS( \ + stdarg.h \ stddef.h \ errno.h \ fcntl.h \ filio.h \ getopt.h \ + libutil.h \ limits.h \ malloc.h \ regex.h \ sgtty.h \ sys/file.h \ + sys/filio.h \ sys/errno.h \ sys/ioctl.h \ sys/param.h \ @@ -738,6 +855,12 @@ dnl Checks for library functions. AC_FUNC_MEMCMP AC_FUNC_STRFTIME AC_FUNC_VPRINTF + +if test $ac_cv_func_vprintf = yes ; then + dnl check for vsnprintf + AC_CHECK_FUNCS(vsnprintf) +fi + AC_FUNC_WAIT3 AC_CHECK_FUNCS( \ @@ -757,6 +880,7 @@ AC_CHECK_FUNCS( \ setsid \ signal \ sigset \ + snprintf \ socket \ strerror \ strstr \ @@ -794,6 +918,9 @@ fi if test $ol_enable_dns != no ; then AC_DEFINE(LDAP_DNS,1) fi +if test $ol_enable_proctitle != no ; then + AC_DEFINE(LDAP_PROCTITLE,1) +fi if test $ol_enable_referrals != no ; then AC_DEFINE(LDAP_REFERRALS,1) fi @@ -843,6 +970,10 @@ if test $ol_enable_slurpd != no -a $ol_link_threads != no -a \ BUILD_SLURPD=yes fi +if test $ol_enable_ldapd != no ; then + BUILD_LDAPD=yes +fi + dnl ---------------------------------------------------------------- AC_SUBST(BUILD_LDAPD) @@ -909,4 +1040,7 @@ servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/ servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \ servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \ tests/Makefile:build/top.mk:tests/Makefile.in \ -,[date > stamp-h]) +,[ +date > stamp-h +echo Please \"make depend\" to build dependencies +]) diff --git a/include/ac/setproctitle.h b/include/ac/setproctitle.h new file mode 100644 index 0000000000..ac1c6a2472 --- /dev/null +++ b/include/ac/setproctitle.h @@ -0,0 +1,18 @@ +/* Generic setproctitle.h */ + +#ifndef _AC_SETPROCTITLE_H +#define _AC_SETPROCTITLE_H + +#ifdef LDAP_PROCTITLE + +#if defined( HAVE_LIBUTIL_H ) +# include +#else + /* use lutil version */ + void setproctitle LDAP_P((const char *fmt, ...)); + extern int Argc; + extern char **Argv; +#endif + +#endif /* LDAP_PROCTITLE */ +#endif /* _AC_SETPROCTITLE_H */ diff --git a/include/ac/termios.h b/include/ac/termios.h new file mode 100644 index 0000000000..5590ab0df6 --- /dev/null +++ b/include/ac/termios.h @@ -0,0 +1,32 @@ +/* Generic termios.h */ + +#ifndef _AC_TERMIOS_H +#define _AC_TERMIOS_H + +#ifdef HAVE_TERMIOS_H +#include + +#define TERMIO_TYPE struct termios +#define TERMFLAG_TYPE tcflag_t +#define GETATTR( fd, tiop ) tcgetattr((fd), (tiop)) +#define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop)) +#define GETFLAGS( tio ) ((tio).c_lflag) +#define SETFLAGS( tio, flags ) ((tio).c_lflag = (flags)) + +#elif defined( HAVE_SGTTY_H ) +#include + +#ifdef HAVE_SYS_IOCTL_H +#include +#endif + +#define TERMIO_TYPE struct sgttyb +#define TERMFLAG_TYPE int +#define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop)) +#define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop)) +#define GETFLAGS( tio ) ((tio).sg_flags) +#define SETFLAGS( tio, flags ) ((tio).sg_flags = (flags)) + +#endif /* HAVE_SGTTY_H */ + +#endif /* _AC_TERMIOS_H */ diff --git a/include/lutil.h b/include/lutil.h new file mode 100644 index 0000000000..6f14d55980 --- /dev/null +++ b/include/lutil.h @@ -0,0 +1,19 @@ +#ifndef _LUTIL_H +#define _LUTIL_H 1 + +#include +/* + * Include file for LDAP utility routine + */ + +/* ISC Base64 Routines */ + +LDAP_BEGIN_DECL + +LDAP_F int b64_ntop LDAP_P((u_char const *, size_t, char *, size_t)); +LDAP_F int b64_pton LDAP_P((char const *, u_char *, size_t)); +LDAP_F void lutil_detach LDAP_P((int debug, int do_close)); + +LDAP_END_DECL + +#endif /* _LUTIL_H */ diff --git a/include/portable.h.bot b/include/portable.h.bot new file mode 100644 index 0000000000..5994b21299 --- /dev/null +++ b/include/portable.h.bot @@ -0,0 +1,11 @@ +/* portable.h.bot begin */ + +#ifdef HAVE_STDDEF_H +# include +#endif + +#include "ldap_cdefs.h" + +#endif /* _LDAP_PORTABLE_H */ + +/* portable.h.bot end */ diff --git a/include/portable.h.in b/include/portable.h.in index 6cf19e1f3f..8f954665e6 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -1,4 +1,5 @@ /* include/portable.h.in. Generated automatically from configure.in by autoheader. */ +/* portable.h.top begin */ /* Copyright 1998 The OpenLDAP Foundation, Redwood City, California, USA All rights reserved. @@ -31,6 +32,7 @@ is provided ``as is'' without express or implied warranty. #ifndef _LDAP_PORTABLE_H #define _LDAP_PORTABLE_H +/* portable.h.top end */ /* Define if on AIX 3. System headers sometimes define this. @@ -104,6 +106,12 @@ is provided ``as is'' without express or implied warranty. /* Define to `int' if doesn't define. */ #undef uid_t +/* define this if needed to get reentrant functions */ +#undef _REENTRANT + +/* define this if needed to get threadsafe functions */ +#undef _THREAD_SAFE + /* define this if toupper() requires tolower() check */ #undef C_UPPER_LOWER @@ -140,9 +148,6 @@ is provided ``as is'' without express or implied warranty. /* define if you have NDBM */ #undef HAVE_NDBM -/* define if you have Mach CThreads */ -#undef HAVE_MACH_CTHREADS - /* define if you have a preemptive POSIX Threads implementation */ #undef HAVE_PREEMPTIVE_PTHREADS @@ -155,6 +160,15 @@ is provided ``as is'' without express or implied warranty. /* define if your POSIX Threads implementation is circa Draft 4 */ #undef HAVE_PTHREADS_D4 +/* define if you have sched_yield() */ +#ifdef __notdef__ +/* see second sched_yield define */ +#undef HAVE_SCHED_YIELD +#endif + +/* define if you have setproctitle() */ +#undef HAVE_SETPROCTITLE + /* define if you have -lwrap */ #undef HAVE_TCPD @@ -176,6 +190,9 @@ is provided ``as is'' without express or implied warranty. /* define this to remove -lldap cache support */ #undef LDAP_NOCACHE +/* define this for LDAP process title support */ +#undef LDAP_PROCTITLE + /* define this for LDAP referrals support */ #undef LDAP_REFERRALS @@ -260,6 +277,9 @@ is provided ``as is'' without express or implied warranty. /* Define if you have the pthread_kill function. */ #undef HAVE_PTHREAD_KILL +/* Define if you have the pthread_setconcurrency function. */ +#undef HAVE_PTHREAD_SETCONCURRENCY + /* Define if you have the pthread_yield function. */ #undef HAVE_PTHREAD_YIELD @@ -281,6 +301,9 @@ is provided ``as is'' without express or implied warranty. /* Define if you have the sigset function. */ #undef HAVE_SIGSET +/* Define if you have the snprintf function. */ +#undef HAVE_SNPRINTF + /* Define if you have the socket function. */ #undef HAVE_SOCKET @@ -314,6 +337,12 @@ is provided ``as is'' without express or implied warranty. /* Define if you have the tempnam function. */ #undef HAVE_TEMPNAM +/* Define if you have the thr_setconcurrency function. */ +#undef HAVE_THR_SETCONCURRENCY + +/* Define if you have the vsnprintf function. */ +#undef HAVE_VSNPRINTF + /* Define if you have the waitpid function. */ #undef HAVE_WAITPID @@ -353,6 +382,9 @@ is provided ``as is'' without express or implied warranty. /* Define if you have the header file. */ #undef HAVE_KRB_H +/* Define if you have the header file. */ +#undef HAVE_LIBUTIL_H + /* Define if you have the header file. */ #undef HAVE_LIMITS_H @@ -386,6 +418,9 @@ is provided ``as is'' without express or implied warranty. /* Define if you have the header file. */ #undef HAVE_SGTTY_H +/* Define if you have the header file. */ +#undef HAVE_STDARG_H + /* Define if you have the header file. */ #undef HAVE_STDDEF_H @@ -401,6 +436,9 @@ is provided ``as is'' without express or implied warranty. /* Define if you have the header file. */ #undef HAVE_SYS_FILE_H +/* Define if you have the header file. */ +#undef HAVE_SYS_FILIO_H + /* Define if you have the header file. */ #undef HAVE_SYS_IOCTL_H @@ -457,6 +495,7 @@ is provided ``as is'' without express or implied warranty. /* Define if you have the socket library (-lsocket). */ #undef HAVE_LIBSOCKET +/* portable.h.bot begin */ #ifdef HAVE_STDDEF_H # include @@ -465,3 +504,5 @@ is provided ``as is'' without express or implied warranty. #include "ldap_cdefs.h" #endif /* _LDAP_PORTABLE_H */ + +/* portable.h.bot end */ diff --git a/include/portable.h.nt b/include/portable.h.nt new file mode 100644 index 0000000000..9d78330308 --- /dev/null +++ b/include/portable.h.nt @@ -0,0 +1,528 @@ +/* include/portable.h.nt -- manually updated of MS NT (MS VC5) */ +/* synced with portable.h.in 1.8 */ +/* +Copyright 1998 The OpenLDAP Foundation, Redwood City, California, USA +All rights reserved. + +Redistribution and use in source and binary forms are permitted only +as authorized by the OpenLDAP Public License. A copy of this +license is available at http://www.OpenLDAP.org/license.html or +in file LICENSE in the top-level directory of the distribution. + +This work is derived from the University of Michigan LDAP v3.3 +distribution. Information concerning is available at + http://www.umich.edu/~dirsvcs/ldap/ldap.html. + +This work also contains materials derived from public sources. + +--- + +Portions Copyright (c) 1992-1996 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. + +*/ + +#ifndef _LDAP_PORTABLE_H +#define _LDAP_PORTABLE_H + +/* we installed Henry Spencer's REGEX */ +#define HAVE_REGEX_H 1 + +/* win32 specific stuff */ +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define strdup _strdup + +/* define type for caddr_t */ +typedef char * caddr_t; + +/* we have winsock2 */ +#define HAVE_WINSOCK2 1 + +/* we have winsock */ +#define HAVE_WINSOCK 1 + +/* we have */ +#define HAVE_IO_H 1 + +/* we have */ +#define HAVE_PROCESS_H 1 + +/* --------------------------------------------------- */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define to the type of elements in the array set by `getgroups'. + Usually this is either `int' or `gid_t'. */ +/* #undef GETGROUPS_T */ + +/* Define to `int' if doesn't define. */ +#define gid_t long + +/* Define if you don't have vprintf but do have _doprnt. */ +/* #undef HAVE_DOPRNT */ + +/* Define if your struct stat has st_blksize. */ +/* #undef HAVE_ST_BLKSIZE */ + +/* Define if you have the strftime function. */ +#define HAVE_STRFTIME 1 + +/* Define if you have that is POSIX.1 compatible. */ +/* #undef HAVE_SYS_WAIT_H */ + +/* Define if you have the tempnam function. */ +/* #undef HAVE_TEMPNAM */ + +/* Define if you have the thr_setconcurrency function. */ +/* #undef HAVE_THR_SETCONCURRENCY */ + +/* Define if you have the vprintf function. */ +#define HAVE_VPRINTF 1 + +/* Define if you have the vsnprintf function. */ +/* #undef HAVE_VSNPRINTF */ + +/* Define if you have the wait3 system call. */ +/* #undef HAVE_WAIT3 */ + +/* Define if on MINIX. */ +/* #undef _MINIX */ + +/* Define to `int' if doesn't define. */ +#define mode_t int + +/* Define to `long' if doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if doesn't define. */ +#define pid_t int + +/* Define if the system does not provide POSIX.1 features except + with this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and . */ +/* #undef TIME_WITH_SYS_TIME */ + +/* Define if your declares struct tm. */ +/* #undef TM_IN_SYS_TIME */ + +/* define this if needed to get reentrant functions */ +#undef _REENTRANT + +/* define this if needed to get threadsafe functions */ +#undef _THREAD_SAFE + +/* Define to `int' if doesn't define. */ +#define uid_t long + +/* define this if toupper() requires tolower() */ +#define C_UPPER_LOWER + +/* define this if sys_errlist is not defined in stdio.h or errno.h */ +/* #undef DECL_SYS_ERRLIST */ + +/* define if you have berkeley db */ +/* #undef HAVE_BERKELEY_DB */ + +/* define if you have berkeley db2 */ +/* #undef HAVE_BERKELEY_DB2 */ + +/* define if you have crypt */ +/* #undef HAVE_CRYPT */ + +/* define if you have DCE */ +/* #undef HAVE_DCE */ + +/* define if you have GDBM */ +/* #undef HAVE_GDBM */ + +/* define if you have Kerberos */ +/* #undef HAVE_KERBEROS */ + +/* define if you have LinuxThreads */ +/* #undef HAVE_LINUX_THREADS */ + +/* define if you have Sun LWP (SunOS style) */ +/* #undef HAVE_LWP */ + +/* define if you have -lncurses */ +/* #undef HAVE_NCURSES */ + +/* define if you have NDBM */ +/* #undef HAVE_NDBM */ + +/* define if you have Mach CThreads */ +/* #undef HAVE_MACH_CTHREADS */ + +/* define if you have a preemptive POSIX Threads implementation */ +/* #undef HAVE_PREEMPTIVE_PTHREADS */ + +/* define if you have POSIX Threads */ +/* #undef HAVE_PTHREADS */ + +/* define if your POSIX Threads implementatin is circa Draft 4 */ +/* #undef HAVE_PTHREADS_D4 */ + +/* define if you have sched_yield() */ +#ifdef __notdef__ +/* see second sched_yield define */ +/* #undef HAVE_SCHED_YIELD */ +#endif + +/* define if you have setproctitle() */ +#undef HAVE_SETPROCTITLE + +/* define if you have -lwrap */ +/* #undef HAVE_TCPD */ + +/* define if you have -ltermcap */ +/* #undef HAVE_TERMCAP */ + +/* define if you have Solaris LWP Threads */ +/* #undef HAVE_THR */ + +/* define this for connectionless LDAP support */ +/* #undef LDAP_CONNECTIONLESS */ + +/* define this to add debugging code */ +#define LDAP_DEBUG 1 + +/* define this for LDAP DNS support */ +/* #undef LDAP_DNS */ + +/* define this to remove -lldap cache support */ +/* #undef LDAP_NOCACHE */ + +/* define this for LDAP process title support */ +/* #undef LDAP_PROCTITLE */ + +/* define this for LDAP referrals support */ +#define LDAP_REFERRALS 1 + +/* define this for LDAP User Interface support */ +/* #undef LDAP_LIBUI */ + +/* define this to use DBBTREE w/ LDBM backend */ +/* #undef LDBM_USE_DBBTREE */ + +/* define this to use DBHASH w/ LDBM backend */ +/* #undef LDBM_USE_DBHASH */ + +/* define this if you want no termcap support */ +#define NO_TERMCAP 1 + +/* define this if you want no thread support */ +#define NO_THREADS 1 + +/* define this if the thread package is preemptive */ +#define PREEMPTIVE_THREADS 1 + +/* define this for ACL Group support */ +#define SLAPD_ACLGROUPS + +/* define this for crypt(3) password support */ +/* #undef SLAPD_CRYPT */ + +/* define this to use SLAPD LDBM backend */ +/* #undef SLAPD_LDBM */ + +/* define this for MD5 password support */ +#define SLAPD_MD5 1 + +/* define this to use SLAPD passwd backend */ +/* #undef SLAPD_PASSWD */ + +/* define this for phonetic support */ +/* #undef SLAPD_PHONETIC */ + +/* define this for Reverse Lookup support */ +#define SLAPD_RLOOKUPS 1 + +/* define this for SHA1 password support */ +#define SLAPD_SHA1 1 + +/* define this to use SLAPD shell backend */ +/* #undef SLAPD_SHELL */ + +/* Define if you have the bcopy function. */ +/* #undef HAVE_BCOPY */ + +/* Define if you have the flock function. */ +/* #undef HAVE_FLOCK */ + +/* Define if you have the getdtablesize function. */ +/* #undef HAVE_GETDTABLESIZE */ + +/* Define if you have the gethostname function. */ +#define HAVE_GETHOSTNAME 1 + +/* define if you have the getopt function */ +/* #undef HAVE_GETOPT */ + +/* Define if you have the gettimeofday function. */ +/* #undef HAVE_GETTIMEOFDAY */ + +/* Define if you have the lockf function. */ +/* #undef HAVE_LOCKF */ + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY 1 + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE 1 + +/* Define if you have the mkstemp function. */ +/* #undef HAVE_MKSTEMP */ + +/* Define if you have the mktime function. */ +#define HAVE_MKTIME 1 + +/* Define if you have the pthread_kill function. */ +/* #undef HAVE_PTHREAD_KILL */ + +/* Define if you have the pthread_setconcurrency function. */ +/* #undef HAVE_PTHREAD_SETCONCURRENCY */ + +/* Define if you have the pthread_yield function. */ +/* #undef HAVE_PTHREAD_YIELD */ + +/* Define if you have the sched_yield function. */ +/* #undef HAVE_SCHED_YIELD */ + +/* Define if you have the select function. */ +#define HAVE_SELECT 1 + +/* Define if you have the setpwfile function. */ +/* #undef HAVE_SETPWFILE */ + +/* Define if you have the setsid function. */ +/* #undef HAVE_SETSID */ + +/* Define if you have the signal function. */ +#define HAVE_SIGNAL 1 + +/* Define if you have the sigset function. */ +/* #undef HAVE_SIGSET */ + +/* Define if you have the snprintf function. */ +/* #undef HAVE_SNPRINTF */ + +/* Define if you have the socket function. */ +#define HAVE_SOCKET 1 + +/* Define if you have the strdup function. */ +#define HAVE_STRDUP 1 + +/* Define if you have the strerror function. */ +#define HAVE_STRERROR 1 + +/* Define if you have the strrchr function. */ +#define HAVE_STRRCHR 1 + +/* Define if you have the strsep function. */ +/* #undef HAVE_STRSEP */ + +/* Define if you have the strstr function. */ +#define HAVE_STRSTR 1 + +/* Define if you have the strtod function. */ +#define HAVE_STRTOD 1 + +/* Define if you have the strtol function. */ +#define HAVE_STRTOL 1 + +/* Define if you have the strtoul function. */ +#define HAVE_STRTOUL 1 + +/* Define if you have the sysconf function. */ +/* #undef HAVE_SYSCONF */ + +/* Define if you have the waitpid function. */ +#define HAVE_WAITPID 1 + +/* Define if you have the header file. */ +/* #undef HAVE_DB_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_DB_185_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_DES_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_DIRENT_H */ + +/* Define if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_FILIO_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_GDBM_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_GETOPT_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_KERBEROSIV_DES_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_KERBEROSIV_KRB_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_KRB_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_LWP_LWP_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_MACH_CTHREADS_H */ + +/* Define if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_NDBM_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_PTHREAD_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_REGEX_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SCHED_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SGTTY_H */ + +/* Define if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_SYNCH_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_ERRNO_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_FILE_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_FILIO_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_IOCTL_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_PARAM_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_SOCKET_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_SYSLOG_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_TIME_H */ + +/* Define if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_SYSLOG_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_TERMCAP_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_TERMIOS_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_UNISTD_H */ + +/* Define if you have the V3 library (-lV3). */ +/* #undef HAVE_LIBV3 */ + +/* Define if you have the gen library (-lgen). */ +/* #undef HAVE_LIBGEN */ + +/* Define if you have the inet library (-linet). */ +/* #undef HAVE_LIBINET */ + +/* Define if you have the net library (-lnet). */ +/* #undef HAVE_LIBNET */ + +/* Define if you have the nsl library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define if you have the nsl_s library (-lnsl_s). */ +/* #undef HAVE_LIBNSL_S */ + +/* Define if you have the socket library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +#ifdef HAVE_STDDEF_H +# include +#endif + +#include "ldap_cdefs.h" + +#endif /* _LDAP_PORTABLE_H */ diff --git a/include/portable.h.top b/include/portable.h.top new file mode 100644 index 0000000000..4f413c0da5 --- /dev/null +++ b/include/portable.h.top @@ -0,0 +1,34 @@ +/* portable.h.top begin */ +/* +Copyright 1998 The OpenLDAP Foundation, Redwood City, California, USA +All rights reserved. + +Redistribution and use in source and binary forms are permitted only +as authorized by the OpenLDAP Public License. A copy of this +license is available at http://www.OpenLDAP.org/license.html or +in file LICENSE in the top-level directory of the distribution. + +This work is derived from the University of Michigan LDAP v3.3 +distribution. Information concerning is available at + http://www.umich.edu/~dirsvcs/ldap/ldap.html. + +This work also contains materials derived from public sources. + +--- + +Portions Copyright (c) 1992-1996 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. + +*/ + +#ifndef _LDAP_PORTABLE_H +#define _LDAP_PORTABLE_H + +/* portable.h.top end */ diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index a722c9eb7a..80f11de436 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -11,45 +11,30 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include -#ifdef MACOS -#include -#include -#include "macos.h" -#else /* MACOS */ -#if defined(NeXT) || defined(VMS) + +#ifdef STDC_HEADERS #include -#else /* next || vms */ -#include -#endif /* next || vms */ -#if defined(BC31) || defined(_WIN32) +#endif + +#if defined( HAVE_STDARG_H ) && __STDC__ #include -#else /* BC31 || _WIN32 */ +#else #include -#endif /* BC31 || _WIN32 */ -#include -#include -#include -#ifdef PCNFS -#include -#endif /* PCNFS */ -#endif /* MACOS */ - -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS */ - -#include +#endif + +#include +#include + #include "lber.h" #ifdef LDAP_DEBUG int lber_debug; #endif -#ifdef NEEDPROTOS -static int ber_getnint( BerElement *ber, long *num, int len ); -#endif /* NEEDPROTOS */ - +static int ber_getnint LDAP_P(( BerElement *ber, long *num, int len )); /* return the tag - LBER_DEFAULT returned means trouble */ unsigned long @@ -58,7 +43,7 @@ ber_get_tag( BerElement *ber ) unsigned char xbyte; unsigned long tag; char *tagp; - int i; + unsigned int i; if ( ber_read( ber, (char *) &xbyte, 1 ) != 1 ) return( LBER_DEFAULT ); @@ -129,7 +114,7 @@ ber_skip_tag( BerElement *ber, unsigned long *len ) if ( ber_read( ber, (char *) &netlen + diff, noctets ) != noctets ) return( LBER_DEFAULT ); - *len = LBER_NTOHL( netlen ); + *len = AC_NTOHL( netlen ); } else { *len = lc; } @@ -155,6 +140,7 @@ ber_getnint( BerElement *ber, long *num, int len ) { int diff, sign, i; long netnum; + char *p; /* * The tag and length have already been stripped off. We should @@ -172,14 +158,15 @@ ber_getnint( BerElement *ber, long *num, int len ) if ( ber_read( ber, ((char *) &netnum) + diff, len ) != len ) return( -1 ); - /* sign extend if necessary */ - sign = ((0x80 << ((len - 1) * 8)) & netnum); - if ( sign && len < sizeof(long) ) { - for ( i = sizeof(long) - 1; i > len - 1; i-- ) { - netnum |= (0xffL << (i * 8)); + /* sign extend if necessary */ + p = (char *) &netnum; + sign = (0x80 & *(p+diff) ); + if ( sign && len < sizeof(long) ) { + for ( i = 0; i < diff; i++ ) { + *(p+i) = (unsigned char) 0xff; } } - *num = LBER_NTOHL( netnum ); + *num = AC_NTOHL( netnum ); return( len ); } @@ -192,7 +179,7 @@ ber_get_int( BerElement *ber, long *num ) if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT ) return( LBER_DEFAULT ); - if ( ber_getnint( ber, num, (int)len ) != len ) + if ( (unsigned long) ber_getnint( ber, num, (int)len ) != len ) return( LBER_DEFAULT ); else return( tag ); @@ -211,7 +198,7 @@ ber_get_stringb( BerElement *ber, char *buf, unsigned long *len ) if ( datalen > (*len - 1) ) return( LBER_DEFAULT ); - if ( ber_read( ber, buf, datalen ) != datalen ) + if ( (unsigned long) ber_read( ber, buf, datalen ) != datalen ) return( LBER_DEFAULT ); buf[datalen] = '\0'; @@ -250,7 +237,7 @@ ber_get_stringa( BerElement *ber, char **buf ) if ( (*buf = (char *) malloc( (size_t)datalen + 1 )) == NULL ) return( LBER_DEFAULT ); - if ( ber_read( ber, *buf, datalen ) != datalen ) + if ( (unsigned long) ber_read( ber, *buf, datalen ) != datalen ) return( LBER_DEFAULT ); (*buf)[datalen] = '\0'; @@ -283,7 +270,7 @@ ber_get_stringal( BerElement *ber, struct berval **bv ) if ( ((*bv)->bv_val = (char *) malloc( (size_t)len + 1 )) == NULL ) return( LBER_DEFAULT ); - if ( ber_read( ber, (*bv)->bv_val, len ) != len ) + if ( (unsigned long) ber_read( ber, (*bv)->bv_val, len ) != len ) return( LBER_DEFAULT ); ((*bv)->bv_val)[len] = '\0'; (*bv)->bv_len = len; @@ -320,7 +307,7 @@ ber_get_bitstringa( BerElement *ber, char **buf, unsigned long *blen ) if ( ber_read( ber, (char *)&unusedbits, 1 ) != 1 ) return( LBER_DEFAULT ); - if ( ber_read( ber, *buf, datalen ) != datalen ) + if ( (unsigned long) ber_read( ber, *buf, datalen ) != datalen ) return( LBER_DEFAULT ); *blen = datalen * 8 - unusedbits; @@ -382,16 +369,16 @@ ber_next_element( BerElement *ber, unsigned long *len, char *last ) /* VARARGS */ unsigned long -ber_scanf( -#if defined( MACOS ) || defined( BC31 ) || defined( _WIN32 ) - BerElement *ber, char *fmt, ... ) +ber_scanf +#if defined( HAVE_STDARG_H ) && __STDC__ + ( BerElement *ber, char *fmt, ... ) #else - va_alist ) + ( va_alist ) va_dcl #endif { va_list ap; -#if !defined( MACOS ) && !defined( BC31 ) && !defined( _WIN32 ) +#if !(defined( HAVE_STDARG_H ) && __STDC__) BerElement *ber; char *fmt; #endif @@ -399,10 +386,10 @@ va_dcl char *s, **ss, ***sss; struct berval ***bv, **bvp, *bval; int *i, j; - long *l, rc, tag; - unsigned long len; + long *l; + unsigned long rc, tag, len; -#if defined( MACOS ) || defined( BC31 ) || defined( _WIN32 ) +#if defined( HAVE_STDARG_H ) && __STDC__ va_start( ap, fmt ); #else va_start( ap ); @@ -536,9 +523,9 @@ va_dcl break; default: -#ifndef NO_USERINTERFACE +#ifdef LDAP_LIBUI fprintf( stderr, "unknown fmt %c\n", *fmt ); -#endif /* NO_USERINTERFACE */ +#endif /* LDAP_LIBUI */ rc = LBER_DEFAULT; break; } diff --git a/libraries/liblber/encode.c b/libraries/liblber/encode.c index cd95f8932b..f2aee16a79 100644 --- a/libraries/liblber/encode.c +++ b/libraries/liblber/encode.c @@ -11,45 +11,32 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include -#ifdef MACOS -#include -#include -#include "macos.h" -#else /* MACOS */ -#if defined(NeXT) || defined(VMS) #include -#else /* next || vms */ -#include -#endif /* next || vms */ -#if defined( BC31 ) || defined( _WIN32 ) + +#if defined( HAVE_STDARG_H ) && __STDC__ #include -#else /* BC31 || _WIN32 */ +#else #include -#endif /* BC31 || _WIN32 */ -#include -#include -#include -#ifdef PCNFS -#include -#endif /* PCNFS */ -#endif /* MACOS */ -#ifndef VMS -#include #endif -#include + +#include +#include + #include "lber.h" -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS */ +static int ber_put_len LDAP_P(( BerElement *ber, + unsigned long len, int nosos )); -#ifdef NEEDPROTOS -static int ber_put_len( BerElement *ber, unsigned long len, int nosos ); -static int ber_start_seqorset( BerElement *ber, unsigned long tag ); -static int ber_put_seqorset( BerElement *ber ); -static int ber_put_int_or_enum( BerElement *ber, long num, unsigned long tag ); -#endif /* NEEDPROTOS */ +static int ber_start_seqorset LDAP_P(( BerElement *ber, + unsigned long tag )); + +static int ber_put_seqorset LDAP_P(( BerElement *ber )); + +static int ber_put_int_or_enum LDAP_P(( BerElement *ber, + long num, unsigned long tag )); static int @@ -77,7 +64,7 @@ ber_put_tag( BerElement *ber, unsigned long tag, int nosos ) taglen = ber_calc_taglen( tag ); - ntag = LBER_HTONL( tag ); + ntag = AC_HTONL( tag ); return( ber_write( ber, ((char *) &ntag) + sizeof(long) - taglen, taglen, nosos ) ); @@ -123,7 +110,7 @@ ber_put_len( BerElement *ber, unsigned long len, int nosos ) */ if ( len <= 127 ) { - netlen = LBER_HTONL( len ); + netlen = AC_HTONL( len ); return( ber_write( ber, (char *) &netlen + sizeof(long) - 1, 1, nosos ) ); } @@ -140,7 +127,7 @@ ber_put_len( BerElement *ber, unsigned long len, int nosos ) if ( len & mask ) break; } - lenlen = ++i; + lenlen = (unsigned char) ++i; if ( lenlen > 4 ) return( -1 ); lenlen |= 0x80; @@ -150,7 +137,7 @@ ber_put_len( BerElement *ber, unsigned long len, int nosos ) return( -1 ); /* write the length itself */ - netlen = LBER_HTONL( len ); + netlen = AC_HTONL( len ); if ( ber_write( ber, (char *) &netlen + (sizeof(long) - i), i, nosos ) != i ) return( -1 ); @@ -201,7 +188,7 @@ ber_put_int_or_enum( BerElement *ber, long num, unsigned long tag ) if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 ) return( -1 ); i++; - netnum = LBER_HTONL( num ); + netnum = AC_HTONL( num ); if ( ber_write( ber, (char *) &netnum + (sizeof(long) - i), i, 0 ) != i ) return( -1 ); @@ -257,7 +244,7 @@ ber_put_ostring( BerElement *ber, char *str, unsigned long len, #endif /* STR_TRANSLATION */ if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 || - ber_write( ber, str, len, 0 ) != len ) { + (unsigned long) ber_write( ber, str, len, 0 ) != len ) { rc = -1; } else { /* return length of tag + length + contents */ @@ -293,7 +280,7 @@ ber_put_bitstring( BerElement *ber, char *str, return( -1 ); len = ( blen + 7 ) / 8; - unusedbits = len * 8 - blen; + unusedbits = (unsigned char) ((len * 8) - blen); if ( (lenlen = ber_put_len( ber, len + 1, 0 )) == -1 ) return( -1 ); @@ -409,7 +396,7 @@ ber_put_seqorset( BerElement *ber ) */ len = (*sos)->sos_clen; - netlen = LBER_HTONL( len ); + netlen = AC_HTONL( len ); if ( sizeof(long) > 4 && len > 0xFFFFFFFFL ) return( -1 ); @@ -458,12 +445,14 @@ ber_put_seqorset( BerElement *ber ) /* the tag */ taglen = ber_calc_taglen( (*sos)->sos_tag ); - ntag = LBER_HTONL( (*sos)->sos_tag ); + ntag = AC_HTONL( (*sos)->sos_tag ); SAFEMEMCPY( (*sos)->sos_first, (char *) &ntag + sizeof(long) - taglen, taglen ); if ( ber->ber_options & LBER_USE_DER ) { - ltag = (lenlen == 1) ? len : 0x80 + (lenlen - 1); + ltag = (lenlen == 1) + ? (unsigned char) len + : 0x80 + (lenlen - 1); } /* one byte of length length */ @@ -519,31 +508,31 @@ ber_put_set( BerElement *ber ) /* VARARGS */ int -ber_printf( -#if defined( MACOS ) || defined( _WIN32 ) || defined( BC31 ) - BerElement *ber, char *fmt, ... ) -#else /* MACOS || _WIN32 || BC31 */ - va_alist ) +ber_printf +#if defined( HAVE_STDARG_H ) && __STDC__ + ( BerElement *ber, char *fmt, ... ) +#else + ( va_alist ) va_dcl -#endif /* MACOS || _WIN32 || BC31 */ +#endif { va_list ap; -#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( BC31 ) +#if !(defined( HAVE_STDARG_H ) && __STDC__) BerElement *ber; char *fmt; -#endif /* !MACOS && !_WIN32 && !BC31 */ +#endif char *s, **ss; struct berval **bv; int rc, i; unsigned long len; -#if defined( MACOS ) || defined( _WIN32 ) || defined( BC31 ) +#if defined( HAVE_STDARG_H ) && __STDC__ va_start( ap, fmt ); -#else /* MACOS || _WIN32 || BC31 */ +#else va_start( ap ); ber = va_arg( ap, BerElement * ); fmt = va_arg( ap, char * ); -#endif /* MACOS || _WIN32 || BC31 */ +#endif for ( rc = 0; *fmt && rc != -1; fmt++ ) { switch ( *fmt ) { @@ -625,9 +614,9 @@ va_dcl break; default: -#ifndef NO_USERINTERFACE +#ifdef LDAP_LIBUI fprintf( stderr, "unknown fmt %c\n", *fmt ); -#endif /* NO_USERINTERFACE */ +#endif /* LDAP_LIBUI */ rc = -1; break; } diff --git a/libraries/liblber/io.c b/libraries/liblber/io.c index 081f386794..2130c29502 100644 --- a/libraries/liblber/io.c +++ b/libraries/liblber/io.c @@ -11,54 +11,29 @@ * is provided ``as is'' without express or implied warranty. */ -#include -#include - -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS || _WIN32 */ +#include "portable.h" -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined(NeXT) || defined(VMS) +#include #include -#else /* next || vms */ -#include -#endif /* next || vms */ -#include -#include -#include -#include -#ifdef PCNFS -#include -#endif /* PCNFS */ -#endif /* MACOS */ -#ifndef VMS -#include -#endif -#include -#include "lber.h" +#include +#include +#include +#include +#include -#ifdef _WIN32 -#include +#ifdef HAVE_IO_H #include -#endif /* _WIN32 */ +#endif + +#include "lber.h" -#ifdef NEEDPROTOS -static int ber_realloc( BerElement *ber, unsigned long len ); -static int ber_filbuf( Sockbuf *sb, long len ); -static long BerRead( Sockbuf *sb, char *buf, long len ); +static int ber_realloc LDAP_P(( BerElement *ber, unsigned long len )); +static int ber_filbuf LDAP_P(( Sockbuf *sb, long len )); +static long BerRead LDAP_P(( Sockbuf *sb, char *buf, long len )); #ifdef PCNFS -static int BerWrite( Sockbuf *sb, char *buf, long len ); +static int BerWrite LDAP_P(( Sockbuf *sb, char *buf, long len )); #endif /* PCNFS */ -#else -int ber_filbuf(); -long BerRead(); -static int ber_realloc(); -#endif /* NEEDPROTOS */ #define bergetc( sb, len ) ( sb->sb_ber.ber_end > sb->sb_ber.ber_ptr ? \ (unsigned char)*sb->sb_ber.ber_ptr++ : \ @@ -134,9 +109,9 @@ int ber_filbuf( Sockbuf *sb, long len ) { short rc; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS int addrlen; -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ if ( sb->sb_ber.ber_buf == NULL ) { if ( (sb->sb_ber.ber_buf = (char *) malloc( READBUFSIZ )) == @@ -147,7 +122,7 @@ ber_filbuf( Sockbuf *sb, long len ) } if ( sb->sb_naddr > 0 ) { -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS rc = udp_read(sb, sb->sb_ber.ber_buf, READBUFSIZ, addrlen ); #ifdef LDAP_DEBUG if ( lber_debug ) { @@ -157,14 +132,13 @@ ber_filbuf( Sockbuf *sb, long len ) lber_bprint( sb->sb_ber.ber_buf, rc ); } #endif /* LDAP_DEBUG */ -#else /* CLDAP */ +#else /* LDAP_CONNECTIONLESS */ rc = -1; -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ } else { rc = read( sb->sb_sd, sb->sb_ber.ber_buf, - ((sb->sb_options & LBER_NO_READ_AHEAD) && - (len < READBUFSIZ)) ? - len : READBUFSIZ ); + ((sb->sb_options & LBER_NO_READ_AHEAD) && (len < READBUFSIZ)) ? + len : READBUFSIZ ); } if ( rc > 0 ) { @@ -189,7 +163,7 @@ BerRead( Sockbuf *sb, char *buf, long len ) break; return( c ); } - *buf++ = c; + *buf++ = (char) c; nread++; len--; } @@ -301,7 +275,7 @@ ber_flush( Sockbuf *sb, BerElement *ber, int freeit ) #ifdef LDAP_DEBUG if ( lber_debug ) { fprintf( stderr, "ber_flush: %ld bytes to sd %ld%s\n", towrite, - sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)" + (long) sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)" : "" ); if ( lber_debug > 1 ) lber_bprint( ber->ber_rwptr, towrite ); @@ -319,17 +293,18 @@ ber_flush( Sockbuf *sb, BerElement *ber, int freeit ) nwritten = 0; do { if (sb->sb_naddr > 0) { -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS rc = udp_write( sb, ber->ber_buf + nwritten, (size_t)towrite ); -#else /* CLDAP */ +#else /* LDAP_CONNECTIONLESS */ rc = -1; -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ if ( rc <= 0 ) return( -1 ); + /* fake error if write was not atomic */ if (rc < towrite) { -#if !defined( MACOS ) && !defined( DOS ) +#ifdef EMSGSIZE errno = EMSGSIZE; #endif return( -1 ); @@ -359,7 +334,7 @@ ber_alloc_t( int options ) if ( (ber = (BerElement *) calloc( 1, sizeof(BerElement) )) == NULLBER ) return( NULLBER ); ber->ber_tag = LBER_DEFAULT; - ber->ber_options = options; + ber->ber_options = (char) options; return( ber ); } @@ -395,7 +370,7 @@ ber_init( BerElement *ber, int options ) { (void) memset( (char *)ber, '\0', sizeof( BerElement )); ber->ber_tag = LBER_DEFAULT; - ber->ber_options = options; + ber->ber_options = (char) options; } @@ -419,14 +394,16 @@ void ber_dump( BerElement *ber, int inout ) { fprintf( stderr, "ber_dump: buf 0x%lx, ptr 0x%lx, end 0x%lx\n", - ber->ber_buf, ber->ber_ptr, ber->ber_end ); + (long) ber->ber_buf, + (long) ber->ber_ptr, + (long) ber->ber_end ); if ( inout == 1 ) { fprintf( stderr, " current len %ld, contents:\n", - ber->ber_end - ber->ber_ptr ); + (long) (ber->ber_end - ber->ber_ptr) ); lber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr ); } else { fprintf( stderr, " current len %ld, contents:\n", - ber->ber_ptr - ber->ber_buf ); + (long) (ber->ber_ptr - ber->ber_buf) ); lber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf ); } } @@ -437,9 +414,9 @@ ber_sos_dump( Seqorset *sos ) fprintf( stderr, "*** sos dump ***\n" ); while ( sos != NULLSEQORSET ) { fprintf( stderr, "ber_sos_dump: clen %ld first 0x%lx ptr 0x%lx\n", - sos->sos_clen, sos->sos_first, sos->sos_ptr ); + (long) sos->sos_clen, (long) sos->sos_first, (long) sos->sos_ptr ); fprintf( stderr, " current len %ld contents:\n", - sos->sos_ptr - sos->sos_first ); + (long) (sos->sos_ptr - sos->sos_first) ); lber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first ); sos = sos->sos_next; @@ -456,7 +433,7 @@ get_tag( Sockbuf *sb ) unsigned char xbyte; unsigned long tag; char *tagp; - int i; + unsigned int i; if ( BerRead( sb, (char *) &xbyte, 1 ) != 1 ) return( LBER_DEFAULT ); @@ -487,7 +464,7 @@ get_tag( Sockbuf *sb ) unsigned long ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) { - unsigned long tag, netlen, toread; + unsigned long tag = 0, netlen, toread; unsigned char lc; long rc; int noctets, diff; @@ -545,7 +522,7 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) noctets ) { return( LBER_DEFAULT ); } - *len = LBER_NTOHL( netlen ); + *len = AC_NTOHL( netlen ); } else { *len = lc; } @@ -564,7 +541,7 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) #endif /* DOS && !_WIN32 */ if ( ( sb->sb_options & LBER_MAX_INCOMING_SIZE ) && - *len > sb->sb_max_incoming ) { + *len > (unsigned long) sb->sb_max_incoming ) { return( LBER_DEFAULT ); } diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index b59563ef88..9f9cd13678 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -1,16 +1,12 @@ +#include "portable.h" + #include -#include -#ifdef MACOS #include -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ + +#include +#include +#include + #include "lber.h" #include "ldap.h" @@ -20,53 +16,53 @@ struct ldaperror { }; static struct ldaperror ldap_errlist[] = { - LDAP_SUCCESS, "Success", - LDAP_OPERATIONS_ERROR, "Operations error", - LDAP_PROTOCOL_ERROR, "Protocol error", - LDAP_TIMELIMIT_EXCEEDED, "Timelimit exceeded", - LDAP_SIZELIMIT_EXCEEDED, "Sizelimit exceeded", - LDAP_COMPARE_FALSE, "Compare false", - LDAP_COMPARE_TRUE, "Compare true", - LDAP_STRONG_AUTH_NOT_SUPPORTED, "Strong authentication not supported", - LDAP_STRONG_AUTH_REQUIRED, "Strong authentication required", - LDAP_PARTIAL_RESULTS, "Partial results and referral received", - LDAP_NO_SUCH_ATTRIBUTE, "No such attribute", - LDAP_UNDEFINED_TYPE, "Undefined attribute type", - LDAP_INAPPROPRIATE_MATCHING, "Inappropriate matching", - LDAP_CONSTRAINT_VIOLATION, "Constraint violation", - LDAP_TYPE_OR_VALUE_EXISTS, "Type or value exists", - LDAP_INVALID_SYNTAX, "Invalid syntax", - LDAP_NO_SUCH_OBJECT, "No such object", - LDAP_ALIAS_PROBLEM, "Alias problem", - LDAP_INVALID_DN_SYNTAX, "Invalid DN syntax", - LDAP_IS_LEAF, "Object is a leaf", - LDAP_ALIAS_DEREF_PROBLEM, "Alias dereferencing problem", - LDAP_INAPPROPRIATE_AUTH, "Inappropriate authentication", - LDAP_INVALID_CREDENTIALS, "Invalid credentials", - LDAP_INSUFFICIENT_ACCESS, "Insufficient access", - LDAP_BUSY, "DSA is busy", - LDAP_UNAVAILABLE, "DSA is unavailable", - LDAP_UNWILLING_TO_PERFORM, "DSA is unwilling to perform", - LDAP_LOOP_DETECT, "Loop detected", - LDAP_NAMING_VIOLATION, "Naming violation", - LDAP_OBJECT_CLASS_VIOLATION, "Object class violation", - LDAP_NOT_ALLOWED_ON_NONLEAF, "Operation not allowed on nonleaf", - LDAP_NOT_ALLOWED_ON_RDN, "Operation not allowed on RDN", - LDAP_ALREADY_EXISTS, "Already exists", - LDAP_NO_OBJECT_CLASS_MODS, "Cannot modify object class", - LDAP_RESULTS_TOO_LARGE, "Results too large", - LDAP_OTHER, "Unknown error", - LDAP_SERVER_DOWN, "Can't contact LDAP server", - LDAP_LOCAL_ERROR, "Local error", - LDAP_ENCODING_ERROR, "Encoding error", - LDAP_DECODING_ERROR, "Decoding error", - LDAP_TIMEOUT, "Timed out", - LDAP_AUTH_UNKNOWN, "Unknown authentication method", - LDAP_FILTER_ERROR, "Bad search filter", - LDAP_USER_CANCELLED, "User cancelled operation", - LDAP_PARAM_ERROR, "Bad parameter to an ldap routine", - LDAP_NO_MEMORY, "Out of memory", - -1, 0 + {LDAP_SUCCESS, "Success" }, + {LDAP_OPERATIONS_ERROR, "Operations error" }, + {LDAP_PROTOCOL_ERROR, "Protocol error" }, + {LDAP_TIMELIMIT_EXCEEDED, "Timelimit exceeded" }, + {LDAP_SIZELIMIT_EXCEEDED, "Sizelimit exceeded" }, + {LDAP_COMPARE_FALSE, "Compare false" }, + {LDAP_COMPARE_TRUE, "Compare true" }, + {LDAP_STRONG_AUTH_NOT_SUPPORTED, "Strong authentication not supported" }, + {LDAP_STRONG_AUTH_REQUIRED, "Strong authentication required" }, + {LDAP_PARTIAL_RESULTS, "Partial results and referral received" }, + {LDAP_NO_SUCH_ATTRIBUTE, "No such attribute" }, + {LDAP_UNDEFINED_TYPE, "Undefined attribute type" }, + {LDAP_INAPPROPRIATE_MATCHING, "Inappropriate matching" }, + {LDAP_CONSTRAINT_VIOLATION, "Constraint violation" }, + {LDAP_TYPE_OR_VALUE_EXISTS, "Type or value exists" }, + {LDAP_INVALID_SYNTAX, "Invalid syntax" }, + {LDAP_NO_SUCH_OBJECT, "No such object" }, + {LDAP_ALIAS_PROBLEM, "Alias problem" }, + {LDAP_INVALID_DN_SYNTAX, "Invalid DN syntax" }, + {LDAP_IS_LEAF, "Object is a leaf" }, + {LDAP_ALIAS_DEREF_PROBLEM, "Alias dereferencing problem" }, + {LDAP_INAPPROPRIATE_AUTH, "Inappropriate authentication" }, + {LDAP_INVALID_CREDENTIALS, "Invalid credentials" }, + {LDAP_INSUFFICIENT_ACCESS, "Insufficient access" }, + {LDAP_BUSY, "DSA is busy" }, + {LDAP_UNAVAILABLE, "DSA is unavailable" }, + {LDAP_UNWILLING_TO_PERFORM, "DSA is unwilling to perform" }, + {LDAP_LOOP_DETECT, "Loop detected" }, + {LDAP_NAMING_VIOLATION, "Naming violation" }, + {LDAP_OBJECT_CLASS_VIOLATION, "Object class violation" }, + {LDAP_NOT_ALLOWED_ON_NONLEAF, "Operation not allowed on nonleaf" }, + {LDAP_NOT_ALLOWED_ON_RDN, "Operation not allowed on RDN" }, + {LDAP_ALREADY_EXISTS, "Already exists" }, + {LDAP_NO_OBJECT_CLASS_MODS, "Cannot modify object class" }, + {LDAP_RESULTS_TOO_LARGE, "Results too large" }, + {LDAP_OTHER, "Unknown error" }, + {LDAP_SERVER_DOWN, "Can't contact LDAP server" }, + {LDAP_LOCAL_ERROR, "Local error" }, + {LDAP_ENCODING_ERROR, "Encoding error" }, + {LDAP_DECODING_ERROR, "Decoding error" }, + {LDAP_TIMEOUT, "Timed out" }, + {LDAP_AUTH_UNKNOWN, "Unknown authentication method" }, + {LDAP_FILTER_ERROR, "Bad search filter" }, + {LDAP_USER_CANCELLED, "User cancelled operation" }, + {LDAP_PARAM_ERROR, "Bad parameter to an ldap routine" }, + {LDAP_NO_MEMORY, "Out of memory" }, + {-1, 0 } }; char * @@ -84,7 +80,7 @@ ldap_err2string( int err ) return( "Unknown error" ); } -#ifndef NO_USERINTERFACE +#ifdef LDAP_LIBUI void ldap_perror( LDAP *ld, char *s ) { @@ -123,7 +119,7 @@ ldap_perror( LDAP *ld, char *s ) { } -#endif /* NO_USERINTERFACE */ +#endif /* !LDAP_LIBUI */ int @@ -132,7 +128,7 @@ ldap_result2error( LDAP *ld, LDAPMessage *r, int freeit ) LDAPMessage *lm; BerElement ber; long along; - int rc; + unsigned long rc; Debug( LDAP_DEBUG_TRACE, "ldap_result2error\n", 0, 0, 0 ); diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 3f8408df18..f8b0f31a2f 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -5,83 +5,41 @@ * result.c - wait for an ldap result */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif #include -#include -#ifdef MACOS #include -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#ifdef PCNFS -#include -#include -#include -#endif /* PCNFS */ -#ifdef NCSA -#include "externs.h" -#endif /* NCSA */ -#else /* DOS */ -#include -#include -#include -#include -#ifdef _AIX -#include -#endif /* _AIX */ -#include "portable.h" -#endif /* DOS */ -#endif /* MACOS */ -#ifdef VMS -#include "ucx_select.h" -#endif + +#include +#include +#include +#include +#include + #include "lber.h" #include "ldap.h" #include "ldap-int.h" -#ifdef USE_SYSCONF -#include -#endif /* USE_SYSCONF */ -#ifdef NEEDPROTOS -static int ldap_abandoned( LDAP *ld, int msgid ); -static int ldap_mark_abandoned( LDAP *ld, int msgid ); -static int wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, - LDAPMessage **result ); +static int ldap_abandoned LDAP_P(( LDAP *ld, int msgid )); +static int ldap_mark_abandoned LDAP_P(( LDAP *ld, int msgid )); +static int wait4msg LDAP_P(( LDAP *ld, int msgid, int all, struct timeval *timeout, + LDAPMessage **result )); #ifdef LDAP_REFERRALS -static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc, - LDAPMessage **result ); -static int build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr ); -static void merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ); +static int read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc, + LDAPMessage **result )); +static unsigned long build_result_ber LDAP_P(( LDAP *ld, BerElement *ber, LDAPRequest *lr )); +static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )); #else /* LDAP_REFERRALS */ -static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, - LDAPMessage **result ); -#endif /* LDAP_REFERRALS */ -#if defined( CLDAP ) || !defined( LDAP_REFERRALS ) -static int ldap_select1( LDAP *ld, struct timeval *timeout ); -#endif -#else /* NEEDPROTOS */ -static int ldap_abandoned(); -static int ldap_mark_abandoned(); -static int wait4msg(); -static int read1msg(); -#ifdef LDAP_REFERRALS -static int build_result_ber(); -static void merge_error_info(); +static int read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, + LDAPMessage **result )); #endif /* LDAP_REFERRALS */ -#if defined( CLDAP ) || !defined( LDAP_REFERRALS ) -static int ldap_select1(); -#endif -#endif /* NEEDPROTOS */ - -#if !defined( MACOS ) && !defined( DOS ) -extern int errno; +#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_REFERRALS ) +static int ldap_select1 LDAP_P(( LDAP *ld, struct timeval *timeout )); #endif @@ -181,7 +139,8 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, { int rc; struct timeval tv, *tvp; - long start_time, tmp_time; + time_t start_time = 0; + time_t tmp_time; #ifdef LDAP_REFERRALS LDAPConn *lc, *nextlc; #endif /* LDAP_REFERRALS */ @@ -201,7 +160,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, } else { tv = *timeout; tvp = &tv; - start_time = (long)time( NULL ); + start_time = time( NULL ); } rc = -2; @@ -211,12 +170,8 @@ 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 !defined( MACOS ) && !defined( DOS ) if ( rc == 0 || ( rc == -1 && (( ld->ld_options & LDAP_OPT_RESTART ) == 0 || errno != EINTR ))) { -#else - if ( rc == -1 || rc == 0 ) { -#endif ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN : LDAP_TIMEOUT); return( rc ); @@ -231,8 +186,8 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, #else /* !LDAP_REFERRALS */ #ifdef LDAP_DEBUG if ( ldap_debug & LDAP_DEBUG_TRACE ) { - dump_connection( ld, ld->ld_conns, 1 ); - dump_requests_and_responses( ld ); + ldap_dump_connection( ld, ld->ld_conns, 1 ); + ldap_dump_requests_and_responses( ld ); } #endif /* LDAP_DEBUG */ for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { @@ -248,7 +203,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, rc = do_ldap_select( ld, tvp ); -#if defined( LDAP_DEBUG ) && !defined( MACOS ) && !defined( DOS ) +#ifdef LDAP_DEBUG if ( rc == -1 ) { Debug( LDAP_DEBUG_TRACE, "do_ldap_select returned -1: errno %d\n", @@ -256,12 +211,8 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, } #endif -#if !defined( MACOS ) && !defined( DOS ) if ( rc == 0 || ( rc == -1 && (( ld->ld_options & LDAP_OPT_RESTART ) == 0 || errno != EINTR ))) { -#else - if ( rc == -1 || rc == 0 ) { -#endif ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN : LDAP_TIMEOUT); return( rc ); @@ -276,7 +227,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, nextlc = lc->lconn_next; if ( lc->lconn_status == LDAP_CONNST_CONNECTED && - is_read_ready( ld, + ldap_is_read_ready( ld, lc->lconn_sb )) { rc = read1msg( ld, msgid, all, lc->lconn_sb, lc, result ); @@ -287,7 +238,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, #endif /* !LDAP_REFERRALS */ if ( rc == -2 && tvp != NULL ) { - tmp_time = (long)time( NULL ); + tmp_time = time( NULL ); if (( tv.tv_sec -= ( tmp_time - start_time )) <= 0 ) { rc = 0; /* timed out */ ld->ld_errno = LDAP_TIMEOUT; @@ -326,7 +277,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, Debug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 ); ber_init( &ber, 0 ); - set_ber_options( ld, &ber ); + ldap_set_ber_options( ld, &ber ); /* get the next message */ if ( (tag = ber_get_next( sb, &len, &ber )) @@ -349,7 +300,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, } #ifdef LDAP_REFERRALS - if (( lr = find_request_by_msgid( ld, id )) == NULL ) { + if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) { Debug( LDAP_DEBUG_ANY, "no request for response with msgid %ld (tossing)\n", id, 0, 0 ); @@ -384,7 +335,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, != LBER_ERROR ) { if ( lderr != LDAP_SUCCESS ) { /* referrals are in error string */ - refer_cnt = chase_referrals( ld, lr, + refer_cnt = ldap_chase_referrals( ld, lr, &lr->lr_res_error, &hadref ); } @@ -455,11 +406,11 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); } } - free_request( ld, lr ); + ldap_free_request( ld, lr ); } if ( lc != NULL ) { - free_connection( ld, lc, 0, 1 ); + ldap_free_connection( ld, lc, 0, 1 ); } } } @@ -479,11 +430,11 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); new->lm_msgtype = tag; new->lm_ber = ber_dup( &ber ); -#ifndef NO_CACHE +#ifndef LDAP_NOCACHE if ( ld->ld_cache != NULL ) { - add_result_to_cache( ld, new ); + ldap_add_result_to_cache( ld, new ); } -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ /* is this the one we're looking for? */ if ( msgid == LDAP_RES_ANY || id == msgid ) { @@ -542,7 +493,18 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); prev->lm_next = l->lm_next; *result = l; ld->ld_errno = LDAP_SUCCESS; +#ifdef LDAP_WORLD_P16 + /* + * XXX questionable fix; see text for [P16] on + * http://www.critical-angle.com/ldapworld/patch/ + * + * inclusion of this patch causes searchs to hang on + * multiple platforms + */ + return( l->lm_msgtype ); +#else /* LDAP_WORLD_P16 */ return( tag ); +#endif /* !LDAP_WORLD_P16 */ } return( -2 ); /* continue looking */ @@ -550,18 +512,18 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); #ifdef LDAP_REFERRALS -static int +static unsigned long build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr ) { unsigned long len; long along; ber_init( ber, 0 ); - set_ber_options( ld, ber ); + ldap_set_ber_options( ld, ber ); if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid, (long)lr->lr_res_msgtype, lr->lr_res_errno, lr->lr_res_matched ? lr->lr_res_matched : "", - lr->lr_res_error ? lr->lr_res_error : "" ) == LBER_ERROR ) { + lr->lr_res_error ? lr->lr_res_error : "" ) == -1 ) { return( LBER_ERROR ); } @@ -587,7 +549,7 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) if ( lr->lr_res_errno == LDAP_PARTIAL_RESULTS ) { parentr->lr_res_errno = lr->lr_res_errno; if ( lr->lr_res_error != NULL ) { - (void)append_referral( ld, &parentr->lr_res_error, + (void)ldap_append_referral( ld, &parentr->lr_res_error, lr->lr_res_error ); } } else if ( lr->lr_res_errno != LDAP_SUCCESS && @@ -618,8 +580,8 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) -#if defined( CLDAP ) || !defined( LDAP_REFERRALS ) -#if !defined( MACOS ) && !defined( DOS ) && !defined( _WIN32 ) +#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_REFERRALS ) + static int ldap_select1( LDAP *ld, struct timeval *timeout ) { @@ -627,11 +589,18 @@ ldap_select1( LDAP *ld, struct timeval *timeout ) static int tblsize; if ( tblsize == 0 ) { -#ifdef USE_SYSCONF +#ifdef HAVE_SYSCONF tblsize = sysconf( _SC_OPEN_MAX ); -#else /* USE_SYSCONF */ +#elif HAVE_GETDTABLESIZE tblsize = getdtablesize(); -#endif /* USE_SYSCONF */ +#else + tblsize = FD_SETSIZE; +#endif +#ifdef FD_SETSIZE + if ( tblsize > FD_SETSIZE ) { + tblsize = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ } FD_ZERO( &readfds ); @@ -639,77 +608,7 @@ ldap_select1( LDAP *ld, struct timeval *timeout ) return( select( tblsize, &readfds, 0, 0, timeout ) ); } -#endif /* !MACOS */ - - -#ifdef MACOS -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - return( tcpselect( ld->ld_sb.sb_sd, timeout )); -} -#endif /* MACOS */ - -#if ( defined( DOS ) && defined( WINSOCK )) || defined( _WIN32 ) -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - fd_set readfds; - int rc; - - FD_ZERO( &readfds ); - FD_SET( ld->ld_sb.sb_sd, &readfds ); - - rc = select( 1, &readfds, 0, 0, timeout ); - return( rc == SOCKET_ERROR ? -1 : rc ); -} -#endif /* WINSOCK || _WIN32 */ - - -#ifdef DOS -#ifdef PCNFS -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - fd_set readfds; - int res; - - FD_ZERO( &readfds ); - FD_SET( ld->ld_sb.sb_sd, &readfds ); - - res = select( FD_SETSIZE, &readfds, NULL, NULL, timeout ); - if ( res == -1 && errno == EINTR) { - /* We've been CTRL-C'ed at this point. It'd be nice to - carry on but PC-NFS currently won't let us! */ - printf("\n*** CTRL-C ***\n"); - exit(-1); - } - return( res ); -} -#endif /* PCNFS */ - -#ifdef NCSA -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - int rc; - clock_t endtime; - - if ( timeout != NULL ) { - endtime = timeout->tv_sec * CLK_TCK + - timeout->tv_usec * CLK_TCK / 1000000 + clock(); - } - - do { - Stask(); - rc = netqlen( ld->ld_sb.sb_sd ); - } while ( rc <= 0 && ( timeout == NULL || clock() < endtime )); - - return( rc > 0 ? 1 : 0 ); -} -#endif /* NCSA */ -#endif /* DOS */ #endif /* !LDAP_REFERRALS */ @@ -807,7 +706,7 @@ ldap_mark_abandoned( LDAP *ld, int msgid ) } -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS int cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber ) { @@ -833,4 +732,4 @@ cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber ) return( tag ); } -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ diff --git a/libraries/libldap/sort.c b/libraries/libldap/sort.c index ee5d549c89..7085c8efb6 100644 --- a/libraries/libldap/sort.c +++ b/libraries/libldap/sort.c @@ -12,34 +12,27 @@ * sort.c: LDAP library entry and value sort routines */ +#include "portable.h" + #include -#include -#include #include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#endif /* DOS */ -#endif /* MACOS */ + +#include +#include +#include #include "lber.h" #include "ldap.h" + struct entrything { char **et_vals; LDAPMessage *et_msg; }; -#ifndef NEEDPROTOS -static int (*et_cmp_fn)(); -static int et_cmp(); -#else /* !NEEDPROTOS */ -static int (*et_cmp_fn)( char *a, char *b ); -static int et_cmp( void *aa, void *bb); -#endif /* !NEEDPROTOS */ +static int (*et_cmp_fn) LDAP_P(( char *a, char *b )); +static int et_cmp LDAP_P(( const void *aa, const void *bb)); + int ldap_sort_strcasecmp( @@ -52,13 +45,13 @@ ldap_sort_strcasecmp( static int et_cmp( - void *aa, - void *bb + const void *aa, + const void *bb ) { int i, rc; - struct entrything *a = (struct entrything *)aa; - struct entrything *b = (struct entrything *)bb; + const struct entrything *a = (const struct entrything *)aa; + const struct entrything *b = (const struct entrything *)bb; if ( a->et_vals == NULL && b->et_vals == NULL ) return( 0 ); @@ -86,7 +79,7 @@ ldap_sort_entries( LDAP *ld, LDAPMessage **chain, char *attr, /* NULL => sort by DN */ - int (*cmp)() + int (*cmp) LDAP_P((char *, char *)) ) { int i, count; @@ -120,7 +113,7 @@ ldap_sort_entries( last = e; et_cmp_fn = cmp; - qsort( et, count, sizeof(struct entrything), (void *) et_cmp ); + qsort( et, count, sizeof(struct entrything), et_cmp ); ep = chain; for ( i = 0; i < count; i++ ) { @@ -139,7 +132,7 @@ int ldap_sort_values( LDAP *ld, char **vals, - int (*cmp)() + int (*cmp) LDAP_P((const void *, const void *)) ) { int nel; diff --git a/libraries/libldap/tmplout.c b/libraries/libldap/tmplout.c index 330527b421..6d92f536b1 100644 --- a/libraries/libldap/tmplout.c +++ b/libraries/libldap/tmplout.c @@ -3,67 +3,54 @@ * 12 April 1994 by Mark C Smith */ +#include "portable.h" + #include -#include -#include -#include #include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#include -#endif /* DOS */ -#endif /* MACOS */ -#ifdef VMS -#include -#endif /* VMS */ +#include +#include +#include +#include + +#ifdef HAVE_SYS_FILE_H +#include +#endif #include "lber.h" #include "ldap.h" #include "disptmpl.h" -#ifdef NEEDPROTOS -static int do_entry2text( LDAP *ld, char *buf, char *base, LDAPMessage *entry, +#include "ldapconfig.h" + +static int do_entry2text LDAP_P(( + LDAP *ld, char *buf, char *base, LDAPMessage *entry, struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol, int rdncount, - unsigned long opts, char *urlprefix ); -static int do_entry2text_search( LDAP *ld, char *dn, char *base, + unsigned long opts, char *urlprefix )); +static int do_entry2text_search LDAP_P(( + LDAP *ld, char *dn, char *base, LDAPMessage *entry, struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol, - int rdncount, unsigned long opts, char *urlprefix ); -static int do_vals2text( LDAP *ld, char *buf, char **vals, char *label, + int rdncount, unsigned long opts, char *urlprefix )); +static int do_vals2text LDAP_P(( + LDAP *ld, char *buf, char **vals, char *label, int labelwidth, unsigned long syntaxid, writeptype writeproc, - void *writeparm, char *eol, int rdncount, char *urlprefix ); -static int max_label_len( struct ldap_disptmpl *tmpl ); -static int output_label( char *buf, char *label, int width, - writeptype writeproc, void *writeparm, char *eol, int html ); -static int output_dn( char *buf, char *dn, int width, int rdncount, - writeptype writeproc, void *writeparm, char *eol, char *urlprefix ); -static void strcat_escaped( char *s1, char *s2 ); -static char *time2text( char *ldtimestr, int dateonly ); -static long gtime( struct tm *tm ); -static int searchaction( LDAP *ld, char *buf, char *base, LDAPMessage *entry, + void *writeparm, char *eol, int rdncount, char *urlprefix )); +static int max_label_len LDAP_P(( struct ldap_disptmpl *tmpl )); +static int output_label LDAP_P(( + char *buf, char *label, int width, + writeptype writeproc, void *writeparm, char *eol, int html )); +static int output_dn LDAP_P(( + char *buf, char *dn, int width, int rdncount, + writeptype writeproc, void *writeparm, char *eol, char *urlprefix )); +static void strcat_escaped LDAP_P(( char *s1, char *s2 )); +static char *time2text LDAP_P(( char *ldtimestr, int dateonly )); +static long gtime LDAP_P(( struct tm *tm )); +static int searchaction LDAP_P(( + LDAP *ld, char *buf, char *base, LDAPMessage *entry, char *dn, struct ldap_tmplitem *tip, int labelwidth, int rdncount, - writeptype writeproc, void *writeparm, char *eol, char *urlprefix ); -#else /* NEEDPROTOS */ -static int do_entry2text(); -static int do_entry2text_search(); -static int do_vals2text(); -static int max_label_len(); -static int output_label(); -static int output_dn(); -static void strcat_escaped(); -static char *time2text(); -static long gtime(); -static int searchaction(); -#endif /* NEEDPROTOS */ + writeptype writeproc, void *writeparm, char *eol, char *urlprefix )); #define DEF_LABEL_WIDTH 15 #define SEARCH_TIMEOUT_SECS 120 @@ -206,7 +193,7 @@ do_entry2text( sprintf( buf + strlen( buf ), "%s\">Move Up To %s%s
", ( vals[ 1 ] == NULL ) ? "??one" : "", - ( untagged != NULL ) ? untagged + 1 : vals[ 1 ], eol, eol ); + ( untagged != NULL ) ? untagged + 1 : vals[ 1 ], eol ); (*writeproc)( writeparm, buf, strlen( buf )); /* @@ -262,9 +249,7 @@ do_entry2text( freevals = 1; } - if ( islower( *attr )) { /* cosmetic -- upcase attr. name */ - *attr = toupper( *attr ); - } + *attr = TOUPPER( *attr ); err = do_vals2text( ld, buf, vals, attr, labelwidth, LDAP_SYN_CASEIGNORESTR, writeproc, writeparm, eol, @@ -313,14 +298,14 @@ do_entry2text( if ( show && LDAP_GET_SYN_TYPE( colp->ti_syntaxid ) == LDAP_SYN_TYPE_BOOLEAN && LDAP_IS_TMPLITEM_OPTION_SET( colp, LDAP_DITEM_OPT_HIDEIFFALSE ) && - toupper( vals[ 0 ][ 0 ] ) != 'T' ) { + TOUPPER( vals[ 0 ][ 0 ] ) != 'T' ) { show = 0; } if ( colp->ti_syntaxid == LDAP_SYN_SEARCHACTION ) { if (( opts & LDAP_DISP_OPT_DOSEARCHACTIONS ) != 0 ) { if ( colp->ti_attrname == NULL || ( show && - toupper( vals[ 0 ][ 0 ] ) == 'T' )) { + TOUPPER( vals[ 0 ][ 0 ] ) == 'T' )) { err = searchaction( ld, buf, base, entry, dn, colp, labelwidth, rdncount, writeproc, writeparm, eol, urlprefix ); @@ -475,12 +460,12 @@ do_entry2text_search( ocattrs[0] = OCATTRNAME; ocattrs[1] = NULL; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( LDAP_IS_CLDAP( ld )) err = cldap_search_s( ld, dn, LDAP_SCOPE_BASE, "objectClass=*", ocattrs, 0, &ldmp, NULL ); else -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ err = ldap_search_st( ld, dn, LDAP_SCOPE_BASE, "objectClass=*", ocattrs, 0, &timeout, &ldmp ); @@ -509,12 +494,12 @@ do_entry2text_search( fetchattrs = ldap_tmplattrs( tmpl, NULL, 1, LDAP_SYN_OPT_DEFER ); } -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( LDAP_IS_CLDAP( ld )) err = cldap_search_s( ld, dn, LDAP_SCOPE_BASE, "objectClass=*", fetchattrs, 0, &ldmp, NULL ); else -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ err = ldap_search_st( ld, dn, LDAP_SCOPE_BASE, "objectClass=*", fetchattrs, 0, &timeout, &ldmp ); @@ -700,7 +685,7 @@ do_vals2text( break; case LDAP_SYN_BOOLEAN: - outval = toupper( outval[ 0 ] ) == 'T' ? "TRUE" : "FALSE"; + outval = TOUPPER( outval[ 0 ] ) == 'T' ? "TRUE" : "FALSE"; ++writeoutval; break; @@ -924,11 +909,6 @@ time2text( char *ldtimestr, int dateonly ) /* gtime.c - inverse gmtime */ - -#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( DOS ) -#include -#endif /* !MACOS */ - /* gtime(): the inverse of localtime(). This routine was supplied by Mike Accetta at CMU many years ago. */ @@ -987,7 +967,7 @@ searchaction( LDAP *ld, char *buf, char *base, LDAPMessage *entry, char *dn, struct ldap_tmplitem *tip, int labelwidth, int rdncount, writeptype writeproc, void *writeparm, char *eol, char *urlprefix ) { - int err, lderr, i, count, html; + int err = 0, lderr, i, count, html; char **vals, **members; char *value, *filtpattern, *attr, *selectname; char *retattrs[2], filter[ 256 ]; @@ -1047,12 +1027,12 @@ searchaction( LDAP *ld, char *buf, char *base, LDAPMessage *entry, char *dn, timeout.tv_sec = SEARCH_TIMEOUT_SECS; timeout.tv_usec = 0; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( LDAP_IS_CLDAP( ld )) lderr = cldap_search_s( ld, base, LDAP_SCOPE_SUBTREE, filter, retattrs, 0, &ldmp, NULL ); else -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ lderr = ldap_search_st( ld, base, LDAP_SCOPE_SUBTREE, filter, retattrs, 0, &timeout, &ldmp ); diff --git a/libraries/libldbm/ldbm.c b/libraries/libldbm/ldbm.c index 6d15e4629e..23e6f842f9 100644 --- a/libraries/libldbm/ldbm.c +++ b/libraries/libldbm/ldbm.c @@ -1,46 +1,98 @@ /* ldbm.c - ldap dbm compatibility routines */ +/* Patched for Berkeley DB version 2.0; /KSp; 98/02/23 + * + * - basic implementation; 1998/02/23, /KSp + * - DB_DBT_MALLOC ; 1998/03/22, /KSp + */ + +#include "portable.h" + +#ifdef SLAPD_LDBM + #include -#include "ldbm.h" +#include +#include -#ifdef LDBM_USE_GDBM +#include "ldbm.h" -#include -#include +#if defined( LDBM_USE_DBHASH ) || defined( LDBM_USE_DBBTREE ) /***************************************************************** * * - * use gdbm * + * use berkeley db hash or btree package * * * *****************************************************************/ +#ifdef HAVE_BERKELEY_DB2 +/************************************************* + * * + * A malloc routine for use with DB_DBT_MALLOC * + * * + *************************************************/ + +void * +ldbm_malloc( size_t size ) +{ + return( calloc( 1, size )); +} + +#endif + + LDBM ldbm_open( char *name, int rw, int mode, int dbcachesize ) { - LDBM db; - struct stat st; + LDBM ret = NULL; - if ( (db = gdbm_open( name, 0, rw | GDBM_FAST, mode, 0 )) == NULL ) { - return( NULL ); - } - if ( dbcachesize > 0 && stat( name, &st ) == 0 ) { - dbcachesize = (dbcachesize / st.st_blksize); - gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) ); +#ifdef HAVE_BERKELEY_DB2 + DB_INFO dbinfo; + + memset( &dbinfo, 0, sizeof( dbinfo )); + dbinfo.db_cachesize = dbcachesize; + dbinfo.db_pagesize = DEFAULT_DB_PAGE_SIZE; + dbinfo.db_malloc = ldbm_malloc; + + db_open( name, DB_TYPE, rw, mode, NULL, &dbinfo, &ret ); + +#else + void *info; + BTREEINFO binfo; + HASHINFO hinfo; + + if ( DB_TYPE == DB_HASH ) { + memset( (char *) &hinfo, '\0', sizeof(hinfo) ); + hinfo.cachesize = dbcachesize; + info = &hinfo; + } else if ( DB_TYPE == DB_BTREE ) { + memset( (char *) &binfo, '\0', sizeof(binfo) ); + binfo.cachesize = dbcachesize; + info = &binfo; + } else { + info = NULL; } - return( db ); + ret = dbopen( name, rw, mode, DB_TYPE, info ); + +#endif + + return( ret ); } void ldbm_close( LDBM ldbm ) { - gdbm_close( ldbm ); +#ifdef HAVE_BERKELEY_DB2 + (*ldbm->close)( ldbm, 0 ); +#else + (*ldbm->close)( ldbm ); +#endif } void ldbm_sync( LDBM ldbm ) { - gdbm_sync( ldbm ); + (*ldbm->sync)( ldbm, 0 ); } void @@ -54,6 +106,10 @@ ldbm_datum_dup( LDBM ldbm, Datum data ) { Datum dup; +#ifdef HAVE_BERKELEY_DB2 + memset( &dup, 0, sizeof( dup )); +#endif + if ( data.dsize == 0 ) { dup.dsize = 0; dup.dptr = NULL; @@ -70,7 +126,26 @@ ldbm_datum_dup( LDBM ldbm, Datum data ) Datum ldbm_fetch( LDBM ldbm, Datum key ) { - return( gdbm_fetch( ldbm, key ) ); + Datum data; + int rc; + +#ifdef HAVE_BERKELEY_DB2 + memset( &data, 0, sizeof( data )); + + data.flags = DB_DBT_MALLOC; + + if ( (rc = (*ldbm->get)( ldbm, NULL, &key, &data, 0 )) != 0 ) { + if ( data.dptr ) free( data.dptr ); +#else + if ( (rc = (*ldbm->get)( ldbm, &key, &data, 0 )) == 0 ) { + data = ldbm_datum_dup( ldbm, data ); + } else { +#endif + data.dptr = NULL; + data.dsize = 0; + } + + return( data ); } int @@ -78,9 +153,14 @@ ldbm_store( LDBM ldbm, Datum key, Datum data, int flags ) { int rc; - rc = gdbm_store( ldbm, key, data, flags & ~LDBM_SYNC ); +#ifdef HAVE_BERKELEY_DB2 + rc = (*ldbm->put)( ldbm, NULL, &key, &data, flags & ~LDBM_SYNC ); + rc = (-1 ) * rc; +#else + rc = (*ldbm->put)( ldbm, &key, &data, flags & ~LDBM_SYNC ); +#endif if ( flags & LDBM_SYNC ) - gdbm_sync( ldbm ); + (*ldbm->sync)( ldbm, 0 ); return( rc ); } @@ -89,71 +169,134 @@ ldbm_delete( LDBM ldbm, Datum key ) { int rc; - rc = gdbm_delete( ldbm, key ); - gdbm_sync( ldbm ); +#ifdef HAVE_BERKELEY_DB2 + rc = (*ldbm->del)( ldbm, NULL, &key, 0 ); + rc = (-1 ) * rc; +#else + rc = (*ldbm->del)( ldbm, &key, 0 ); +#endif + (*ldbm->sync)( ldbm, 0 ); return( rc ); } Datum +#ifdef HAVE_BERKELEY_DB2 +ldbm_firstkey( LDBM ldbm, DBC **dbch ) +#else ldbm_firstkey( LDBM ldbm ) +#endif { - return( gdbm_firstkey( ldbm ) ); + Datum key, data; + int rc; + +#ifdef HAVE_BERKELEY_DB2 + DBC *dbci; + + memset( &key, 0, sizeof( key )); + memset( &data, 0, sizeof( data )); + + key.flags = data.flags = DB_DBT_MALLOC; + + /* acquire a cursor for the DB */ + if ( (*ldbm->cursor)( ldbm, NULL, &dbci )) { + return( key ); + } else { + *dbch = dbci; + if ( (*dbci->c_get)( dbci, &key, &data, DB_NEXT ) == 0 ) { + if ( data.dptr ) free( data.dptr ); +#else + if ( (rc = (*ldbm->seq)( ldbm, &key, &data, R_FIRST )) == 0 ) { + key = ldbm_datum_dup( ldbm, key ); +#endif + } else { + key.dptr = NULL; + key.dsize = 0; + } + +#ifdef HAVE_BERKELEY_DB2 + } +#endif + + return( key ); } Datum +#ifdef HAVE_BERKELEY_DB2 +ldbm_nextkey( LDBM ldbm, Datum key, DBC *dbcp ) +#else ldbm_nextkey( LDBM ldbm, Datum key ) +#endif { - return( gdbm_nextkey( ldbm, key ) ); + Datum data; + int rc; + +#ifdef HAVE_BERKELEY_DB2 + void *oldKey = key.dptr; + + memset( &data, 0, sizeof( data )); + + data.flags = DB_DBT_MALLOC; + + if ( (*dbcp->c_get)( dbcp, &key, &data, DB_NEXT ) == 0 ) { + if ( data.dptr ) free( data.dptr ); +#else + if ( (rc = (*ldbm->seq)( ldbm, &key, &data, R_NEXT )) == 0 ) { + key = ldbm_datum_dup( ldbm, key ); +#endif + } else { + key.dptr = NULL; + key.dsize = 0; + } +#ifdef HAVE_BERKELEY_DB2 + if ( oldKey ) free( oldKey ); +#endif + + return( key ); } int ldbm_errno( LDBM ldbm ) { - return( (int) gdbm_errno ); + return( errno ); } -#else -#if defined( LDBM_USE_DBHASH ) || defined( LDBM_USE_DBBTREE ) +#elif defined( HAVE_GDBM ) + +#include /***************************************************************** * * - * use berkeley db hash or btree package * + * use gdbm * * * *****************************************************************/ LDBM ldbm_open( char *name, int rw, int mode, int dbcachesize ) { - LDBM ret; - void *info; - BTREEINFO binfo; - HASHINFO hinfo; + LDBM db; + struct stat st; - if ( DB_TYPE == DB_HASH ) { - memset( (char *) &hinfo, '\0', sizeof(hinfo) ); - hinfo.cachesize = dbcachesize; - info = &hinfo; - } else if ( DB_TYPE == DB_BTREE ) { - memset( (char *) &binfo, '\0', sizeof(binfo) ); - binfo.cachesize = dbcachesize; - info = &binfo; - } else { - info = NULL; + if ( (db = gdbm_open( name, 0, rw | GDBM_FAST, mode, 0 )) == NULL ) { + return( NULL ); } - ret = dbopen( name, rw, mode, DB_TYPE, info ); - return( ret ); + if ( dbcachesize > 0 && stat( name, &st ) == 0 ) { + dbcachesize = (dbcachesize / st.st_blksize); + gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) ); + } + + return( db ); } void ldbm_close( LDBM ldbm ) { - (*ldbm->close)( ldbm ); + gdbm_close( ldbm ); } void ldbm_sync( LDBM ldbm ) { - (*ldbm->sync)( ldbm, 0 ); + gdbm_sync( ldbm ); } void @@ -183,17 +326,7 @@ ldbm_datum_dup( LDBM ldbm, Datum data ) Datum ldbm_fetch( LDBM ldbm, Datum key ) { - Datum data; - int rc; - - if ( (rc = (*ldbm->get)( ldbm, &key, &data, 0 )) == 0 ) { - data = ldbm_datum_dup( ldbm, data ); - } else { - data.dptr = NULL; - data.dsize = 0; - } - - return( data ); + return( gdbm_fetch( ldbm, key ) ); } int @@ -201,9 +334,9 @@ ldbm_store( LDBM ldbm, Datum key, Datum data, int flags ) { int rc; - rc = (*ldbm->put)( ldbm, &key, &data, flags & ~LDBM_SYNC ); + rc = gdbm_store( ldbm, key, data, flags & ~LDBM_SYNC ); if ( flags & LDBM_SYNC ) - (*ldbm->sync)( ldbm, 0 ); + gdbm_sync( ldbm ); return( rc ); } @@ -212,50 +345,30 @@ ldbm_delete( LDBM ldbm, Datum key ) { int rc; - rc = (*ldbm->del)( ldbm, &key, 0 ); - (*ldbm->sync)( ldbm, 0 ); + rc = gdbm_delete( ldbm, key ); + gdbm_sync( ldbm ); return( rc ); } Datum ldbm_firstkey( LDBM ldbm ) { - Datum key, data; - int rc; - - if ( (rc = (*ldbm->seq)( ldbm, &key, &data, R_FIRST )) == 0 ) { - key = ldbm_datum_dup( ldbm, key ); - } else { - key.dptr = NULL; - key.dsize = 0; - } - return( key ); + return( gdbm_firstkey( ldbm ) ); } Datum ldbm_nextkey( LDBM ldbm, Datum key ) { - Datum data; - int rc; - - if ( (rc = (*ldbm->seq)( ldbm, &key, &data, R_NEXT )) == 0 ) { - key = ldbm_datum_dup( ldbm, key ); - } else { - key.dptr = NULL; - key.dsize = 0; - } - return( key ); + return( gdbm_nextkey( ldbm, key ) ); } int ldbm_errno( LDBM ldbm ) { - return( errno ); + return( (int) gdbm_errno ); } -#else - -#ifdef LDBM_USE_NDBM +#elif defined( HAVE_NDBM ) /***************************************************************** * * @@ -301,7 +414,8 @@ ldbm_datum_dup( LDBM ldbm, Datum data ) return( dup ); } dup.dsize = data.dsize; - if ( dup.dptr = (char *) malloc( data.dsize ) ) + dup.dptr = (char *) malloc( data.dsize ); + if ( dup.dptr ) memcpy( dup.dptr, data.dptr, data.dsize ); return( dup ); @@ -344,5 +458,4 @@ ldbm_errno( LDBM ldbm ) } #endif /* ndbm */ -#endif /* db */ -#endif /* gdbm */ +#endif /* ldbm */ diff --git a/libraries/libldif/line64.c b/libraries/libldif/line64.c index 429e1d6ab1..7fae27961c 100644 --- a/libraries/libldif/line64.c +++ b/libraries/libldif/line64.c @@ -187,7 +187,7 @@ str_getline( char **next ) *(*next)++ = '\0'; break; } - *(*next)++; + (*next)++; } return( l ); @@ -215,7 +215,7 @@ put_type_and_value( char **out, char *t, char *val, int vlen ) b64 = 0; stop = (unsigned char *) (val + vlen); - if ( isascii( val[0] ) && isspace( val[0] ) || val[0] == ':' ) { + if ( isascii( val[0] ) && (isspace( val[0] ) || val[0] == ':') ) { b64 = 1; } else { for ( byte = (unsigned char *) val; byte < stop; diff --git a/libraries/liblutil/Makefile.in b/libraries/liblutil/Makefile.in new file mode 100644 index 0000000000..80b5420e56 --- /dev/null +++ b/libraries/liblutil/Makefile.in @@ -0,0 +1,11 @@ +## +## Makefile for -lutil +## + +LIBRARY = liblutil.a +SRCS = base64.c md5.c sha1.c detach.c +OBJS = base64.o md5.o sha1.o detach.o @LIBOBJS@ + +LDAP_INCDIR= ../../include +LDAP_LIBDIR= ../../libraries + diff --git a/libraries/liblutil/base64.c b/libraries/liblutil/base64.c new file mode 100644 index 0000000000..a2c27a1ff9 --- /dev/null +++ b/libraries/liblutil/base64.c @@ -0,0 +1,320 @@ +/* + * Modified by Kurt D. Zeilenga for inclusion into OpenLDAP + */ + +/* + * Copyright (c) 1996, 1998 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * Portions Copyright (c) 1995 by International Business Machines, Inc. + * + * International Business Machines, Inc. (hereinafter called IBM) grants + * permission under its copyrights to use, copy, modify, and distribute this + * Software with or without fee, provided that the above copyright notice and + * all paragraphs of this notice appear in all copies, and that the name of IBM + * not be used in connection with the marketing of any product incorporating + * the Software or modifications thereof, without specific, written prior + * permission. + * + * To the extent it has a right to do so, IBM grants an immunity from suit + * under its patents, if any, for the use, sale or manufacture of products to + * the extent that such products are used for performing Domain Name System + * dynamic updates in TCP/IP networks by means of the Software. No immunity is + * granted for any product per se or for any other function of any product. + * + * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, + * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN + * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include "portable.h" + +#include +#include +#include + +#include + +/* include socket.h to get sys/types.h and/or winsock2.h */ +#include + +#include "lutil.h" + +#define Assert(Cond) if (!(Cond)) abort() + +static const char Base64[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static const char Pad64 = '='; + +/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) + The following encoding technique is taken from RFC 1521 by Borenstein + and Freed. It is reproduced here in a slightly edited form for + convenience. + + A 65-character subset of US-ASCII is used, enabling 6 bits to be + represented per printable character. (The extra 65th character, "=", + is used to signify a special processing function.) + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating 3 8-bit input groups. + These 24 bits are then treated as 4 concatenated 6-bit groups, each + of which is translated into a single digit in the base64 alphabet. + + Each 6-bit group is used as an index into an array of 64 printable + characters. The character referenced by the index is placed in the + output string. + + Table 1: The Base64 Alphabet + + Value Encoding Value Encoding Value Encoding Value Encoding + 0 A 17 R 34 i 51 z + 1 B 18 S 35 j 52 0 + 2 C 19 T 36 k 53 1 + 3 D 20 U 37 l 54 2 + 4 E 21 V 38 m 55 3 + 5 F 22 W 39 n 56 4 + 6 G 23 X 40 o 57 5 + 7 H 24 Y 41 p 58 6 + 8 I 25 Z 42 q 59 7 + 9 J 26 a 43 r 60 8 + 10 K 27 b 44 s 61 9 + 11 L 28 c 45 t 62 + + 12 M 29 d 46 u 63 / + 13 N 30 e 47 v + 14 O 31 f 48 w (pad) = + 15 P 32 g 49 x + 16 Q 33 h 50 y + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. A full encoding quantum is + always completed at the end of a quantity. When fewer than 24 input + bits are available in an input group, zero bits are added (on the + right) to form an integral number of 6-bit groups. Padding at the + end of the data is performed using the '=' character. + + Since all base64 input is an integral number of octets, only the + ------------------------------------------------- + following cases can arise: + + (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded + output will be an integral multiple of 4 characters + with no "=" padding, + (2) the final quantum of encoding input is exactly 8 bits; + here, the final unit of encoded output will be two + characters followed by two "=" padding characters, or + (3) the final quantum of encoding input is exactly 16 bits; + here, the final unit of encoded output will be three + characters followed by one "=" padding character. + */ + +int +b64_ntop( + u_char const *src, + size_t srclength, + char *target, + size_t targsize) +{ + size_t datalength = 0; + u_char input[3]; + u_char output[4]; + size_t i; + + while (2 < srclength) { + input[0] = *src++; + input[1] = *src++; + input[2] = *src++; + srclength -= 3; + + output[0] = input[0] >> 2; + output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); + output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); + output[3] = input[2] & 0x3f; + Assert(output[0] < 64); + Assert(output[1] < 64); + Assert(output[2] < 64); + Assert(output[3] < 64); + + if (datalength + 4 > targsize) + return (-1); + target[datalength++] = Base64[output[0]]; + target[datalength++] = Base64[output[1]]; + target[datalength++] = Base64[output[2]]; + target[datalength++] = Base64[output[3]]; + } + + /* Now we worry about padding. */ + if (0 != srclength) { + /* Get what's left. */ + input[0] = input[1] = input[2] = '\0'; + for (i = 0; i < srclength; i++) + input[i] = *src++; + + output[0] = input[0] >> 2; + output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); + output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); + Assert(output[0] < 64); + Assert(output[1] < 64); + Assert(output[2] < 64); + + if (datalength + 4 > targsize) + return (-1); + target[datalength++] = Base64[output[0]]; + target[datalength++] = Base64[output[1]]; + if (srclength == 1) + target[datalength++] = Pad64; + else + target[datalength++] = Base64[output[2]]; + target[datalength++] = Pad64; + } + if (datalength >= targsize) + return (-1); + target[datalength] = '\0'; /* Returned value doesn't count \0. */ + return (datalength); +} + +/* skips all whitespace anywhere. + converts characters, four at a time, starting at (or after) + src from base - 64 numbers into three 8 bit bytes in the target area. + it returns the number of data bytes stored at the target, or -1 on error. + */ + +int +b64_pton( + char const *src, + u_char *target, + size_t targsize) +{ + int tarindex, state, ch; + char *pos; + + state = 0; + tarindex = 0; + + while ((ch = *src++) != '\0') { + if (isascii(ch) && isspace(ch)) /* Skip whitespace anywhere. */ + continue; + + if (ch == Pad64) + break; + + pos = strchr(Base64, ch); + if (pos == 0) /* A non-base64 character. */ + return (-1); + + switch (state) { + case 0: + if (target) { + if ((size_t)tarindex >= targsize) + return (-1); + target[tarindex] = (pos - Base64) << 2; + } + state = 1; + break; + case 1: + if (target) { + if ((size_t)tarindex + 1 >= targsize) + return (-1); + target[tarindex] |= (pos - Base64) >> 4; + target[tarindex+1] = ((pos - Base64) & 0x0f) + << 4 ; + } + tarindex++; + state = 2; + break; + case 2: + if (target) { + if ((size_t)tarindex + 1 >= targsize) + return (-1); + target[tarindex] |= (pos - Base64) >> 2; + target[tarindex+1] = ((pos - Base64) & 0x03) + << 6; + } + tarindex++; + state = 3; + break; + case 3: + if (target) { + if ((size_t)tarindex >= targsize) + return (-1); + target[tarindex] |= (pos - Base64); + } + tarindex++; + state = 0; + break; + default: + abort(); + } + } + + /* + * We are done decoding Base-64 chars. Let's see if we ended + * on a byte boundary, and/or with erroneous trailing characters. + */ + + if (ch == Pad64) { /* We got a pad char. */ + ch = *src++; /* Skip it, get next. */ + switch (state) { + case 0: /* Invalid = in first position */ + case 1: /* Invalid = in second position */ + return (-1); + + case 2: /* Valid, means one byte of info */ + /* Skip any number of spaces. */ + for ((void)NULL; ch != '\0'; ch = *src++) + if (! (isascii(ch) && isspace(ch))) + break; + /* Make sure there is another trailing = sign. */ + if (ch != Pad64) + return (-1); + ch = *src++; /* Skip the = */ + /* Fall through to "single trailing =" case. */ + /* FALLTHROUGH */ + + case 3: /* Valid, means two bytes of info */ + /* + * We know this char is an =. Is there anything but + * whitespace after it? + */ + for ((void)NULL; ch != '\0'; ch = *src++) + if (! (isascii(ch) && isspace(ch))) + return (-1); + + /* + * Now make sure for cases 2 and 3 that the "extra" + * bits that slopped past the last full byte were + * zeros. If we don't check them, they become a + * subliminal channel. + */ + if (target && target[tarindex] != 0) + return (-1); + } + } else { + /* + * We ended by seeing the end of the string. Make sure we + * have no partial bytes lying around. + */ + if (state != 0) + return (-1); + } + + return (tarindex); +} diff --git a/libraries/liblutil/detach.c b/libraries/liblutil/detach.c new file mode 100644 index 0000000000..72ec99741f --- /dev/null +++ b/libraries/liblutil/detach.c @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1990, 1994 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" + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "portable.h" + + +/* I'd really like to make do_close an fd_set, but that isn't portable. */ +void +lutil_detach( int debug, int do_close ) +{ + int i, sd, nbits; + +#ifdef HAVE_SYSCONF + nbits = sysconf( _SC_OPEN_MAX ); +#elif HAVE_GETDTABLESIZE + nbits = getdtablesize(); +#else + nbits = FD_SETSIZE; +#endif + +#ifdef FD_SETSIZE + if ( nbits > FD_SETSIZE ) { + nbits = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ + + if ( debug == 0 ) { + for ( i = 0; i < 5; i++ ) { +#if HAVE_THR + switch ( fork1() ) +#else + switch ( fork() ) +#endif + { + case -1: + sleep( 5 ); + continue; + + case 0: + break; + + default: + _exit( 0 ); + } + break; + } + + if ( do_close ) + for ( i = 3; i < nbits; i++ ) + close( i ); + + (void) chdir( "/" ); + + if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) { + perror( "/dev/null" ); + exit( 1 ); + } + for ( i = 0; i < 3; i++ ) + if ( sd != i && isatty( i ) ) + (void) dup2( sd, i ); + if ( sd > 2 ) + close( sd ); + +#ifdef HAVE_SETSID + (void) setsid(); +#else /* HAVE_SETSID */ + if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) { + (void) ioctl( sd, TIOCNOTTY, NULL ); + (void) close( sd ); + } +#endif /* HAVE_SETSID */ + } + + (void) SIGNAL( SIGPIPE, SIG_IGN ); +} diff --git a/libraries/liblutil/memcmp.c b/libraries/liblutil/memcmp.c new file mode 100644 index 0000000000..b2c575d955 --- /dev/null +++ b/libraries/liblutil/memcmp.c @@ -0,0 +1,19 @@ +#include "portable.h" + +#include + +/* + * Memory Compare + */ +int +memcmp(const void *v1, const void *v2, int n) +{ + if (n != 0) { + register const unsigned char *s1=v1, *s2=v2; + do { + if (*s1++ != *s2++) + return (*--s1 - *--s2); + } while (--n != 0); + } + return (0); +} diff --git a/libraries/liblutil/setproctitle.c b/libraries/liblutil/setproctitle.c new file mode 100644 index 0000000000..b2a590b612 --- /dev/null +++ b/libraries/liblutil/setproctitle.c @@ -0,0 +1,85 @@ +#include "portable.h" + +#ifndef HAVE_SETPROCTITLE + +#include + +#if defined( HAVE_STDARG_H ) && __STDC__ +#include +#else +#include +#endif + +#include + +/* + * 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 */ +void setproctitle +#if defined( HAVE_STDARG_H ) && __STDC__ + ( const char *fmt, ... ) +#else + ( fmt, va_alist ) +const char *fmt; +va_dcl +#endif +{ + static char *endargv = (char *)0; + char *s; + int i; + char buf[ 1024 ]; + va_list ap; + +#if defined( HAVE_STDARG_H ) && __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + +#ifdef HAVE_VSNPRINTF + buf[sizeof(buf) - 1] = '\0'; + vsnprintf( buf, sizeof(buf)-1, fmt, ap ); +#elif HAVE_VPRINTF + vsprintf( buf, fmt, ap ); /* hope it's not too long */ +#else + /* use doprnt() */ + chokeme = "choke me! I don't have a doprnt() manual handy"; +#endif + + va_end(ap); + + if ( endargv == (char *)0 ) { + /* set pointer to end of original argv */ + endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] ); + } + /* 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 */ diff --git a/servers/ldapd/Makefile.in b/servers/ldapd/Makefile.in new file mode 100644 index 0000000000..50c6d6bd59 --- /dev/null +++ b/servers/ldapd/Makefile.in @@ -0,0 +1,51 @@ +## +## Makefile.in for ldapd +## +PROGRAMS=ldapd +XPROGRAMS=sldapd +SRCS = main.c request.c bind.c result.c error.c \ + search.c util.c compare.c message.c add.c delete.c modrdn.c modify.c \ + abandon.c syntax.c association.c kerberos.c certificate.c +OBJS = main.o request.o bind.o result.o error.o \ + search.o util.o compare.o message.o add.o delete.o modrdn.o modify.o \ + abandon.o syntax.o association.o kerberos.o LDAP_tables.o \ + certificate.o + +LDAP_INCDIR= ../../include +LDAP_LIBDIR= ../../libraries + +BUILD_OPT = "--enable-ldapd" +BUILD_SRV = @BUILD_LDAPD@ + +XLIBS= @LDAPD_LIBS@ -llutil @LUTIL_LIBS@ + +all-local: $(PROGRAMS) + +ldapd: version.o + $(CC) $(LDFLAGS) -o $@ $(OBJS) version.o $(LIBS) + +sldapd: version.o + $(CC) $(LDFLAGS) -static -o $@ $(OBJS) version.o $(LDFLAGS) $(LIBS) -lresolv + +version.c: $(OBJS) $(LDAP_LIBDIR)/liblber/liblber.a + $(RM) $@ + (u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \ + t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < $(srcdir)/Version.c > $@) + +request.o: LDAP-types.h + +LDAP_tables.c: ldap.py + @if [ ! -z "$(PEPSY)" ]; then \ + $(PEPSY) -A ldap.py; \ + else \ + touch LDAP_tables.c LDAP-types.h; \ + fi + +LDAP-types.h: LDAP_tables.c + +install-local: FORCE + @$(MKDIR) -p $(libexecdir) + $(INSTALL) $(INSTALLFLAGS) -m 755 ldapd $(LDAP_LIBEXECDIR) diff --git a/servers/ldapd/bind.c b/servers/ldapd/bind.c index db76ff0bf7..20f97de576 100644 --- a/servers/ldapd/bind.c +++ b/servers/ldapd/bind.c @@ -10,21 +10,24 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include -#include -#include -#include -#include + +#include +#include /* get SAFEMEMCPY */ + #include #include #include #include #include + #include "lber.h" #include "ldap.h" #include "common.h" -#ifdef COMPAT20 +#ifdef LDAP_COMPAT20 extern int ldap_compat; #define BINDTAG (ldap_compat == 20 ? OLD_LDAP_RES_BIND : LDAP_RES_BIND) #else @@ -75,7 +78,7 @@ do_bind( LDAP_PROTOCOL_ERROR, NULL, "Decoding error" ); return( 0 ); } -#ifdef COMPAT30 +#ifdef LDAP_COMPAT30 if ( ldap_compat == 30 ) method = ber_skip_tag( ber, &len ); else @@ -141,7 +144,7 @@ do_bind_real( struct DSError dse; char *dn = dsaconn->c_dn; int err; -#ifdef KERBEROS +#ifdef HAVE_KERBEROS u_long nonce; #endif extern DN ldap_str2dn(); @@ -155,10 +158,10 @@ do_bind_real( } switch ( dsaconn->c_method ) { -#ifdef COMPAT20 +#ifdef LDAP_COMPAT20 case OLD_LDAP_AUTH_SIMPLE: #endif -#ifdef COMPAT30 +#ifdef LDAP_COMPAT30 case LDAP_AUTH_SIMPLE_30: #endif case LDAP_AUTH_SIMPLE: /* x.500 simple authentication */ @@ -176,11 +179,11 @@ do_bind_real( ba.dba_version = DBA_VERSION_V1988; break; -#ifdef KERBEROS -#ifdef COMPAT20 +#ifdef HAVE_KERBEROS +#ifdef LDAP_COMPAT20 case OLD_LDAP_AUTH_KRBV4: #endif -#ifdef COMPAT30 +#ifdef LDAP_COMPAT30 case LDAP_AUTH_KRBV41_30: #endif case LDAP_AUTH_KRBV41: /* kerberos authentication to ldap server */ @@ -188,10 +191,10 @@ do_bind_real( dsaconn->c_credlen ) ); break; -#ifdef COMPAT20 +#ifdef LDAP_COMPAT20 case OLD_LDAP_AUTH_KRBV42: #endif -#ifdef COMPAT30 +#ifdef LDAP_COMPAT30 case LDAP_AUTH_KRBV42_30: #endif case LDAP_AUTH_KRBV42: /* kerberos authentication to x500 dsa */ @@ -254,7 +257,7 @@ do_bind_real( Debug( LDAP_DEBUG_TRACE, "dap_bind successful\n", 0, 0, 0 ); -#ifdef KERBEROS +#ifdef HAVE_KERBEROS /* XXX why doesn't this work?? if ( dsaconn->c_method == LDAP_AUTH_KRBV42 && kerberos_check_mutual( &br, nonce ) != 0 ) { diff --git a/servers/ldapd/delete.c b/servers/ldapd/delete.c index 57fe76ec07..7c7b6ebfe8 100644 --- a/servers/ldapd/delete.c +++ b/servers/ldapd/delete.c @@ -10,20 +10,26 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include +/* ac/socket.h must precede ISODE #includes or p_type must be #undeffed + * after it is included. (Because ISODE uses p_type as a field name, and + * SunOS 5.5:sys/vtype.h defines it (and ac/socket.h indirectly includes it) */ +#include + #include #include #include #include #include #include -#include -#include + #include "lber.h" #include "ldap.h" #include "common.h" -#ifdef COMPAT20 +#ifdef HAVE_COMPAT20 extern int ldap_compat; #define DELTAG (ldap_compat == 20 ? OLD_LDAP_RES_DELETE : LDAP_RES_DELETE) #else diff --git a/servers/ldapd/main.c b/servers/ldapd/main.c index 5626a34c4f..43eac641f2 100644 --- a/servers/ldapd/main.c +++ b/servers/ldapd/main.c @@ -17,36 +17,41 @@ * University of Minnesota Microcomputer Workstation and Networks Center */ +#include "portable.h" + #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _AIX -#include -#endif -#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef LDAP_PROCTITLE +#include +#endif + #include #include -#include "portable.h" + #include "lber.h" #include "ldap.h" #include "common.h" -#ifdef USE_SYSCONF -#include -#endif /* USE_SYSCONF */ +#ifdef HAVE_TCPD +#include + +int allow_severity = LOG_INFO; +int deny_severity = LOG_NOTICE; +#endif /* TCP_WRAPPERS */ void log_and_exit(); static set_socket(); static do_queries(); -static SIG_FN wait4child(); -#ifdef CLDAP +static RETSIGTYPE wait4child(); +#ifdef LDAP_CONNECTIONLESS static udp_init(); #endif @@ -54,18 +59,18 @@ static udp_init(); int ldap_debug; #endif int version; -#ifdef COMPAT +#ifdef LDAP_COMPAT int ldap_compat; #endif int dosyslog; int do_tcp = 1; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS int do_udp = 0; #endif int idletime = DEFAULT_TIMEOUT; int referral_connection_timeout = DEFAULT_REFERRAL_TIMEOUT; struct timeval conn_start_tv; -#ifdef KERBEROS +#ifdef HAVE_KERBEROS char *krb_ldap_service = "ldapserver"; char *krb_x500_service = "x500dsa"; char *krb_x500_instance; @@ -82,13 +87,13 @@ static usage( name ) char *name; { fprintf( stderr, "usage: %s [-d debuglvl] [-p port] [-l] [-c dsa] [-r referraltimeout]", name ); -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS fprintf( stderr, " [ -U | -t timeout ]" ); #else fprintf( stderr, " [ -t timeout ]" ); #endif fprintf( stderr, " [-I]" ); -#ifdef KERBEROS +#ifdef HAVE_KERBEROS fprintf( stderr, " [-i dsainstance]" ); #endif fprintf( stderr, "\n" ); @@ -99,7 +104,7 @@ int argc; char **argv; { int tcps, ns; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS int udps; #endif int myport = LDAP_PORT; @@ -111,11 +116,9 @@ char **argv; int len; int dsapargc; char **dsapargv; - SIG_FN wait4child(); -#ifndef NOSETPROCTITLE + RETSIGTYPE wait4child(); +#ifdef LDAP_PROCTITLE char title[80]; - extern char **Argv; - extern int Argc; #endif extern char *optarg; extern int optind; @@ -139,7 +142,7 @@ char **argv; dsapargv[2] = 0; dsapargv[3] = 0; dsapargc = 1; -#ifdef KERBEROS +#ifdef HAVE_KERBEROS kerberos_keyfile = ""; #endif @@ -178,7 +181,7 @@ char **argv; idletime = atoi( optarg ); break; -#ifdef KERBEROS +#ifdef HAVE_KERBEROS case 'f': /* kerberos key file */ kerberos_keyfile = strdup( optarg ); break; @@ -194,7 +197,7 @@ char **argv; RunFromInetd = 1; break; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS case 'U': /* UDP only (no TCP) */ do_tcp = 0; do_udp = 1; @@ -206,7 +209,7 @@ char **argv; break; #endif /* NOTYET */ -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ default: usage( argv[0] ); @@ -219,7 +222,7 @@ char **argv; exit( 1 ); } -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( do_udp && !do_tcp && idletime != DEFAULT_TIMEOUT ) { usage( argv[ 0 ] ); exit( 1 ); @@ -228,13 +231,21 @@ char **argv; Debug( LDAP_DEBUG_TRACE, "%s", Versionstr, 0, 0 ); -#ifdef USE_SYSCONF +#ifdef HAVE_SYSCONF dtblsize = sysconf( _SC_OPEN_MAX ); -#else /* USE_SYSCONF */ +#elif HAVE_GETDTABLESIZE dtblsize = getdtablesize(); -#endif /* USE_SYSCONF */ +#else + dtblsize = FD_SETSIZE; +#endif -#ifndef NOSETPROCTITLE +#ifdef FD_SETSIZE + if( dtblsize > FD_SETSIZE ) { + dtblsize = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ + +#if defined(LDAP_PROCTITLE) && !defined( HAVE_SETPROCTITLE ) /* for setproctitle */ Argv = argv; Argc = argc; @@ -251,11 +262,15 @@ char **argv; * that have exited */ if (!RunFromInetd) { -#ifndef NOSETPROCTITLE +#ifdef LDAP_PROCTITLE setproctitle( "initializing" ); #endif #ifndef VMS - (void) detach(); +# ifdef LDAP_DEBUG + lutil_detach( ldap_debug, 1 ); +# else + lutil_detach( 0, 1 ); +# endif #endif (void) SIGNAL( SIGCHLD, (void *) wait4child ); (void) SIGNAL( SIGINT, (void *) log_and_exit ); @@ -292,17 +307,17 @@ char **argv; len = sizeof( socktype ); getsockopt( ns, SOL_SOCKET, SO_TYPE, &socktype, &len ); if ( socktype == SOCK_DGRAM ) { -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS Debug( LDAP_DEBUG_ARGS, "CLDAP request from unknown (%s)\n", inet_ntoa( from.sin_addr ), 0, 0 ); conn_start_tv.tv_sec = 0; udp_init( 0, 0 ); do_queries( ns, 1 ); -#else /* CLDAP */ +#else /* LDAP_CONNECTIONLESS */ Debug( LDAP_DEBUG_ARGS, - "Compile with -DCLDAP for UDP support\n",0,0,0 ); -#endif /* CLDAP */ + "Compile with -DLDAP_CONNECTIONLESS for UDP support\n",0,0,0 ); +#endif /* LDAP_CONNECTIONLESS */ exit( 0 ); } @@ -321,7 +336,7 @@ char **argv; inet_ntoa( from.sin_addr ) ); } -#ifndef NOSETPROCTITLE +#ifdef LDAP_PROCTITLE sprintf( title, "%s %d\n", hp == NULL ? inet_ntoa( from.sin_addr ) : hp->h_name, myport ); setproctitle( title ); @@ -336,7 +351,7 @@ char **argv; if ( do_tcp ) tcps = set_socket( myport, 0 ); -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( do_udp ) udps = udp_init( myport, 1 ); #endif @@ -346,8 +361,8 @@ char **argv; * if we are doing CLDAP as well, handle those requests on the fly */ -#ifndef NOSETPROCTITLE -#ifdef CLDAP +#ifdef LDAP_PROCTITLE +#ifdef LDAP_CONNECTIONLESS sprintf( title, "listening %s/%s %d", do_tcp ? "tcp" : "", do_udp ? "udp" : "", myport ); #else @@ -360,7 +375,7 @@ char **argv; FD_ZERO( &readfds ); if ( do_tcp ) FD_SET( tcps, &readfds ); -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( do_udp ) FD_SET( udps, &readfds ); #endif @@ -372,7 +387,7 @@ char **argv; continue; } -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( do_udp && FD_ISSET( udps, &readfds ) ) { do_queries( udps, 1 ); } @@ -393,10 +408,31 @@ char **argv; hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr), sizeof(from.sin_addr.s_addr), AF_INET ); + +#ifdef HAVE_TCPD + if ( !hosts_ctl("ldapd", (hp == NULL) ? "unknown" : hp->h_name, + inet_ntoa( from.sin_addr ), STRING_UNKNOWN ) { + + Debug( LDAP_DEBUG_ARGS, "connection from %s (%s) denied.\n", + (hp == NULL) ? "unknown" : hp->h_name, + inet_ntoa( from.sin_addr ), 0 ); + + if ( dosyslog ) { + syslog( LOG_NOTICE, "connection from %s (%s) denied.", + (hp == NULL) ? "unknown" : hp->h_name, + inet_ntoa( from.sin_addr ) ); + } + + close(ns); + continue; + } +#endif /* TCP_WRAPPERS */ + Debug( LDAP_DEBUG_ARGS, "connection from %s (%s)\n", (hp == NULL) ? "unknown" : hp->h_name, inet_ntoa( from.sin_addr ), 0 ); + if ( dosyslog ) { syslog( LOG_INFO, "connection from %s (%s)", (hp == NULL) ? "unknown" : hp->h_name, @@ -406,7 +442,7 @@ char **argv; #ifdef VMS /* This is for debug on terminal on VMS */ close( tcps ); -#ifndef NOSETPROCTITLE +#ifdef LDAP_PROCTITLE setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) : hp->h_name ); #endif @@ -420,7 +456,7 @@ char **argv; switch( pid = fork() ) { case 0: /* child */ close( tcps ); -#ifndef NOSETPROCTITLE +#ifdef LDAP_PROCTITLE sprintf( title, "%s (%d)\n", hp == NULL ? inet_ntoa( from.sin_addr ) : hp->h_name, myport ); @@ -462,10 +498,10 @@ do_queries( int rc, i; struct timeval timeout; Sockbuf sb; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS struct sockaddr saddr, faddr; struct sockaddr *saddrlist[ 1 ]; -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ Debug( LDAP_DEBUG_TRACE, "do_queries%s\n", udp ? " udp" : "", 0, 0 ); @@ -487,7 +523,7 @@ do_queries( (void) memset( (void *) &sb, '\0', sizeof( sb ) ); sb.sb_sd = clientsock; sb.sb_naddr = ( udp ) ? 1 : 0; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS sb.sb_addrs = (void **)saddrlist; sb.sb_fromaddr = &faddr; sb.sb_useaddr = saddrlist[ 0 ] = &saddr; @@ -611,18 +647,20 @@ static set_socket( return( s ); } -static SIG_FN wait4child() +static RETSIGTYPE wait4child() { - WAITSTATUSTYPE status; +#ifndef HAVE_WAITPID + WAITSTATUSTYPE status; +#endif Debug( LDAP_DEBUG_TRACE, "parent: catching child status\n", 0, 0, 0 ); -#ifdef USE_WAITPID - while( waitpid( (pid_t) -1, 0, WAIT_FLAGS ) > 0 ) +#ifdef HAVE_WAITPID + while( waitpid( (pid_t) -1, NULL, WAIT_FLAGS ) > 0 ) ; /* NULL */ #else - while ( wait3( &status, WAIT_FLAGS, 0 ) > 0 ) - ; /* NULL */ + while ( wait3( &status, WAIT_FLAGS, 0 ) > 0 ) + ; /* NULL */ #endif (void) SIGNAL( SIGCHLD, (void *) wait4child ); @@ -648,7 +686,7 @@ log_and_exit( int exitcode ) } -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS static int udp_init( int port, diff --git a/servers/ldapd/modify.c b/servers/ldapd/modify.c index bbfd5ed82a..dd4538c034 100644 --- a/servers/ldapd/modify.c +++ b/servers/ldapd/modify.c @@ -10,16 +10,21 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include -#include + +#include +#include +#include /* get SAFEMEMCPY */ + #include #include #include #include #include #include -#include -#include + #include "lber.h" #include "ldap.h" #include "common.h" @@ -38,8 +43,9 @@ extern short ldap_rts_cred_syntax; extern short ldap_rtl_syntax; extern short ldap_octetstring_syntax; +static int replace_mod( struct entrymod *, Attr_Sequence, Attr_Sequence ); -#ifdef COMPAT20 +#ifdef LDAP_COMPAT20 extern int ldap_compat; #define MODTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODIFY : LDAP_RES_MODIFY) #else @@ -517,7 +523,7 @@ modlist_free( LDAPMod *mods ) * that are not in the new set and by only adding what isn't in old set */ -int +static int replace_mod( struct entrymod *rem, Attr_Sequence oas, diff --git a/servers/slapd/Makefile.in b/servers/slapd/Makefile.in new file mode 100644 index 0000000000..f7b4d91020 --- /dev/null +++ b/servers/slapd/Makefile.in @@ -0,0 +1,112 @@ +## +## Makefile.in for slapd +## +PROGRAMS=slapd +XPROGRAMS=libbackends.a .backend +SRCS = main.c daemon.c connection.c search.c filter.c add.c charray.c \ + attr.c entry.c config.c backend.c result.c operation.c \ + dn.c compare.c modify.c delete.c modrdn.c ch_malloc.c \ + value.c ava.c bind.c unbind.c abandon.c filterentry.c \ + phonetic.c acl.c str2filter.c aclparse.c init.c \ + repl.c lock.c \ + suffixalias.c schema.c schemaparse.c monitor.c configinfo.c +OBJS = main.o daemon.o connection.o search.o filter.o add.o charray.o \ + attr.o entry.o config.o backend.o result.o operation.o \ + dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \ + value.o ava.o bind.o unbind.o abandon.o filterentry.o \ + phonetic.o acl.o str2filter.o aclparse.o init.o \ + repl.o lock.o \ + suffixalias.o schema.o schemaparse.o monitor.o configinfo.o + +LDAP_INCDIR= ../../include +LDAP_LIBDIR= ../../libraries + +BUILD_OPT = "--enable-slapd" +BUILD_SRV = @BUILD_SLAPD@ + +all-local: FORCE + $(MAKE) $(MFLAGS) backendslib + $(MAKE) $(MFLAGS) slapd + (cd tools; $(MAKE) $(MFLAGS) all) + +XLIBS = @SLAPD_LIBS@ libbackends.a \ + -lavl -lldbm @LDBM_LIBS@ -llthread @LTHREAD_LIBS@ -llutil @LUTIL_LIBS@ + +slapd: version.o + $(CC) $(LDFLGS) -o $@ $(OBJS) version.o $(LIBS) + +backendslib: FORCE + @for i in back-*; do \ + if [ -d $$i ]; then \ + echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \ + ( cd $$i; $(MAKE) $(MFLAGS) all ); \ + fi; \ + done; \ + echo " "; \ + $(MAKE) $(MFLAGS) libbackends.a + +libbackends.a: .backend + @$(RM) -r tmp + @$(MKDIR) tmp + @-for i in back-*/*.a; do \ + ( \ + cd tmp; \ + $(AR) x ../$$i; \ + pre=`echo $$i | sed -e 's/\/.*$$//' -e 's/back-//'`; \ + for j in *.o; do \ + mv $$j $${pre}$$j; \ + done; \ + $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \ + $(RM) *.o __.SYMDEF; \ + echo "added backend library $$i"; \ + ); \ + done + @mv -f tmp/libbackends.a ./libbackends.a + @$(RM) -r tmp + @if [ ! -z "$(RANLIB)" ]; then \ + $(RANLIB) libbackends.a; \ + fi + @ls -l libbackends.a + +version.c: libbackends.a $(OBJS) $(LDAP_LIBDEPEND) \ + $(LDAP_LIBDIR)/libldbm.a \ + $(LDAP_LIBDIR)/libavl.a \ + $(LDAP_LIBDIR)/libldif.a \ + $(LDAP_LIBDIR)/liblutil.a \ + $(LDAP_LIBDIR)/liblthread.a + $(RM) $@ + (u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \ + t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < $(srcdir)/Version.c > $@) + +clean-local: FORCE + @for i in back-* tools; do \ + if [ -d $$i ]; then \ + echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \ + ( cd $$i; $(MAKE) $(MFLAGS) clean ); \ + fi; \ + done + +install-local: install-slapd install-conf install-tools + +install-slapd: FORCE + @-$(MKDIR) $(libexecdir) + $(INSTALL) $(INSTALLFLAGS) -m 755 slapd $(libexecdir) + +install-conf: FORCE + @-$(MKDIR) -p $(sysconfdir) + $(SED) -e 's;%SYSCONFDIR%;$(sysconfdir);' slapd.conf > /tmp/slapd.$$ + -$(MV) $(sysconfdir)/slapd.conf $(sysconfdir)/slapd.conf- + $(INSTALL) $(INSTALLFLAGS) -m 644 /tmp/slapd.$$ $(sysconfdir)/slapd.conf + $(RM) -f /tmp/slapd.$$ + -$(MV) $(sysconfdir)/slapd.at.conf $(sysconfdir)/slapd.at.conf- + $(INSTALL) $(INSTALLFLAGS) -m 644 slapd.at.conf $(sysconfdir) + -$(MV) $(sysconfdir)/slapd.oc.conf $(sysconfdir)/slapd.oc.conf- + $(INSTALL) $(INSTALLFLAGS) -m 644 slapd.oc.conf $(sysconfdir) + +install-tools: FORCE + @-$(MKDIR) $(sbindir) + (cd tools; $(MAKE) $(MFLAGS) install) + diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index cc208217bb..f8dea06bd5 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -293,9 +293,10 @@ parse_acl( } else { - if (ldap_debug&LDAP_DEBUG_ACL) - print_acl(a); - +#ifdef LDAP_DEBUG + if (ldap_debug & LDAP_DEBUG_ACL) + print_acl(a); +#endif if ( a->acl_access == NULL ) { fprintf( stderr, diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 2ec7b0902b..9839a542c1 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -367,7 +367,7 @@ onelevel_candidates( f->f_and = (Filter *) ch_malloc( sizeof(Filter) ); f->f_and->f_choice = LDAP_FILTER_EQUALITY; f->f_and->f_ava.ava_type = strdup( "id2children" ); - sprintf( buf, "%d", e != NULL ? e->e_id : 0 ); + sprintf( buf, "%ld", e != NULL ? e->e_id : 0 ); f->f_and->f_ava.ava_value.bv_val = strdup( buf ); f->f_and->f_ava.ava_value.bv_len = strlen( buf ); f->f_and->f_next = filter; diff --git a/servers/slapd/lock.c b/servers/slapd/lock.c index 305fb5b91c..47f09cf546 100644 --- a/servers/slapd/lock.c +++ b/servers/slapd/lock.c @@ -1,15 +1,15 @@ /* lock.c - routines to open and apply an advisory lock to a file */ -#include -#include -#include #include "portable.h" -#ifdef USE_LOCKF -#include -#endif + +#include + +#include +#include +#include + #include #include -#include #include "slap.h" FILE * @@ -27,10 +27,10 @@ lock_fopen( char *fname, char *type, FILE **lfp ) } /* acquire the lock */ -#ifdef USE_LOCKF - while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 ) { -#else +#ifdef HAVE_FLOCK while ( flock( fileno( *lfp ), LOCK_EX ) != 0 ) { +#else + while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 ) { #endif ; /* NULL */ } @@ -38,10 +38,10 @@ lock_fopen( char *fname, char *type, FILE **lfp ) /* open the log file */ if ( (fp = fopen( fname, type )) == NULL ) { Debug( LDAP_DEBUG_ANY, "could not open \"%s\"\n", fname, 0, 0 ); -#ifdef USE_LOCKF - lockf( fileno( *lfp ), F_ULOCK, 0 ); -#else +#ifdef HAVE_FLOCK flock( fileno( *lfp ), LOCK_UN ); +#else + lockf( fileno( *lfp ), F_ULOCK, 0 ); #endif return( NULL ); } @@ -53,10 +53,10 @@ int lock_fclose( FILE *fp, FILE *lfp ) { /* unlock */ -#ifdef USE_LOCKF - lockf( fileno( lfp ), F_ULOCK, 0 ); -#else +#ifdef HAVE_FLOCK flock( fileno( lfp ), LOCK_UN ); +#else + lockf( fileno( lfp ), F_ULOCK, 0 ); #endif fclose( lfp ); diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 01930b9709..e93777db73 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -1,25 +1,25 @@ -#include -#include -#include -#include -#include -#include -#include -#include #include "portable.h" + +#include + +#include +#include +#include + #include "slap.h" #include "ldapconfig.h" -extern void daemon(); +extern void slapd_daemon(); extern int lber_debug; extern char Versionstr[]; + /* * read-only global variables or variables only written by the listener * thread (after they are initialized) - no need to protect them with a mutex. */ -int ldap_debug; +int ldap_debug = 0; #ifdef LDAP_DEBUG int ldap_syslog = LDAP_DEBUG_STATS; #else @@ -55,15 +55,12 @@ pthread_mutex_t num_sent_mutex; */ pthread_mutex_t entry2str_mutex; pthread_mutex_t replog_mutex; -#ifndef sunos5 -pthread_mutex_t regex_mutex; -#endif static usage( name ) char *name; { - fprintf( stderr, "usage: %s [-d debuglevel] [-f configfile] [-p portnumber] [-s sysloglevel]\n", name ); + fprintf( stderr, "usage: %s [-d ?|debuglevel] [-f configfile] [-p portnumber] [-s sysloglevel]\n", name ); } main( argc, argv ) @@ -105,19 +102,19 @@ main( argc, argv ) LDAP_DEBUG_CONFIG ); printf( "\tLDAP_DEBUG_ACL\t\t%d\n", LDAP_DEBUG_ACL ); - printf( "\tLDAP_DEBUG_STATS\t\t%d\n", + printf( "\tLDAP_DEBUG_STATS\t%d\n", LDAP_DEBUG_STATS ); - printf( "\tLDAP_DEBUG_STATS2\t\t%d\n", + printf( "\tLDAP_DEBUG_STATS2\t%d\n", LDAP_DEBUG_STATS2 ); - printf( "\tLDAP_DEBUG_SHELL\t\t%d\n", + printf( "\tLDAP_DEBUG_SHELL\t%d\n", LDAP_DEBUG_SHELL ); - printf( "\tLDAP_DEBUG_PARSE\t\t%d\n", + printf( "\tLDAP_DEBUG_PARSE\t%d\n", LDAP_DEBUG_PARSE ); printf( "\tLDAP_DEBUG_ANY\t\t%d\n", LDAP_DEBUG_ANY ); exit( 0 ); } else { - ldap_debug = atoi( optarg ); + ldap_debug |= atoi( optarg ); lber_debug = (ldap_debug & LDAP_DEBUG_BER); } break; @@ -165,7 +162,11 @@ main( argc, argv ) if ( ! inetd ) { /* pre-open config file before detach in case it is a relative path */ fp = fopen( configfile, "r" ); - detach(); +#ifdef LDAP_DEBUG + lutil_detach( ldap_debug, 0 ); +#else + lutil_detach( 0, 0 ); +#endif } #ifdef LOG_LOCAL4 openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL4 ); @@ -184,12 +185,27 @@ main( argc, argv ) pthread_attr_init( &attr ); pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED ); - if ( pthread_create( &listener_tid, attr, (void *) daemon, +#if !defined(HAVE_PTHREADS_D4) && !defined(HAVE_DCE) + /* POSIX_THREADS or compatible + * This is a draft 10 or standard pthreads implementation + */ + if ( pthread_create( &listener_tid, &attr, slapd_daemon, + (void *) port ) != 0 ) { + Debug( LDAP_DEBUG_ANY, + "listener pthread_create failed\n", 0, 0, 0 ); + exit( 1 ); + } +#else /* draft4 */ + /* + * This is a draft 4 or earlier pthreads implementation + */ + if ( pthread_create( &listener_tid, attr, slapd_daemon, (void *) port ) != 0 ) { Debug( LDAP_DEBUG_ANY, "listener pthread_create failed\n", 0, 0, 0 ); exit( 1 ); } +#endif /* !draft4 */ pthread_attr_destroy( &attr ); pthread_join( listener_tid, (void *) &status ); pthread_exit( 0 ); @@ -221,7 +237,7 @@ main( argc, argv ) #endif flen = sizeof(from); if ( getpeername( 0, (struct sockaddr *) &from, &flen ) == 0 ) { -#ifdef REVERSE_LOOKUP +#ifdef SLAPD_RLOOKUPS hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr), sizeof(from.sin_addr.s_addr), AF_INET ); #else diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index 7dbabc9377..73a78c8f70 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -10,10 +10,21 @@ * is provided ``as is'' without express or implied warranty. */ +/* Revision history + * + * 5-Jun-96 jeff.hodges@stanford.edu + * Added locking of new_conn_mutex when traversing the c[] array. + * Added locking of currenttime_mutex to protect call(s) to localtime(). + */ + +#include "portable.h" + #include -#include -#include -#include + +#include +#include +#include + #include "slap.h" #include "ldapconfig.h" @@ -32,18 +43,16 @@ extern time_t currenttime; extern time_t starttime; extern int num_conns; +extern pthread_mutex_t new_conn_mutex; +extern pthread_mutex_t currenttime_mutex; extern char Versionstr[]; -/* - * no mutex protection in here - take our chances! - */ - void monitor_info( Connection *conn, Operation *op ) { Entry *e; - char buf[BUFSIZ], buf2[20]; + char buf[BUFSIZ], buf2[22]; struct berval val; struct berval *vals[2]; int i, nconns, nwritewaiters, nreadwaiters; @@ -54,6 +63,8 @@ monitor_info( Connection *conn, Operation *op ) vals[1] = NULL; e = (Entry *) ch_calloc( 1, sizeof(Entry) ); + /* initialize reader/writer lock */ + entry_rdwr_init(e); e->e_attrs = NULL; e->e_dn = strdup( SLAPD_MONITOR_DN ); @@ -73,6 +84,8 @@ monitor_info( Connection *conn, Operation *op ) nconns = 0; nwritewaiters = 0; nreadwaiters = 0; + + pthread_mutex_lock( &new_conn_mutex ); for ( i = 0; i < dtblsize; i++ ) { if ( c[i].c_sb.sb_sd != -1 ) { nconns++; @@ -82,8 +95,16 @@ monitor_info( Connection *conn, Operation *op ) if ( c[i].c_gettingber ) { nreadwaiters++; } + pthread_mutex_lock( ¤ttime_mutex ); +#ifndef LDAP_LOCALTIME + ltm = gmtime( &c[i].c_starttime ); + strftime( buf2, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm ); +#else ltm = localtime( &c[i].c_starttime ); strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); +#endif + pthread_mutex_unlock( ¤ttime_mutex ); + pthread_mutex_lock( &c[i].c_dnmutex ); sprintf( buf, "%d : %s : %ld : %ld : %s : %s%s", i, buf2, c[i].c_opsinitiated, c[i].c_opscompleted, @@ -96,6 +117,8 @@ monitor_info( Connection *conn, Operation *op ) attr_merge( e, "connection", vals ); } } + pthread_mutex_unlock( &new_conn_mutex ); + sprintf( buf, "%d", nconns ); val.bv_val = buf; val.bv_len = strlen( buf ); @@ -141,14 +164,28 @@ monitor_info( Connection *conn, Operation *op ) val.bv_len = strlen( buf ); attr_merge( e, "bytessent", vals ); - ltm = localtime( ¤ttime ); - strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); + pthread_mutex_lock( ¤ttime_mutex ); +#ifndef LDAP_LOCALTIME + ltm = gmtime( ¤ttime ); + strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); +#else + ltm = localtime( ¤ttime ); + strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); +#endif + pthread_mutex_unlock( ¤ttime_mutex ); val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "currenttime", vals ); - ltm = localtime( &starttime ); - strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); + pthread_mutex_lock( ¤ttime_mutex ); +#ifndef LDAP_LOCALTIME + ltm = gmtime( &starttime ); + strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); +#else + ltm = localtime( &starttime ); + strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); +#endif + pthread_mutex_unlock( ¤ttime_mutex ); val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "starttime", vals ); @@ -158,7 +195,7 @@ monitor_info( Connection *conn, Operation *op ) val.bv_len = strlen( buf ); attr_merge( e, "nbackends", vals ); -#ifdef THREAD_SUNOS5_LWP +#ifdef HAVE_THR sprintf( buf, "%d", thr_getconcurrency() ); val.bv_val = buf; val.bv_len = strlen( buf ); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 46e7e90260..79233f88e5 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -20,6 +20,9 @@ #include "lthread.h" #include "lthread_rdwr.h" #include "ldif.h" +#ifdef f_next +#undef f_next /* name conflict between sys/file.h on SCO and struct filter */ +#endif #define DN_DNS 0 #define DN_X500 1 diff --git a/servers/slapd/tools/centipede.c b/servers/slapd/tools/centipede.c index 9919232b7a..8e964ed05e 100644 --- a/servers/slapd/tools/centipede.c +++ b/servers/slapd/tools/centipede.c @@ -1,11 +1,16 @@ /* centipede.c - generate and install indexing information (view w/tabstop=4) */ +#include "portable.h" + #include -#include -#include -#include + +#include +#include +#include + #include #include + #include #include @@ -68,7 +73,7 @@ static void usage( char *name ) main( int argc, char **argv ) { - char *ldapfilter, *ldapref; + char *ldapfilter; char *ldapsrcurl, *ldapdesturl; LDAP *ld; LDAPMod **mods; @@ -161,8 +166,7 @@ main( int argc, char **argv ) srcldapauthmethod = LDAP_AUTH_KRBV4; } else { fprintf( stderr, "%s: unknown auth method\n", optarg ); - fprintf( stderr, "expecting \"simple\" or \"kerberos\"\n", - optarg ); + fputs( "expecting \"simple\" or \"kerberos\"\n", stderr ); exit( 1 ); } break; @@ -174,8 +178,7 @@ main( int argc, char **argv ) destldapauthmethod = LDAP_AUTH_KRBV4; } else { fprintf( stderr, "%s: unknown auth method\n", optarg ); - fprintf( stderr, "expecting \"simple\" or \"kerberos\"\n", - optarg ); + fputs( "expecting \"simple\" or \"kerberos\"\n", stderr ); exit( 1 ); } break; @@ -353,9 +356,11 @@ start_ldap_search( char *s, *s2; int i; - if ( strncmp( ldapsrcurl, "ldap://", 7 ) == 0 ) { - s = ldapsrcurl + 7; + if ( strncmp( ldapsrcurl, "ldap://", 7 ) != 0 ) { + fputs( "Not an LDAP URL", stderr ); /* Should be smarter? */ + return( NULL ); } + s = ldapsrcurl + 7; if ( (s2 = strchr( s, '/' )) == NULL ) { ldapbase = strdup( s ); } else { @@ -493,7 +498,7 @@ generate_new_centroids( /* normalize the value */ for ( s = val[j]; *s; s++ ) { if ( isascii( *s ) ) { - *s = tolower( *s ); + *s = TOLOWER( *s ); } last = *s; } @@ -556,6 +561,11 @@ diff_centroids( int amax, acur, dmax, dcur; char **vals; +#ifdef HAVE_BERKELEY_DB2 + DBC *ocursorp; + DBC *ncursorp; +#endif /* HAVE_BERKELEY_DB2 */ + if ( verbose ) { printf( "Generating mods for differential %s centroid...", attr ); fflush( stdout ); @@ -600,8 +610,14 @@ diff_centroids( olast.dptr = NULL; nlast.dptr = NULL; +#ifdef HAVE_BERKELEY_DB2 + for ( okey = ldbm_firstkey( oldbm, &ocursorp ), + nkey = ldbm_firstkey( nldbm, &ncursorp ); + okey.dptr != NULL && nkey.dptr != NULL; ) +#else for ( okey = ldbm_firstkey( oldbm ), nkey = ldbm_firstkey( nldbm ); okey.dptr != NULL && nkey.dptr != NULL; ) +#endif { rc = strcmp( okey.dptr, nkey.dptr ); @@ -616,8 +632,13 @@ diff_centroids( } nlast = nkey; +#ifdef HAVE_BERKELEY_DB2 + okey = ldbm_nextkey( oldbm, olast, ocursorp ); + nkey = ldbm_nextkey( nldbm, nlast, ncursorp ); +#else okey = ldbm_nextkey( oldbm, olast ); nkey = ldbm_nextkey( nldbm, nlast ); +#endif } else if ( rc > 0 ) { /* new value is not in old centroid - add it */ if ( charray_add_dup( &avals, &acur, &amax, nkey.dptr ) == NULL ) { @@ -629,7 +650,12 @@ diff_centroids( ldbm_datum_free( nldbm, nlast ); } nlast = nkey; + +#ifdef HAVE_BERKELEY_DB2 + nkey = ldbm_nextkey( nldbm, nlast, ncursorp ); +#else nkey = ldbm_nextkey( nldbm, nlast ); +#endif } else { /* old value is not in new centroid - delete it */ if ( charray_add_dup( &dvals, &dcur, &dmax, okey.dptr ) == NULL ) { @@ -641,7 +667,12 @@ diff_centroids( ldbm_datum_free( oldbm, olast ); } olast = okey; + +#ifdef HAVE_BERKELEY_DB2 + okey = ldbm_nextkey( oldbm, olast, ocursorp ); +#else okey = ldbm_nextkey( oldbm, olast ); +#endif } } @@ -651,7 +682,11 @@ diff_centroids( return( NULL ); } +#ifdef HAVE_BERKELEY_DB2 + okey = ldbm_nextkey( oldbm, olast, ocursorp ); +#else okey = ldbm_nextkey( oldbm, olast ); +#endif if ( olast.dptr != NULL ) { ldbm_datum_free( oldbm, olast ); } @@ -666,7 +701,11 @@ diff_centroids( return( NULL ); } +#ifdef HAVE_BERKELEY_DB2 + nkey = ldbm_nextkey( nldbm, nlast, ncursorp ); +#else nkey = ldbm_nextkey( nldbm, nlast ); +#endif if ( nlast.dptr != NULL ) { ldbm_datum_free( nldbm, nlast ); } @@ -687,8 +726,14 @@ diff_centroids( /* generate list of values to add */ lastkey.dptr = NULL; +#ifdef HAVE_BERKELEY_DB2 + for ( key = ldbm_firstkey( nldbm, &ncursorp ); key.dptr != NULL; + key = ldbm_nextkey( nldbm, lastkey, ncursorp ) ) +#else for ( key = ldbm_firstkey( nldbm ); key.dptr != NULL; - key = ldbm_nextkey( nldbm, lastkey ) ) { + key = ldbm_nextkey( nldbm, lastkey ) ) +#endif + { /* see if it's in the old one */ data = ldbm_fetch( oldbm, key ); @@ -712,8 +757,14 @@ diff_centroids( /* generate list of values to delete */ lastkey.dptr = NULL; +#ifdef HAVE_BERKELEY_DB2 + for ( key = ldbm_firstkey( oldbm, &ocursorp ); key.dptr != NULL; + key = ldbm_nextkey( oldbm, lastkey, ocursorp ) ) +#else for ( key = ldbm_firstkey( oldbm ); key.dptr != NULL; - key = ldbm_nextkey( oldbm, lastkey ) ) { + key = ldbm_nextkey( oldbm, lastkey ) ) +#endif + { /* see if it's in the new one */ data = ldbm_fetch( nldbm, key ); @@ -773,6 +824,10 @@ full_centroid( char **vals; int vcur, vmax; +#ifdef HAVE_BERKELEY_DB2 + DBC *cursorp; +#endif + if ( verbose ) { printf( "Generating mods for full %s centroid...", attr ); fflush( stdout ); @@ -800,8 +855,14 @@ full_centroid( lastkey.dptr = NULL; vals = NULL; vcur = vmax = 0; +#ifdef HAVE_BERKELEY_DB2 + for ( key = ldbm_firstkey( ldbm, &cursorp ); key.dptr != NULL; + key = ldbm_nextkey( ldbm, lastkey, cursorp ) ) +#else for ( key = ldbm_firstkey( ldbm ); key.dptr != NULL; - key = ldbm_nextkey( ldbm, lastkey ) ) { + key = ldbm_nextkey( ldbm, lastkey ) ) +#endif + { if ( charray_add_dup( &vals, &vcur, &vmax, key.dptr ) == NULL ) { ldap_mods_free( mods, 1 ); return( NULL ); @@ -862,10 +923,13 @@ bind_to_destination_ldap( /* first, pick out the destination ldap server info */ if ( ldapbase != NULL ) { free( ldapbase ); + ldapbase = NULL; } - if ( strncmp( ldapdesturl, "ldap://", 7 ) == 0 ) { - s = ldapdesturl + 7; + if ( strncmp( ldapdesturl, "ldap://", 7 ) != 0 ) { + fputs( "Not an LDAP URL", stderr ); /* Should be smarter? */ + return( NULL ); } + s = ldapdesturl + 7; if ( (s2 = strchr( s, '/' )) == NULL ) { ldapbase = strdup( s ); } else { diff --git a/servers/slurpd/Makefile.in b/servers/slurpd/Makefile.in new file mode 100644 index 0000000000..4e1316f192 --- /dev/null +++ b/servers/slurpd/Makefile.in @@ -0,0 +1,38 @@ +## +## Makefile.in for slurpd +## + +PROGRAMS = slurpd +SRCS = admin.c args.c ch_malloc.c config.c \ + fm.c globals.c ldap_op.c lock.c main.c re.c \ + reject.c replica.c replog.c ri.c rq.c sanity.c st.c \ + tsleep.c +OBJS = admin.o args.o ch_malloc.o config.o \ + fm.o globals.o ldap_op.o lock.o main.o re.o \ + reject.o replica.o replog.o ri.o rq.o sanity.o st.o \ + tsleep.o + +LDAP_INCDIR= ../../include +LDAP_LIBDIR= ../../libraries + +BUILD_OPT = "--enable-slurpd" +BUILD_SRV = @BUILD_SLURPD@ + +all-local: slurpd + +XLIBS = @SLURPD_LIBS@ -llthread @LTHREAD_LIBS@ -llutil @LUTIL_LIBS@ + +slurpd: version.o + $(CC) $(LDFLAGS) -o $@ $(OBJS) version.o $(LIBS) + +version.c: $(OBJS) $(LDAP_LIBDEPEND) + $(RM) $@ + (u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \ + t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < $(srcdir)/Version.c > $@) + +install-local: FORCE + @-$(MKDIR) -p $(libexecdir) + $(INSTALL) $(INSTALLFLAGS) -m 755 slurpd $(libexecdir) diff --git a/servers/slurpd/globals.h b/servers/slurpd/globals.h index 5d976ff8a4..211c829ecd 100644 --- a/servers/slurpd/globals.h +++ b/servers/slurpd/globals.h @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#ifndef SLURPD_GLOBALS_H +#define SLURPD_GLOBALS_H 1 /* * globals.h - definition of structure holding global data. @@ -17,6 +19,8 @@ #include "slurp.h" +LDAP_BEGIN_DECL + typedef struct globals { /* Thread ID for file manager thread */ pthread_t fm_tid; @@ -50,11 +54,11 @@ typedef struct globals { St *st; /* Pointer to replication queue */ Rq *rq; -#ifdef KERBEROS +#ifdef HAVE_KERBEROS /* Default name of kerberos srvtab file */ char *default_srvtab; -#endif /* KERBEROS */ -#if defined( THREAD_SUNOS4_LWP ) +#endif /* HAVE_KERBEROS */ +#if defined( HAVE_LWP ) && !defined( HAVE_THR ) tl_t *tsl_list; mon_t tsl_mon; #endif /* THREAD_SUNOS4_LWP */ @@ -62,3 +66,7 @@ typedef struct globals { extern Globals *sglob; + +LDAP_END_DECL + +#endif /* SLURPD_GLOBALS_H */ diff --git a/servers/slurpd/main.c b/servers/slurpd/main.c index a3b935faa5..061aefa080 100644 --- a/servers/slurpd/main.c +++ b/servers/slurpd/main.c @@ -15,10 +15,13 @@ * main.c - main routine for slurpd. */ +#include "portable.h" + #include #include "slurp.h" #include "globals.h" +#include "lutil.h" extern int doargs( int, char **, Globals * ); @@ -26,9 +29,10 @@ extern void fm(); extern int start_replica_thread( Ri * ); extern Globals *init_globals(); extern int sanity(); -#if defined( THREAD_SUNOS4_LWP ) + +#if defined( HAVE_LWP ) extern void start_lwp_scheduler(); -#endif /* THREAD_SUNOS4_LWP */ +#endif /* HAVE_LWP */ main( int argc, @@ -39,11 +43,11 @@ main( int status; int i; -#ifndef _THREAD +#ifdef NO_THREADS /* Haven't yet written the non-threaded version */ fprintf( stderr, "slurpd currently requires threads support\n" ); exit( 1 ); -#endif /* !_THREAD */ +#else /* * Create and initialize globals. init_globals() also initializes @@ -93,21 +97,18 @@ main( * and if not in one-shot mode. */ #ifdef LDAP_DEBUG - if (( ldap_debug == 0 ) && !sglob->one_shot_mode ) { + if (( ldap_debug == 0 ) && !sglob->one_shot_mode ) #else /* LDAP_DEBUG */ - if ( !sglob->one_shot_mode ) { + if ( !sglob->one_shot_mode ) #endif /* LDAP_DEBUG */ - detach(); - } + lutil_detach( 0, 0 ); -#ifdef _THREAD - -#if defined( THREAD_SUNOS4_LWP ) +#if defined( HAVE_LWP ) /* * Need to start a scheduler thread under SunOS 4 */ start_lwp_scheduler(); -#endif /* THREAD_SUNOS4_LWP */ +#endif /* HAVE_LWP */ /* @@ -121,35 +122,54 @@ main( * Start the main file manager thread (in fm.c). */ pthread_attr_init( &attr ); - if ( pthread_create( &(sglob->fm_tid), attr, (void *) fm, (void *) NULL ) + +#if !defined(HAVE_PTHREADS_D4) && !defined(HAVE_DCE) + /* POSIX_THREADS or compatible + * This is a draft 10 or standard pthreads implementation + */ + if ( pthread_create( &(sglob->fm_tid), &attr, fm, (void *) NULL ) + != 0 ) { + Debug( LDAP_DEBUG_ANY, "file manager pthread_create failed\n", + 0, 0, 0 ); + exit( 1 ); + + } +#else /* !PTHREADS_FINAL */ + /* + * This is a draft 4 or earlier pthreads implementation + */ + if ( pthread_create( &(sglob->fm_tid), attr, fm, (void *) NULL ) != 0 ) { Debug( LDAP_DEBUG_ANY, "file manager pthread_create failed\n", 0, 0, 0 ); exit( 1 ); } +#endif /* !PTHREADS_FINAL */ + pthread_attr_destroy( &attr ); /* * Wait for the fm thread to finish. */ +#ifdef HAVE_PTHREADS_FINAL + pthread_join( sglob->fm_tid, (void *) NULL ); +#else pthread_join( sglob->fm_tid, (void *) &status ); +#endif /* * Wait for the replica threads to finish. */ for ( i = 0; sglob->replicas[ i ] != NULL; i++ ) { +#ifdef HAVE_PTHREADS_FINAL + pthread_join( sglob->replicas[ i ]->ri_tid, (void *) NULL ); +#else pthread_join( sglob->replicas[ i ]->ri_tid, (void *) &status ); +#endif } Debug( LDAP_DEBUG_ANY, "slurpd: terminating normally\n", 0, 0, 0 ); sglob->slurpd_shutdown = 1; pthread_exit( 0 ); -#else /* !_THREAD */ - /* - * Non-threaded case. - */ - exit( 0 ); - -#endif /* !_THREAD */ - +#endif /* !NO_THREADS */ }