From b76c56ba3f45576b9c418ea9fe7f7b3440052904 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 21 Oct 1998 01:24:26 +0000 Subject: [PATCH] include portable.h --- acconfig.h | 3 + aclocal.m4 | 34 +++- configure | 157 ++++++----------- configure.in | 2 +- include/portable.h.in | 5 +- servers/slapd/abandon.c | 6 +- servers/slapd/acl.c | 2 + servers/slapd/aclparse.c | 134 ++++++++++---- servers/slapd/add.c | 2 + servers/slapd/attr.c | 2 + servers/slapd/ava.c | 2 + servers/slapd/back-ldbm/abandon.c | 2 + servers/slapd/back-ldbm/add.c | 2 + servers/slapd/back-ldbm/attr.c | 2 + servers/slapd/back-ldbm/back-ldbm.h | 15 +- servers/slapd/back-ldbm/bind.c | 2 + servers/slapd/back-ldbm/cache.c | 2 + servers/slapd/back-ldbm/close.c | 2 + servers/slapd/back-ldbm/compare.c | 2 + servers/slapd/back-ldbm/config.c | 6 + servers/slapd/back-ldbm/dbcache.c | 1 - servers/slapd/back-ldbm/delete.c | 2 + servers/slapd/back-ldbm/dn2id.c | 2 + servers/slapd/back-ldbm/filterindex.c | 2 + servers/slapd/back-ldbm/group.c | 2 + servers/slapd/back-ldbm/id2children.c | 11 ++ servers/slapd/back-ldbm/id2entry.c | 2 + servers/slapd/back-ldbm/idl.c | 1 - servers/slapd/back-ldbm/index.c | 33 ++-- servers/slapd/back-ldbm/init.c | 9 + servers/slapd/back-ldbm/kerberos.c | 2 + servers/slapd/back-ldbm/modify.c | 2 + servers/slapd/back-ldbm/modrdn.c | 2 + servers/slapd/back-ldbm/nextid.c | 2 + servers/slapd/back-ldbm/proto-back-ldbm.h | 109 ++++++------ servers/slapd/back-ldbm/search.c | 2 + servers/slapd/back-ldbm/unbind.c | 2 + servers/slapd/back-passwd/config.c | 2 + servers/slapd/back-passwd/search.c | 2 + servers/slapd/back-shell/abandon.c | 2 + servers/slapd/back-shell/add.c | 2 + servers/slapd/back-shell/bind.c | 2 + servers/slapd/back-shell/compare.c | 2 + servers/slapd/back-shell/config.c | 2 + servers/slapd/back-shell/delete.c | 2 + servers/slapd/back-shell/fork.c | 2 + servers/slapd/back-shell/init.c | 2 + servers/slapd/back-shell/modify.c | 2 + servers/slapd/back-shell/modrdn.c | 2 + servers/slapd/back-shell/result.c | 2 + servers/slapd/back-shell/search.c | 2 + servers/slapd/back-shell/shell.h | 11 ++ servers/slapd/back-shell/unbind.c | 2 + servers/slapd/backend.c | 38 +++- servers/slapd/bind.c | 2 + servers/slapd/ch_malloc.c | 2 + servers/slapd/charray.c | 6 + servers/slapd/compare.c | 2 + servers/slapd/config.c | 2 + servers/slapd/configinfo.c | 2 + servers/slapd/connection.c | 1 - servers/slapd/daemon.c | 1 - servers/slapd/delete.c | 2 + servers/slapd/detach.c | 8 + servers/slapd/dn.c | 5 +- servers/slapd/entry.c | 2 + servers/slapd/filter.c | 5 + servers/slapd/filterentry.c | 55 ++---- servers/slapd/init.c | 8 +- servers/slapd/lock.c | 2 + servers/slapd/main.c | 39 +++-- servers/slapd/modify.c | 2 + servers/slapd/modrdn.c | 2 + servers/slapd/monitor.c | 2 + servers/slapd/operation.c | 2 + servers/slapd/phonetic.c | 2 + servers/slapd/proto-slap.h | 182 ++++++++++---------- servers/slapd/repl.c | 2 + servers/slapd/result.c | 1 - servers/slapd/schema.c | 13 +- servers/slapd/schemaparse.c | 2 + servers/slapd/search.c | 2 + servers/slapd/shell-backends/passwd-shell.c | 2 + servers/slapd/shell-backends/shellutil.c | 2 + servers/slapd/shell-backends/shellutil.h | 9 + servers/slapd/slap.h | 21 ++- servers/slapd/str2filter.c | 2 + servers/slapd/strdup.c | 3 +- servers/slapd/tempnam.c | 2 + servers/slapd/tools/centipede.c | 64 ++++++- servers/slapd/tools/chlog2replog.c | 2 + servers/slapd/tools/edb2ldif.c | 2 + servers/slapd/tools/ldapsyntax.c | 2 + servers/slapd/tools/ldapsyntax.h | 16 +- servers/slapd/tools/ldbmcat.c | 15 +- servers/slapd/tools/ldbmtest.c | 1 - servers/slapd/tools/ldif.c | 8 +- servers/slapd/tools/ldif2id2children.c | 2 + servers/slapd/tools/ldif2id2entry.c | 2 + servers/slapd/tools/ldif2index.c | 9 +- servers/slapd/tools/ldif2ldbm.c | 34 ++-- servers/slapd/tools/sizecount.c | 2 + servers/slapd/unbind.c | 2 + servers/slapd/value.c | 1 + servers/slurpd/admin.c | 1 + servers/slurpd/args.c | 3 + servers/slurpd/ch_malloc.c | 2 + servers/slurpd/config.c | 2 + servers/slurpd/detach.c | 8 + servers/slurpd/fm.c | 1 - servers/slurpd/globals.c | 2 + servers/slurpd/globals.h | 14 +- servers/slurpd/ldap_op.c | 1 - servers/slurpd/lock.c | 2 + servers/slurpd/main.c | 26 +++ servers/slurpd/re.c | 1 - servers/slurpd/reject.c | 1 - servers/slurpd/replica.c | 20 +++ servers/slurpd/replog.c | 2 - servers/slurpd/ri.c | 13 +- servers/slurpd/rq.c | 1 - servers/slurpd/sanity.c | 2 + servers/slurpd/slurp.h | 18 +- servers/slurpd/st.c | 1 - servers/slurpd/tsleep.c | 1 + 125 files changed, 898 insertions(+), 432 deletions(-) diff --git a/acconfig.h b/acconfig.h index 545db86416..ec41bf6bd8 100644 --- a/acconfig.h +++ b/acconfig.h @@ -5,6 +5,9 @@ Leave the following blank line there!! Autoheader needs it. */ +/* define this if toupper() requires tolower() check */ +#undef C_UPPER_LOWER + /* define this if sys_errlist is not defined in stdio.h or errno.h */ #undef DECL_SYS_ERRLIST diff --git a/aclocal.m4 b/aclocal.m4 index 1df969aa99..b6e6ca9700 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -113,7 +113,7 @@ AC_DEFUN([OL_BERKELEY_DB2], fi ]) if test $ol_cv_berkeley_db2 = yes ; then - AC_DEFINE(HAVE_BERKELEY_DB2) + AC_DEFINE(HAVE_BERKELEY_DB2,1) fi ])dnl dnl @@ -179,7 +179,7 @@ AC_DEFUN([OL_BERKELEY_DB], fi ]) if test $ol_cv_berkeley_db = yes ; then - AC_DEFINE(HAVE_BERKELEY_DB) + AC_DEFINE(HAVE_BERKELEY_DB,1) fi ])dnl dnl @@ -224,7 +224,7 @@ AC_DEFUN([OL_GDBM], fi ]) if test $ol_cv_gdbm = yes ; then - AC_DEFINE(HAVE_GDBM) + AC_DEFINE(HAVE_GDBM,1) fi ])dnl dnl @@ -280,7 +280,7 @@ AC_DEFUN([OL_NDBM], fi ]) if test $ol_cv_ndbm = yes ; then - AC_DEFINE(HAVE_NDBM) + AC_DEFINE(HAVE_NDBM,1) fi ])dnl dnl @@ -340,6 +340,30 @@ AC_CACHE_CHECK([for LinuxThreads], [ol_cv_linux_threads], [ ]) ])dnl dnl +dnl ==================================================================== +dnl Check if toupper() requires islower() to be called first +AC_DEFUN([OL_C_UPPER_LOWER], +[ +AC_MSG_CHECKING([if toupper() requires islower()]) +AC_CACHE_VAL(ol_cv_c_upper_lower,[ + AC_TRY_RUN([ +#include +main() +{ + if ('C' == toupper('C')) + exit 0; + else + exit 1; +}], + [ol_cv_c_upper_lower=no], + [ol_cv_c_upper_lower=yes], + [ol_cv_c_upper_lower=safe])]) +AC_MSG_RESULT($ol_cv_c_upper_lower) +if test $ol_cv_c_upper_lower != no ; then + AC_DEFINE(C_UPPER_LOWER,1) +fi +]) + dnl ==================================================================== dnl Check for declaration of sys_errlist in one of stdio.h and errno.h. dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration. @@ -359,7 +383,7 @@ AC_MSG_RESULT($ol_cv_dcl_sys_errlist) # It's possible (for near-UNIX clones) that sys_errlist doesn't exist if test $ol_cv_dcl_sys_errlist = no ; then - AC_DEFINE(DECL_SYS_ERRLIST) + AC_DEFINE(DECL_SYS_ERRLIST,1) AC_MSG_CHECKING([existence of sys_errlist]) AC_CACHE_VAL(ol_cv_have_sys_errlist,[ AC_TRY_LINK([#include ], diff --git a/configure b/configure index 2cd35bfb9a..516047020c 100755 --- a/configure +++ b/configure @@ -5430,103 +5430,58 @@ EOF fi -echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:5435: checking whether byte ordering is bigendian" >&5 -if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then + +echo $ac_n "checking if toupper() requires islower()""... $ac_c" 1>&6 +echo "configure:5436: 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 - ac_cv_c_bigendian=unknown -# See if sys/param.h defines the BYTE_ORDER macro. -cat > conftest.$ac_ext < -#include -int main() { - -#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN - bogus endian macros -#endif -; return 0; } -EOF -if { (eval echo configure:5453: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - # It does; now see whether it defined to BIG_ENDIAN or not. -cat > conftest.$ac_ext < -#include -int main() { - -#if BYTE_ORDER != BIG_ENDIAN - not big endian -#endif -; return 0; } -EOF -if { (eval echo configure:5468: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_c_bigendian=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_c_bigendian=no -fi -rm -f conftest* -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -if test $ac_cv_c_bigendian = unknown; then -if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } + + if test "$cross_compiling" = yes; then + ol_cv_c_upper_lower=safe else cat > conftest.$ac_ext < +main() +{ + if ('C' == toupper('C')) + exit 0; + else + exit 1; } EOF -if { (eval echo configure:5501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5457: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then - ac_cv_c_bigendian=no + ol_cv_c_upper_lower=no else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* - ac_cv_c_bigendian=yes + ol_cv_c_upper_lower=yes fi rm -fr conftest* fi -fi fi -echo "$ac_t""$ac_cv_c_bigendian" 1>&6 -if test $ac_cv_c_bigendian = yes; then - cat >> confdefs.h <<\EOF -#define WORDS_BIGENDIAN 1 +echo "$ac_t""$ol_cv_c_upper_lower" 1>&6 +if test $ol_cv_c_upper_lower != no ; then + cat >> confdefs.h <<\EOF +#define C_UPPER_LOWER 1 EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:5525: checking for working const" >&5 +echo "configure:5480: 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:5534: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -5598,7 +5553,7 @@ fi echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 -echo "configure:5602: checking for 8-bit clean memcmp" >&5 +echo "configure:5557: 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 @@ -5606,7 +5561,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:5575: \"$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 @@ -5634,12 +5589,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:5638: checking for strftime" >&5 +echo "configure:5593: 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:5621: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_strftime=yes" else @@ -5684,7 +5639,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:5688: checking for strftime in -lintl" >&5 +echo "configure:5643: 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 @@ -5692,7 +5647,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:5662: \"$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 @@ -5730,12 +5685,12 @@ fi fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:5734: checking for vprintf" >&5 +echo "configure:5689: 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:5717: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -5782,12 +5737,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:5786: checking for _doprnt" >&5 +echo "configure:5741: 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:5769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -5835,7 +5790,7 @@ fi fi echo $ac_n "checking for wait3 that fills in rusage""... $ac_c" 1>&6 -echo "configure:5839: checking for wait3 that fills in rusage" >&5 +echo "configure:5794: 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 @@ -5843,7 +5798,7 @@ else ac_cv_func_wait3_rusage=no else cat > conftest.$ac_ext < #include @@ -5874,7 +5829,7 @@ main() { } } EOF -if { (eval echo configure:5878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5833: \"$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 @@ -5926,12 +5881,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5930: checking for $ac_func" >&5 +echo "configure:5885: 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:5913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5982,12 +5937,12 @@ done for ac_func in getopt strdup do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5986: checking for $ac_func" >&5 +echo "configure:5941: 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:5969: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6040,13 +5995,13 @@ done # Check Configuration echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6 -echo "configure:6044: checking declaration of sys_errlist" >&5 +echo "configure:5999: 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 < @@ -6056,7 +6011,7 @@ int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:6060: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6015: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_dcl_sys_errlist=yes else @@ -6077,20 +6032,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:6081: checking existence of sys_errlist" >&5 +echo "configure:6036: 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:6094: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6049: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ol_cv_have_sys_errlist=yes else diff --git a/configure.in b/configure.in index 725008a5e8..e112c59a52 100644 --- a/configure.in +++ b/configure.in @@ -716,7 +716,7 @@ AC_STRUCT_ST_BLKSIZE AC_HEADER_TIME AC_STRUCT_TM -AC_C_BIGENDIAN +OL_C_UPPER_LOWER AC_C_CONST dnl AC_CHECK_SIZEOF(short) diff --git a/include/portable.h.in b/include/portable.h.in index 67a861f055..3b8fd80dac 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -104,9 +104,8 @@ is provided ``as is'' without express or implied warranty. /* Define to `int' if doesn't define. */ #undef uid_t -/* Define if your processor stores words with the most significant - byte first (like Motorola and SPARC, unlike Intel and VAX). */ -#undef WORDS_BIGENDIAN +/* define this if toupper() requires tolower() check */ +#undef C_UPPER_LOWER /* define this if sys_errlist is not defined in stdio.h or errno.h */ #undef DECL_SYS_ERRLIST diff --git a/servers/slapd/abandon.c b/servers/slapd/abandon.c index d6f7291c78..fb9d1be4b2 100644 --- a/servers/slapd/abandon.c +++ b/servers/slapd/abandon.c @@ -12,9 +12,11 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include -#include -#include +#include + #include "slap.h" extern Backend *select_backend(); diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index a5fd38abbd..1098553319 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -1,5 +1,7 @@ /* acl.c - routines to parse and check acl's */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 10fa6a0721..a8ba951089 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -1,5 +1,6 @@ /* acl.c - routines to parse and check acl's */ +#include "portable.h" #include #include @@ -7,12 +8,13 @@ #include #include #include -#include "regex.h" +#include +#include + #include "slap.h" #include "portable.h" extern Filter *str2filter(); -extern char *re_comp(); extern struct acl *global_acl; extern char **str2charray(); extern char *dn_upcase(); @@ -26,6 +28,62 @@ static void print_acl(); static void print_access(); #endif +int +regtest(char *fname, int lineno, char *pat) { + int e; + regex_t re; + + char buf[512]; + int size; + + char *sp; + char *dp; + int flag; + + sp = pat; + dp = buf; + size = 0; + buf[0] = '\0'; + + for (size = 0, flag = 0; (size < sizeof(buf)) && *sp; sp++) { + if (flag) { + if (*sp == '$'|| (*sp >= '0' && *sp <= '9')) { + *dp++ = *sp; + size++; + } + flag = 0; + + } else { + if (*sp == '$') { + flag = 1; + } else { + *dp++ = *sp; + size++; + } + } + } + + *dp = '\0'; + if ( size >= (sizeof(buf)-1) ) { + fprintf( stderr, + "%s: line %d: regular expression \"%s\" too large\n", + fname, lineno, pat, 0 ); + acl_usage(); + } + + if ((e = regcomp(&re, buf, REG_EXTENDED|REG_ICASE))) { + char error[512]; + regerror(e, &re, error, sizeof(error)); + fprintf( stderr, + "%s: line %d: regular expression \"%s\" bad because of %s\n", + fname, lineno, pat, error ); + acl_usage(); + return(0); + } + regfree(&re); + return(1); +} + void parse_acl( Backend *be, @@ -58,6 +116,17 @@ parse_acl( } if ( strcasecmp( argv[i], "*" ) == 0 ) { + int e; + if ((e = regcomp( &a->acl_dnre, ".*", + REG_EXTENDED|REG_ICASE))) + { + char buf[512]; + regerror(e, &a->acl_dnre, buf, sizeof(buf)); + fprintf( stderr, + "%s: line %d: regular expression \"%s\" bad because of %s\n", + fname, lineno, right, buf ); + acl_usage(); + } a->acl_dnpat = strdup( ".*" ); continue; } @@ -79,14 +148,19 @@ parse_acl( acl_usage(); } } else if ( strcasecmp( left, "dn" ) == 0 ) { - if ( (e = re_comp( right )) != NULL ) { + int e; + if ((e = regcomp(&a->acl_dnre, right, + REG_EXTENDED|REG_ICASE))) { + char buf[512]; + regerror(e, &a->acl_dnre, buf, sizeof(buf)); fprintf( stderr, - "%s: line %d: regular expression \"%s\" bad because of %s\n", - fname, lineno, right, e ); + "%s: line %d: regular expression \"%s\" bad because of %s\n", + fname, lineno, right, buf ); acl_usage(); + + } else { + a->acl_dnpat = dn_upcase(strdup( right )); } - a->acl_dnpat = dn_upcase( strdup( - right ) ); } else if ( strncasecmp( left, "attr", 4 ) == 0 ) { char **alist; @@ -96,7 +170,7 @@ parse_acl( free( alist ); } else { fprintf( stderr, - "%s: line %d: expecting got \"%s\"\n", + "%s: line %d: expecting got \"%s\"\n", fname, lineno, left ); acl_usage(); } @@ -106,7 +180,7 @@ parse_acl( } else if ( strcasecmp( argv[i], "by" ) == 0 ) { if ( a == NULL ) { fprintf( stderr, - "%s: line %d: to clause required before by clause in access line\n", + "%s: line %d: to clause required before by clause in access line\n", fname, lineno ); acl_usage(); } @@ -131,38 +205,27 @@ parse_acl( } else if ( strcasecmp( argv[i], "self" ) == 0 ) { b->a_dnpat = strdup( "self" ); } else if ( strcasecmp( left, "dn" ) == 0 ) { - if ( (e = re_comp( right )) != NULL ) { - fprintf( stderr, - "%s: line %d: regular expression \"%s\" bad: %s\n", - fname, lineno, right, e ); - acl_usage(); - } + regtest(fname, lineno, right); b->a_dnpat = dn_upcase( strdup( right ) ); - } else if ( strcasecmp( left, "dnattr" ) - == 0 ) { + } else if ( strcasecmp( left, "dnattr" ) == 0 ) { b->a_dnattr = strdup( right ); - } else if ( strcasecmp( left, "domain" ) - == 0 ) { - char *s; - if ( (e = re_comp( right )) != NULL ) { - fprintf( stderr, - "%s: line %d: regular expression \"%s\" bad: %s\n", - fname, lineno, right, e ); - acl_usage(); - } +#ifdef ACLGROUP + } else if ( strcasecmp( left, "group" ) == 0 ) { + regtest(fname, lineno, right); + b->a_group = dn_upcase(strdup( right )); +#endif /* ACLGROUP */ + } else if ( strcasecmp( left, "domain" ) == 0 ) { + char *s; + regtest(fname, lineno, right); b->a_domainpat = strdup( right ); + /* normalize the domain */ for ( s = b->a_domainpat; *s; s++ ) { *s = TOLOWER( *s ); } } else if ( strcasecmp( left, "addr" ) == 0 ) { - if ( (e = re_comp( right )) != NULL ) { - fprintf( stderr, - "%s: line %d: regular expression \"%s\" bad: %s\n", - fname, lineno, right, e ); - acl_usage(); - } + regtest(fname, lineno, right); b->a_addrpat = strdup( right ); } else { fprintf( stderr, @@ -198,16 +261,15 @@ parse_acl( /* if we have no real access clause, complain and do nothing */ if ( a == NULL ) { - fprintf( stderr, - "%s: line %d: warning: no access clause(s) specified in access line\n", + "%s: line %d: warning: no access clause(s) specified in access line\n", fname, lineno ); } else { if ( a->acl_access == NULL ) { fprintf( stderr, - "%s: line %d: warning: no by clause(s) specified in access line\n", + "%s: line %d: warning: no by clause(s) specified in access line\n", fname, lineno ); } @@ -373,4 +435,4 @@ print_acl( struct acl *a ) } } -#endif +#endif /* LDAP_DEBUG */ diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 93cc3cdcd3..feecf522b5 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index fb9add64bc..5842813b96 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -1,5 +1,7 @@ /* attr.c - routines for dealing with attributes */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/ava.c b/servers/slapd/ava.c index ef0487c7aa..12ef18cbf4 100644 --- a/servers/slapd/ava.c +++ b/servers/slapd/ava.c @@ -1,5 +1,7 @@ /* ava.c - routines for dealing with attribute value assertions */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/abandon.c b/servers/slapd/back-ldbm/abandon.c index 8ed2dfd5cb..8f1ca0e040 100644 --- a/servers/slapd/back-ldbm/abandon.c +++ b/servers/slapd/back-ldbm/abandon.c @@ -1,5 +1,7 @@ /* abandon.c - ldbm backend abandon routine */ +#include "portable.h" + ldbm_back_abandon() { } diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 797398ad4b..37b6a40635 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -1,5 +1,7 @@ /* add.c - ldap ldbm back-end add routine */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/attr.c b/servers/slapd/back-ldbm/attr.c index dfe72f6e2f..ca59ba3090 100644 --- a/servers/slapd/back-ldbm/attr.c +++ b/servers/slapd/back-ldbm/attr.c @@ -1,5 +1,7 @@ /* attr.c - backend routines for dealing with attributes */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/back-ldbm.h b/servers/slapd/back-ldbm/back-ldbm.h index 2824330190..3d656f4dd9 100644 --- a/servers/slapd/back-ldbm/back-ldbm.h +++ b/servers/slapd/back-ldbm/back-ldbm.h @@ -5,8 +5,16 @@ #include "ldbm.h" +LDAP_BEGIN_DECL + #define DEFAULT_CACHE_SIZE 1000 -#define DEFAULT_DBCACHE_SIZE 100000 + +#ifdef LDBM_USE_DB2 +# define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE) +#else +# define DEFAULT_DBCACHE_SIZE 100000 +#endif + #define DEFAULT_DB_DIRECTORY "/usr/tmp" #define DEFAULT_MODE 0600 @@ -102,13 +110,14 @@ struct ldbminfo { struct cache li_cache; Avlnode *li_attrs; int li_dbcachesize; + int li_flush_wrt; struct dbcache li_dbcache[MAXDBCACHE]; pthread_mutex_t li_dbcache_mutex; pthread_cond_t li_dbcache_cv; }; -#ifdef NEEDPROTOS #include "proto-back-ldbm.h" -#endif + +LDAP_END_DECL #endif /* _back_ldbm_h_ */ diff --git a/servers/slapd/back-ldbm/bind.c b/servers/slapd/back-ldbm/bind.c index 66dfddbceb..90aa228f08 100644 --- a/servers/slapd/back-ldbm/bind.c +++ b/servers/slapd/back-ldbm/bind.c @@ -1,5 +1,7 @@ /* bind.c - ldbm backend bind and unbind routines */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/cache.c b/servers/slapd/back-ldbm/cache.c index 819b1f2712..4c5e7c3203 100644 --- a/servers/slapd/back-ldbm/cache.c +++ b/servers/slapd/back-ldbm/cache.c @@ -1,5 +1,7 @@ /* cache.c - routines to maintain an in-core cache of entries */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/close.c b/servers/slapd/back-ldbm/close.c index d6758e143b..66ef3e8606 100644 --- a/servers/slapd/back-ldbm/close.c +++ b/servers/slapd/back-ldbm/close.c @@ -1,5 +1,7 @@ /* close.c - close ldbm backend */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c index b0974ffdbb..714923e177 100644 --- a/servers/slapd/back-ldbm/compare.c +++ b/servers/slapd/back-ldbm/compare.c @@ -1,5 +1,7 @@ /* compare.c - ldbm backend compare routine */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/config.c b/servers/slapd/back-ldbm/config.c index d6aca2c413..5cbfd6e924 100644 --- a/servers/slapd/back-ldbm/config.c +++ b/servers/slapd/back-ldbm/config.c @@ -1,5 +1,7 @@ /* config.c - ldbm backend configuration file routine */ +#include "portable.h" + #include #include #include @@ -77,6 +79,10 @@ ldbm_back_config( } li->li_dbcachesize = atoi( argv[1] ); + /* flush on writes */ + } else if ( strcasecmp( argv[0], "flushwrites" ) == 0 ) { + li->li_flush_wrt = 1; + /* anything else */ } else { fprintf( stderr, diff --git a/servers/slapd/back-ldbm/dbcache.c b/servers/slapd/back-ldbm/dbcache.c index 269e3d152c..bef299be86 100644 --- a/servers/slapd/back-ldbm/dbcache.c +++ b/servers/slapd/back-ldbm/dbcache.c @@ -1,6 +1,5 @@ /* ldbmcache.c - maintain a cache of open ldbm files */ -#define DISABLE_BRIDGE /* disable LDAP_BRIDGE code */ #include "portable.h" #include diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index b6ffa79e0e..ee5fbabca6 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -1,5 +1,7 @@ /* delete.c - ldbm backend delete routine */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index 0a7edac280..89a5ea13ea 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -1,5 +1,7 @@ /* dn2id.c - routines to deal with the dn2id index */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/filterindex.c b/servers/slapd/back-ldbm/filterindex.c index 55aada54e4..b65b841e24 100644 --- a/servers/slapd/back-ldbm/filterindex.c +++ b/servers/slapd/back-ldbm/filterindex.c @@ -1,5 +1,7 @@ /* filterindex.c - generate the list of candidate entries from a filter */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/group.c b/servers/slapd/back-ldbm/group.c index 8ada479ea4..e3e3436ceb 100644 --- a/servers/slapd/back-ldbm/group.c +++ b/servers/slapd/back-ldbm/group.c @@ -1,5 +1,7 @@ /* compare.c - ldbm backend compare routine */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/id2children.c b/servers/slapd/back-ldbm/id2children.c index 3b2c55d202..2906c5b2cb 100644 --- a/servers/slapd/back-ldbm/id2children.c +++ b/servers/slapd/back-ldbm/id2children.c @@ -1,5 +1,7 @@ /* id2children.c - routines to deal with the id2children index */ +#include "portable.h" + #include #include #include @@ -23,6 +25,11 @@ id2children_add( IDList *idl; char buf[20]; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); + memset( &data, 0, sizeof( data ) ); +#endif + Debug( LDAP_DEBUG_TRACE, "=> id2children_add( %d, %d )\n", p ? p->e_id : 0, e->e_id, 0 ); @@ -63,6 +70,10 @@ has_children( IDList *idl; char buf[20]; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); +#endif + Debug( LDAP_DEBUG_TRACE, "=> has_children( %d )\n", p->e_id , 0, 0 ); if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX, diff --git a/servers/slapd/back-ldbm/id2entry.c b/servers/slapd/back-ldbm/id2entry.c index 38522cb54a..140555c0c3 100644 --- a/servers/slapd/back-ldbm/id2entry.c +++ b/servers/slapd/back-ldbm/id2entry.c @@ -1,5 +1,7 @@ /* id2entry.c - routines to deal with the id2entry index */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/idl.c b/servers/slapd/back-ldbm/idl.c index d00b025d52..d68c7b834b 100644 --- a/servers/slapd/back-ldbm/idl.c +++ b/servers/slapd/back-ldbm/idl.c @@ -1,6 +1,5 @@ /* idl.c - ldap id list handling routines */ -#define DISABLE_BRIDGE #include "portable.h" #include diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index 3d75a091d3..1e58ab8c91 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -1,5 +1,7 @@ /* index.c - routines for dealing with attribute indexes */ +#include "portable.h" + #include #include #include @@ -105,6 +107,10 @@ index_read( char *realval, *tmpval; char buf[BUFSIZ]; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); +#endif + prefix = index2prefix( indextype ); Debug( LDAP_DEBUG_TRACE, "=> index_read( \"%s\" \"%c\" \"%s\" )\n", type, prefix, val ); @@ -130,25 +136,26 @@ index_read( realval = val; tmpval = NULL; if ( prefix != '\0' ) { - int len; + int len = strlen( val ); - if ( (len = strlen( val )) < sizeof(buf) ) { - buf[0] = prefix; - strcpy( &buf[1], val ); + if ( (len + 2) < sizeof(buf) ) { realval = buf; } else { /* value + prefix + null */ tmpval = (char *) ch_malloc( len + 2 ); - tmpval[0] = prefix; - strcat( &tmpval[1], val ); realval = tmpval; } + realval[0] = prefix; + strcpy( &realval[1], val ); } key.dptr = realval; key.dsize = strlen( realval ) + 1; idl = idl_fetch( be, db, key ); + if ( tmpval != NULL ) { + free( tmpval ); + } ldbm_cache_close( be, db ); @@ -174,6 +181,10 @@ add_value( char *realval, *tmpval, *s; char buf[BUFSIZ]; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); +#endif + prefix = index2prefix( indextype ); Debug( LDAP_DEBUG_TRACE, "=> add_value( \"%c%s\" )\n", prefix, val, 0 ); @@ -181,19 +192,17 @@ add_value( tmpval = NULL; idl = NULL; if ( prefix != '\0' ) { - int len; + int len = strlen( val ); - if ( (len = strlen( val )) < sizeof(buf) ) { - buf[0] = prefix; - strcpy( &buf[1], val ); + if ( (len + 2) < sizeof(buf) ) { realval = buf; } else { /* value + prefix + null */ tmpval = (char *) ch_malloc( len + 2 ); - tmpval[0] = prefix; - strcat( &tmpval[1], val ); realval = tmpval; } + realval[0] = prefix; + strcpy( &realval[1], val ); } key.dptr = realval; diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index b9c5c2f3fa..eaf886baf8 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -1,5 +1,7 @@ /* init.c - initialize ldbm backend */ +#include "portable.h" + #include #include #include @@ -15,6 +17,10 @@ ldbm_back_init( char *argv[ 4 ]; int i; +#ifdef LDAP_CRYPT + extern pthread_mutex_t crypt_mutex; +#endif /* LDAP_CRYPT */ + /* allocate backend-specific stuff */ li = (struct ldbminfo *) ch_calloc( 1, sizeof(struct ldbminfo) ); @@ -59,6 +65,9 @@ ldbm_back_init( pthread_mutex_init( &li->li_cache.c_mutex, pthread_mutexattr_default ); pthread_mutex_init( &li->li_nextid_mutex, pthread_mutexattr_default ); pthread_mutex_init( &li->li_dbcache_mutex, pthread_mutexattr_default ); +#ifdef LDAP_CRYPT + pthread_mutex_init( &crypt_mutex, pthread_mutexattr_default ); +#endif /* LDAP_CRYPT */ pthread_cond_init( &li->li_dbcache_cv, pthread_condattr_default ); for ( i = 0; i < MAXDBCACHE; i++ ) { pthread_mutex_init( &li->li_dbcache[i].dbc_mutex, diff --git a/servers/slapd/back-ldbm/kerberos.c b/servers/slapd/back-ldbm/kerberos.c index d07138bed7..c369c2bc13 100644 --- a/servers/slapd/back-ldbm/kerberos.c +++ b/servers/slapd/back-ldbm/kerberos.c @@ -1,5 +1,7 @@ /* kerberos.c - ldbm backend kerberos bind routines */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index df94146736..455dd8c175 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -1,5 +1,7 @@ /* modify.c - ldbm backend modify routine */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 26c96709ae..62a2acd18b 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -1,5 +1,7 @@ /* modrdn.c - ldbm backend modrdn routine */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/nextid.c b/servers/slapd/back-ldbm/nextid.c index e51f4d84e7..b680890a79 100644 --- a/servers/slapd/back-ldbm/nextid.c +++ b/servers/slapd/back-ldbm/nextid.c @@ -1,5 +1,7 @@ /* id.c - keep track of the next id to be given out */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index 1bc9fdd0e1..371e8bf9c2 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -1,112 +1,117 @@ #ifndef _PROTO_BACK_LDBM #define _PROTO_BACK_LDBM +#include + +LDAP_BEGIN_DECL + /* * attr.c */ -void attr_masks( struct ldbminfo *li, char *type, int *indexmask, - int *syntaxmask ); -void attr_index_config( struct ldbminfo *li, char *fname, int lineno, - int argc, char **argv, int init ); +void attr_masks LDAP_P(( struct ldbminfo *li, char *type, int *indexmask, + int *syntaxmask )); +void attr_index_config LDAP_P(( struct ldbminfo *li, char *fname, int lineno, + int argc, char **argv, int init )); /* * cache.c */ -void cache_set_state( struct cache *cache, Entry *e, int state ); -void cache_return_entry_r( struct cache *cache, Entry *e ); -void cache_return_entry_w( struct cache *cache, Entry *e ); -int cache_add_entry_lock( struct cache *cache, Entry *e, int state ); -ID cache_find_entry_dn2id( Backend *be, struct cache *cache, char *dn ); -Entry * cache_find_entry_id( struct cache *cache, ID id, int rw ); -int cache_delete_entry( struct cache *cache, Entry *e ); +void cache_set_state LDAP_P(( struct cache *cache, Entry *e, int state )); +void cache_return_entry_r LDAP_P(( struct cache *cache, Entry *e )); +void cache_return_entry_w LDAP_P(( struct cache *cache, Entry *e )); +int cache_add_entry_lock LDAP_P(( struct cache *cache, Entry *e, int state )); +ID cache_find_entry_dn2id LDAP_P(( Backend *be, struct cache *cache, char *dn )); +Entry * cache_find_entry_id LDAP_P(( struct cache *cache, ID id, int rw )); +int cache_delete_entry LDAP_P(( struct cache *cache, Entry *e )); /* * dbcache.c */ -struct dbcache * ldbm_cache_open( Backend *be, char *name, char *suffix, - int flags ); -void ldbm_cache_close( Backend *be, struct dbcache *db ); -void ldbm_cache_flush_all( Backend *be ); -Datum ldbm_cache_fetch( struct dbcache *db, Datum key ); -int ldbm_cache_store( struct dbcache *db, Datum key, Datum data, int flags ); -int ldbm_cache_delete( struct dbcache *db, Datum key ); +struct dbcache * ldbm_cache_open LDAP_P(( Backend *be, char *name, char *suffix, + int flags )); +void ldbm_cache_close LDAP_P(( Backend *be, struct dbcache *db )); +void ldbm_cache_flush_all LDAP_P(( Backend *be )); +Datum ldbm_cache_fetch LDAP_P(( struct dbcache *db, Datum key )); +int ldbm_cache_store LDAP_P(( struct dbcache *db, Datum key, Datum data, int flags )); +int ldbm_cache_delete LDAP_P(( struct dbcache *db, Datum key )); /* * dn2id.c */ -int dn2id_add( Backend *be, char *dn, ID id ); -ID dn2id( Backend *be, char *dn ); -int dn2id_delete( Backend *be, char *dn ); -/*Entry * dn2entry( Backend *be, char *dn, char **matched );*/ -Entry * dn2entry_r( Backend *be, char *dn, char **matched ); -Entry * dn2entry_w( Backend *be, char *dn, char **matched ); +int dn2id_add LDAP_P(( Backend *be, char *dn, ID id )); +ID dn2id LDAP_P(( Backend *be, char *dn )); +int dn2id_delete LDAP_P(( Backend *be, char *dn )); +/*Entry * dn2entry LDAP_P(( Backend *be, char *dn, char **matched ));*/ +Entry * dn2entry_r LDAP_P(( Backend *be, char *dn, char **matched )); +Entry * dn2entry_w LDAP_P(( Backend *be, char *dn, char **matched )); /* * filterindex.c */ -IDList * filter_candidates( Backend *be, Filter *f ); +IDList * filter_candidates LDAP_P(( Backend *be, Filter *f )); /* * id2children.c */ -int id2children_add( Backend *be, Entry *p, Entry *e ); -int has_children( Backend *be, Entry *p ); +int id2children_add LDAP_P(( Backend *be, Entry *p, Entry *e )); +int has_children LDAP_P(( Backend *be, Entry *p )); /* * id2entry.c */ -int id2entry_add( Backend *be, Entry *e ); -int id2entry_delete( Backend *be, Entry *e ); -Entry * id2entry( Backend *be, ID id, int rw ); -Entry * id2entry_r( Backend *be, ID id ); -Entry * id2entry_w( Backend *be, ID id ); +int id2entry_add LDAP_P(( Backend *be, Entry *e )); +int id2entry_delete LDAP_P(( Backend *be, Entry *e )); +Entry * id2entry LDAP_P(( Backend *be, ID id, int rw )); +Entry * id2entry_r LDAP_P(( Backend *be, ID id )); +Entry * id2entry_w LDAP_P(( Backend *be, ID id )); /* * idl.c */ -IDList * idl_alloc( int nids ); -IDList * idl_allids( Backend *be ); -void idl_free( IDList *idl ); -IDList * idl_fetch( Backend *be, struct dbcache *db, Datum key ); -int idl_insert_key( Backend *be, struct dbcache *db, Datum key, ID id ); -int idl_insert( IDList **idl, ID id, int maxids ); -IDList * idl_intersection( Backend *be, IDList *a, IDList *b ); -IDList * idl_union( Backend *be, IDList *a, IDList *b ); -IDList * idl_notin( Backend *be, IDList *a, IDList *b ); -ID idl_firstid( IDList *idl ); -ID idl_nextid( IDList *idl, ID id ); +IDList * idl_alloc LDAP_P(( int nids )); +IDList * idl_allids LDAP_P(( Backend *be )); +void idl_free LDAP_P(( IDList *idl )); +IDList * idl_fetch LDAP_P(( Backend *be, struct dbcache *db, Datum key )); +int idl_insert_key LDAP_P(( Backend *be, struct dbcache *db, Datum key, ID id )); +int idl_insert LDAP_P(( IDList **idl, ID id, int maxids )); +IDList * idl_intersection LDAP_P(( Backend *be, IDList *a, IDList *b )); +IDList * idl_union LDAP_P(( Backend *be, IDList *a, IDList *b )); +IDList * idl_notin LDAP_P(( Backend *be, IDList *a, IDList *b )); +ID idl_firstid LDAP_P(( IDList *idl )); +ID idl_nextid LDAP_P(( IDList *idl, ID id )); /* * index.c */ -int index_add_entry( Backend *be, Entry *e ); -int index_add_mods( Backend *be, LDAPMod *mods, ID id ); -IDList * index_read( Backend *be, char *type, int indextype, char *val ); -int index_add_values( Backend *be, char *type, struct berval **vals, ID id ); +int index_add_entry LDAP_P(( Backend *be, Entry *e )); +int index_add_mods LDAP_P(( Backend *be, LDAPMod *mods, ID id )); +IDList * index_read LDAP_P(( Backend *be, char *type, int indextype, char *val )); +int index_add_values LDAP_P(( Backend *be, char *type, struct berval **vals, ID id )); /* * kerberos.c */ -#ifdef KERBEROS -/* krbv4_ldap_auth( Backend *be, struct berval *cred, AUTH_DAT *ad ); */ +#ifdef HAVE_KERBEROS +/* krbv4_ldap_auth LDAP_P(( Backend *be, struct berval *cred, AUTH_DAT *ad )); */ #endif /* * nextid.c */ -ID next_id( Backend *be ); -void next_id_return( Backend *be, ID id ); -ID next_id_get( Backend *be ); +ID next_id LDAP_P(( Backend *be )); +void next_id_return LDAP_P(( Backend *be, ID id )); +ID next_id_get LDAP_P(( Backend *be )); +LDAP_END_DECL #endif diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 19dafe4c01..2bf35034bf 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -1,5 +1,7 @@ /* search.c - ldbm backend search function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-ldbm/unbind.c b/servers/slapd/back-ldbm/unbind.c index 9f3421d5ee..56e3e426a4 100644 --- a/servers/slapd/back-ldbm/unbind.c +++ b/servers/slapd/back-ldbm/unbind.c @@ -1,5 +1,7 @@ /* unbind.c - handle an ldap unbind operation */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-passwd/config.c b/servers/slapd/back-passwd/config.c index 5a26ff0fb6..252717ab73 100644 --- a/servers/slapd/back-passwd/config.c +++ b/servers/slapd/back-passwd/config.c @@ -1,5 +1,7 @@ /* config.c - passwd backend configuration file routine */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 11c1d8e719..3e9a0f9a8c 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -1,5 +1,7 @@ /* search.c - /etc/passwd backend search function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/abandon.c b/servers/slapd/back-shell/abandon.c index fc9d6a40b6..090ba26a4b 100644 --- a/servers/slapd/back-shell/abandon.c +++ b/servers/slapd/back-shell/abandon.c @@ -1,5 +1,7 @@ /* abandon.c - shell backend abandon function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/add.c b/servers/slapd/back-shell/add.c index 89f054cc9c..e9840e9eaa 100644 --- a/servers/slapd/back-shell/add.c +++ b/servers/slapd/back-shell/add.c @@ -1,5 +1,7 @@ /* add.c - shell backend add function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/bind.c b/servers/slapd/back-shell/bind.c index dea149e410..2d8e5a0a13 100644 --- a/servers/slapd/back-shell/bind.c +++ b/servers/slapd/back-shell/bind.c @@ -1,5 +1,7 @@ /* bind.c - shell backend bind function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/compare.c b/servers/slapd/back-shell/compare.c index 48dfbb553b..642524f04d 100644 --- a/servers/slapd/back-shell/compare.c +++ b/servers/slapd/back-shell/compare.c @@ -1,5 +1,7 @@ /* compare.c - shell backend compare function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/config.c b/servers/slapd/back-shell/config.c index 5d2fa1c19a..fc22aac49a 100644 --- a/servers/slapd/back-shell/config.c +++ b/servers/slapd/back-shell/config.c @@ -1,5 +1,7 @@ /* config.c - shell backend configuration file routine */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/delete.c b/servers/slapd/back-shell/delete.c index 0dc3439c00..e794a23a62 100644 --- a/servers/slapd/back-shell/delete.c +++ b/servers/slapd/back-shell/delete.c @@ -1,5 +1,7 @@ /* delete.c - shell backend delete function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/fork.c b/servers/slapd/back-shell/fork.c index aff0e5bbe4..1b25031cbb 100644 --- a/servers/slapd/back-shell/fork.c +++ b/servers/slapd/back-shell/fork.c @@ -1,5 +1,7 @@ /* fork.c - fork and exec a process, connecting stdin/out w/pipes */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/init.c b/servers/slapd/back-shell/init.c index 1df9c4b265..b4087cb8a8 100644 --- a/servers/slapd/back-shell/init.c +++ b/servers/slapd/back-shell/init.c @@ -1,5 +1,7 @@ /* init.c - initialize shell backend */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/modify.c b/servers/slapd/back-shell/modify.c index d05b79639d..b61dc8234d 100644 --- a/servers/slapd/back-shell/modify.c +++ b/servers/slapd/back-shell/modify.c @@ -1,5 +1,7 @@ /* modify.c - shell backend modify function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/modrdn.c b/servers/slapd/back-shell/modrdn.c index 9fd793317d..a4735164d0 100644 --- a/servers/slapd/back-shell/modrdn.c +++ b/servers/slapd/back-shell/modrdn.c @@ -1,5 +1,7 @@ /* modrdn.c - shell backend modrdn function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/result.c b/servers/slapd/back-shell/result.c index 675aa1f144..f1ac898526 100644 --- a/servers/slapd/back-shell/result.c +++ b/servers/slapd/back-shell/result.c @@ -1,5 +1,7 @@ /* result.c - shell backend result reading function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/search.c b/servers/slapd/back-shell/search.c index 749b112a94..cbc3243d21 100644 --- a/servers/slapd/back-shell/search.c +++ b/servers/slapd/back-shell/search.c @@ -1,5 +1,7 @@ /* search.c - shell backend search function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/back-shell/shell.h b/servers/slapd/back-shell/shell.h index 5ef493c045..6228b6408e 100644 --- a/servers/slapd/back-shell/shell.h +++ b/servers/slapd/back-shell/shell.h @@ -1,5 +1,12 @@ /* shell.h - shell backend header file */ +#ifndef SLAPD_SHELL_H +#define SLAPD_SHELL_H + +#include + +LDAP_BEGIN_DECL + struct shellinfo { char **si_bind; /* cmd + args to exec for bind */ char **si_unbind; /* cmd + args to exec for unbind */ @@ -11,3 +18,7 @@ struct shellinfo { char **si_delete; /* cmd + args to exec for delete */ char **si_abandon; /* cmd + args to exec for abandon */ }; + +LDAP_END_DECL + +#endif diff --git a/servers/slapd/back-shell/unbind.c b/servers/slapd/back-shell/unbind.c index 649fe96c13..df836f3e8f 100644 --- a/servers/slapd/back-shell/unbind.c +++ b/servers/slapd/back-shell/unbind.c @@ -1,5 +1,7 @@ /* unbind.c - shell backend unbind function */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 998bfa8c6a..93675af31b 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -1,6 +1,8 @@ /* backend.c - routines for dealing with back-end databases */ +#include "portable.h" + #include #include #include @@ -21,6 +23,7 @@ extern int ldbm_back_abandon(); extern int ldbm_back_config(); extern int ldbm_back_init(); extern int ldbm_back_close(); +extern int ldbm_back_group(); #endif #ifdef LDAP_PASSWD @@ -86,6 +89,9 @@ new_backend( be->be_config = ldbm_back_config; be->be_init = ldbm_back_init; be->be_close = ldbm_back_close; +#ifdef ACLGROUP + be->be_group = ldbm_back_group; +#endif be->be_type = "ldbm"; foundit = 1; } @@ -105,6 +111,9 @@ new_backend( be->be_config = passwd_back_config; be->be_init = NULL; be->be_close = NULL; +#ifdef ACLGROUP + be->be_group = NULL; +#endif be->be_type = "passwd"; foundit = 1; } @@ -124,6 +133,9 @@ new_backend( be->be_config = shell_back_config; be->be_init = shell_back_init; be->be_close = NULL; +#ifdef ACLGROUP + be->be_group = NULL; +#endif be->be_type = "shell"; foundit = 1; } @@ -149,7 +161,20 @@ select_backend( char * dn ) dnlen = strlen( dn ); for ( i = 0; i < nbackends; i++ ) { for ( j = 0; backends[i].be_suffix != NULL && - backends[i].be_suffix[j] != NULL; j++ ) { + backends[i].be_suffix[j] != NULL; j++ ) + { +#ifdef LDAP_ALLOW_NULL_SEARCH_BASE + /* Add greg@greg.rim.or.jp + * It's quick hack for cheap client + * Some browser offer a NULL base at ldap_search + */ + if(dnlen == 0) { + Debug( LDAP_DEBUG_TRACE, + "select_backend: use default backend\n", 0, 0, 0 ); + return (&backends[i]); + } +#endif /* LDAP_ALLOW_NULL_SEARCH_BASE */ + len = strlen( backends[i].be_suffix[j] ); if ( len > dnlen ) { @@ -231,3 +256,14 @@ be_unbind( } } } + +#ifdef ACLGROUP +int +be_group(Backend *be, char *bdn, char *edn) +{ + if (be->be_group) + return(be->be_group(be, bdn, edn)); + else + return(1); +} +#endif diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index 562ce5b54a..4fa8478535 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -12,6 +12,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/ch_malloc.c b/servers/slapd/ch_malloc.c index 43ec4c9adb..9f5cf56073 100644 --- a/servers/slapd/ch_malloc.c +++ b/servers/slapd/ch_malloc.c @@ -1,5 +1,7 @@ /* ch_malloc.c - malloc routines that test returns from malloc and friends */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/charray.c b/servers/slapd/charray.c index b731cf1e90..71ef9e6345 100644 --- a/servers/slapd/charray.c +++ b/servers/slapd/charray.c @@ -1,5 +1,7 @@ /* charray.c - routines for dealing with char * arrays */ +#include "portable.h" + #include #include #include @@ -113,6 +115,9 @@ str2charray( char *str, char *brkstr ) char *s; int i; + /* protect the input string from strtok */ + str = strdup( str ); + i = 1; for ( s = str; *s; s++ ) { if ( strchr( brkstr, *s ) != NULL ) { @@ -128,5 +133,6 @@ str2charray( char *str, char *brkstr ) } res[i] = NULL; + free( str ); return( res ); } diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 248c8b1ec7..d836a43365 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 66050586ab..55660182c6 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -1,5 +1,7 @@ /* config.c - configuration file handling routines */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/configinfo.c b/servers/slapd/configinfo.c index c1719efde8..f6dcfe9d5f 100644 --- a/servers/slapd/configinfo.c +++ b/servers/slapd/configinfo.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 1b2bd41ed7..bbfdd4344e 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -1,4 +1,3 @@ -#define DISABLE_BRIDGE #include "portable.h" #include diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index c15c58b24a..1dfc8682b1 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -5,7 +5,6 @@ * Added locking of new_conn_mutex when traversing the c[] array. */ -#define DISABLE_BRIDGE /* disable bridge code */ #include "portable.h" #include diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index bbab47806c..bab22d924f 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/detach.c b/servers/slapd/detach.c index 7b3fdab57a..bb28bc96a2 100644 --- a/servers/slapd/detach.c +++ b/servers/slapd/detach.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #ifdef SVR4 @@ -39,6 +41,12 @@ detach() nbits = getdtablesize(); #endif /* USE_SYSCONF */ +#ifdef FD_SETSIZE + if ( nbits > FD_SETSIZE ) { + nbits = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ + #ifdef LDAP_DEBUG if ( ldap_debug == 0 ) { #endif diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 226937efa9..de10e368c7 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -1,12 +1,13 @@ /* dn.c - routines for dealing with distinguished names */ +#include "portable.h" + #include #include #include #include #include #include -#include "portable.h" #include "slap.h" static char **dn_explode(); @@ -206,7 +207,7 @@ dn_parent( } } - return( NULL ); + return( strdup("") ); } /* diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 72ef4b1684..562cc47b68 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -1,5 +1,7 @@ /* entry.c - routines for dealing with entries */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 8d990b361d..49f8166f2b 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -1,5 +1,7 @@ /* filter.c - routines for parsing and dealing with filters */ +#include "portable.h" + #include #include #include @@ -135,6 +137,7 @@ get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr ) Debug( LDAP_DEBUG_FILTER, "AND\n", 0, 0, 0 ); if ( (err = get_filter_list( conn, ber, &f->f_and, &ftmp )) == 0 ) { + if (ftmp == NULL) ftmp = strdup(""); *fstr = ch_malloc( 4 + strlen( ftmp ) ); sprintf( *fstr, "(&%s)", ftmp ); free( ftmp ); @@ -145,6 +148,7 @@ get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr ) Debug( LDAP_DEBUG_FILTER, "OR\n", 0, 0, 0 ); if ( (err = get_filter_list( conn, ber, &f->f_or, &ftmp )) == 0 ) { + if (ftmp == NULL) ftmp = strdup(""); *fstr = ch_malloc( 4 + strlen( ftmp ) ); sprintf( *fstr, "(|%s)", ftmp ); free( ftmp ); @@ -155,6 +159,7 @@ get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr ) Debug( LDAP_DEBUG_FILTER, "NOT\n", 0, 0, 0 ); (void) ber_skip_tag( ber, &len ); if ( (err = get_filter( conn, ber, &f->f_not, &ftmp )) == 0 ) { + if (ftmp == NULL) ftmp = strdup(""); *fstr = ch_malloc( 4 + strlen( ftmp ) ); sprintf( *fstr, "(!%s)", ftmp ); free( ftmp ); diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index 712ff22e2e..495fcb2ca6 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -1,25 +1,18 @@ /* filterentry.c - apply a filter to an entry */ +#include "portable.h" + #include #include #include #include -#ifdef sunos5 -#include "regexpr.h" -#else -#include "regex.h" -#endif +#include #include "slap.h" extern Attribute *attr_find(); extern char *first_word(); extern char *next_word(); extern char *phonetic(); -extern char *re_comp(); - -#ifndef sunos5 -extern pthread_mutex_t regex_mutex; -#endif static int test_filter_list(); static int test_substring_filter(); @@ -223,11 +216,12 @@ test_approx_filter( w2 = next_word( w2 ) ) { c2 = phonetic( w2 ); if ( strcmp( c1, c2 ) == 0 ) { + free( c2 ); break; } + free( c2 ); } free( c1 ); - free( c2 ); /* * if we stopped because we ran out of words @@ -322,6 +316,7 @@ test_substring_filter( char pat[BUFSIZ]; char buf[BUFSIZ]; struct berval *val; + regex_t re; Debug( LDAP_DEBUG_FILTER, "begin test_substring_filter\n", 0, 0, 0 ); @@ -389,19 +384,16 @@ test_substring_filter( } /* compile the regex */ -#ifdef sunos5 - if ( (p = compile( pat, NULL, NULL )) == NULL ) { - Debug( LDAP_DEBUG_ANY, "compile failed (%s)\n", p, 0, 0 ); + Debug( LDAP_DEBUG_FILTER, "test_substring_filter: regcomp pat: %s\n", + pat, 0, 0 ); + if ((rc = regcomp(&re, pat, 0))) { + char error[512]; + + regerror(rc, &re, error, sizeof(error)); + Debug( LDAP_DEBUG_ANY, "regcomp failed (%s) %s\n", + p, error, 0 ); return( -1 ); } -#else /* sunos5 */ - pthread_mutex_lock( ®ex_mutex ); - if ( (p = re_comp( pat )) != 0 ) { - Debug( LDAP_DEBUG_ANY, "re_comp failed (%s)\n", p, 0, 0 ); - pthread_mutex_unlock( ®ex_mutex ); - return( -1 ); - } -#endif /* sunos5 */ /* for each value in the attribute see if regex matches */ for ( i = 0; a->a_vals[i] != NULL; i++ ) { @@ -417,29 +409,18 @@ test_substring_filter( } value_normalize( realval, a->a_syntax ); -#ifdef sunos5 - rc = step( realval, p ); -#else /* sunos5 */ - rc = re_exec( realval ); -#endif /* sunos5 */ + rc = !regexec(&re, realval, 0, NULL, 0); if ( tmp != NULL ) { free( tmp ); } if ( rc == 1 ) { -#ifdef sunos5 - free( p ); -#else /* sunos5 */ - pthread_mutex_unlock( ®ex_mutex ); -#endif /* sunos5 */ + regfree(&re); return( 0 ); } } -#ifdef sunos5 - free( p ); -#else /* sunos5 */ - pthread_mutex_unlock( ®ex_mutex ); -#endif /* sunos5 */ + + regfree(&re); Debug( LDAP_DEBUG_FILTER, "end test_substring_filter 1\n", 0, 0, 0 ); return( 1 ); diff --git a/servers/slapd/init.c b/servers/slapd/init.c index 03dd850f0e..7ba8318758 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -1,5 +1,7 @@ /* init.c - initialize various things */ +#include "portable.h" + #include #include #include @@ -18,9 +20,6 @@ extern pthread_mutex_t entry2str_mutex; extern pthread_mutex_t replog_mutex; extern pthread_mutex_t ops_mutex; extern pthread_mutex_t num_sent_mutex; -#ifndef sunos5 -extern pthread_mutex_t regex_mutex; -#endif init() { @@ -31,7 +30,4 @@ init() pthread_mutex_init( &replog_mutex, pthread_mutexattr_default ); pthread_mutex_init( &ops_mutex, pthread_mutexattr_default ); pthread_mutex_init( &num_sent_mutex, pthread_mutexattr_default ); -#ifndef sunos5 - pthread_mutex_init( ®ex_mutex, pthread_mutexattr_default ); -#endif } diff --git a/servers/slapd/lock.c b/servers/slapd/lock.c index 305fb5b91c..2e3cb917fd 100644 --- a/servers/slapd/lock.c +++ b/servers/slapd/lock.c @@ -1,5 +1,7 @@ /* lock.c - routines to open and apply an advisory lock to a file */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 01930b9709..258923e61e 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -1,3 +1,5 @@ +#include "portable.h" + #include #include #include @@ -10,16 +12,17 @@ #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 +58,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 +105,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; @@ -184,12 +184,27 @@ main( argc, argv ) pthread_attr_init( &attr ); pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED ); - if ( pthread_create( &listener_tid, attr, (void *) daemon, +#ifndef THREAD_MIT_PTHREADS + /* POSIX_THREADS or compatible + * This is a draft 10 or standard pthreads implementation + */ + if ( pthread_create( &listener_tid, &attr, (void *) slapd_daemon, (void *) port ) != 0 ) { Debug( LDAP_DEBUG_ANY, "listener pthread_create failed\n", 0, 0, 0 ); exit( 1 ); } +#else /* !THREAD_MIT_PTHREADS */ + /* + * This is a draft 4 or earlier pthreads implementation + */ + if ( pthread_create( &listener_tid, attr, (void *) slapd_daemon, + (void *) port ) != 0 ) { + Debug( LDAP_DEBUG_ANY, + "listener pthread_create failed\n", 0, 0, 0 ); + exit( 1 ); + } +#endif /* !THREAD_MIT_PTHREADS */ pthread_attr_destroy( &attr ); pthread_join( listener_tid, (void *) &status ); pthread_exit( 0 ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index dd7689cfaf..8c03510460 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 802dda55ac..75af6e13e8 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index a7311989ef..66c6494e5c 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -17,6 +17,8 @@ * Added locking of currenttime_mutex to protect call(s) to localtime(). */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/operation.c b/servers/slapd/operation.c index 0c62e219ec..a960c30695 100644 --- a/servers/slapd/operation.c +++ b/servers/slapd/operation.c @@ -1,5 +1,7 @@ /* operation.c - routines to deal with pending ldap operations */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/phonetic.c b/servers/slapd/phonetic.c index 959e06e1e3..996c68160c 100644 --- a/servers/slapd/phonetic.c +++ b/servers/slapd/phonetic.c @@ -1,5 +1,7 @@ /* phonetic.c - routines to do phonetic matching */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 83e4872d15..3b08579d76 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1,213 +1,215 @@ #ifndef _PROTO_SLAP #define _PROTO_SLAP +#include + /* * acl.c */ -int access_allowed( Backend *be, Connection *conn, Operation *op, Entry *e, - char *attr, struct berval *val, char *dn, int access ); +int access_allowed LDAP_P(( Backend *be, Connection *conn, Operation *op, Entry *e, + char *attr, struct berval *val, char *dn, int access )); -struct acl * acl_get_applicable( Backend *be, Operation *op, Entry *e, - char *attr, char *edn, int nmatches, regmatch_t *matches ); -int acl_access_allowed( struct acl *a, Backend *be, Connection *conn, Entry *e, +struct acl * acl_get_applicable LDAP_P(( Backend *be, Operation *op, Entry *e, + char *attr, char *edn, int nmatches, regmatch_t *matches )); +int acl_access_allowed LDAP_P(( struct acl *a, Backend *be, Connection *conn, Entry *e, struct berval *val, Operation *op, int access, char *edn, - regmatch_t *matches ); + regmatch_t *matches )); -int acl_check_mods( Backend *be, Connection *conn, Operation *op, Entry *e, - LDAPMod *mods ); +int acl_check_mods LDAP_P(( Backend *be, Connection *conn, Operation *op, Entry *e, + LDAPMod *mods )); /* * aclparse.c */ -void parse_acl( Backend *be, char *fname, int lineno, int argc, char **argv ); -char * access2str( int access ); -int str2access( char *str ); +void parse_acl LDAP_P(( Backend *be, char *fname, int lineno, int argc, char **argv )); +char * access2str LDAP_P(( int access )); +int str2access LDAP_P(( char *str )); /* * attr.c */ -void attr_free( Attribute *a ); -char * attr_normalize( char *s ); -int attr_merge_fast( Entry *e, char *type, struct berval **vals, int nvals, - int naddvals, int *maxvals, Attribute ***a ); -int attr_merge( Entry *e, char *type, struct berval **vals ); -Attribute * attr_find( Attribute *a, char *type ); -int attr_delete( Attribute **attrs, char *type ); -int attr_syntax( char *type ); -void attr_syntax_config( char *fname, int lineno, int argc, char **argv ); +void attr_free LDAP_P(( Attribute *a )); +char * attr_normalize LDAP_P(( char *s )); +int attr_merge_fast LDAP_P(( Entry *e, char *type, struct berval **vals, int nvals, + int naddvals, int *maxvals, Attribute ***a )); +int attr_merge LDAP_P(( Entry *e, char *type, struct berval **vals )); +Attribute * attr_find LDAP_P(( Attribute *a, char *type )); +int attr_delete LDAP_P(( Attribute **attrs, char *type )); +int attr_syntax LDAP_P(( char *type )); +void attr_syntax_config LDAP_P(( char *fname, int lineno, int argc, char **argv )); /* * ava.c */ -int get_ava( BerElement *ber, Ava *ava ); -void ava_free( Ava *ava, int freeit ); +int get_ava LDAP_P(( BerElement *ber, Ava *ava )); +void ava_free LDAP_P(( Ava *ava, int freeit )); /* * backend.c */ -Backend * new_backend( char *type ); -Backend * select_backend( char * dn ); -int be_issuffix( Backend *be, char *suffix ); -int be_isroot( Backend *be, char *dn ); -int be_isroot_pw( Backend *be, char *dn, struct berval *cred ); -void be_close(); +Backend * new_backend LDAP_P(( char *type )); +Backend * select_backend LDAP_P(( char * dn )); +int be_issuffix LDAP_P(( Backend *be, char *suffix )); +int be_isroot LDAP_P(( Backend *be, char *dn )); +int be_isroot_pw LDAP_P(( Backend *be, char *dn, struct berval *cred )); +void be_close LDAP_P(()); /* * ch_malloc.c */ -char * ch_malloc( unsigned long size ); -char * ch_realloc( char *block, unsigned long size ); -char * ch_calloc( unsigned long nelem, unsigned long size ); +char * ch_malloc LDAP_P(( unsigned long size )); +char * ch_realloc LDAP_P(( char *block, unsigned long size )); +char * ch_calloc LDAP_P(( unsigned long nelem, unsigned long size )); /* * charray.c */ -void charray_add( char ***a, char *s ); -void charray_merge( char ***a, char **s ); -void charray_free( char **array ); -int charray_inlist( char **a, char *s ); -char ** charray_dup( char **a ); -char ** str2charray( char *str, char *brkstr ); +void charray_add LDAP_P(( char ***a, char *s )); +void charray_merge LDAP_P(( char ***a, char **s )); +void charray_free LDAP_P(( char **array )); +int charray_inlist LDAP_P(( char **a, char *s )); +char ** charray_dup LDAP_P(( char **a )); +char ** str2charray LDAP_P(( char *str, char *brkstr )); /* * config.c */ -void read_config( char *fname, Backend **bep, FILE *pfp ); +void read_config LDAP_P(( char *fname, Backend **bep, FILE *pfp )); /* * connection.c */ -void connection_activity( Connection *conn ); +void connection_activity LDAP_P(( Connection *conn )); /* * dn.c */ -char * dn_normalize( char *dn ); -char * dn_normalize_case( char *dn ); -char * dn_parent( Backend *be, char *dn ); -int dn_issuffix( char *dn, char *suffix ); -int dn_type( char *dn ); -char * dn_upcase( char *dn ); +char * dn_normalize LDAP_P(( char *dn )); +char * dn_normalize_case LDAP_P(( char *dn )); +char * dn_parent LDAP_P(( Backend *be, char *dn )); +int dn_issuffix LDAP_P(( char *dn, char *suffix )); +int dn_type LDAP_P(( char *dn )); +char * dn_upcase LDAP_P(( char *dn )); /* * entry.c */ -Entry * str2entry( char *s ); -char * entry2str( Entry *e, int *len, int printid ); -void entry_free( Entry *e ); +Entry * str2entry LDAP_P(( char *s )); +char * entry2str LDAP_P(( Entry *e, int *len, int printid )); +void entry_free LDAP_P(( Entry *e )); -int entry_rdwr_lock( Entry *e, int rw ); -int entry_rdwr_rlock( Entry *e ); -int entry_rdwr_wlock( Entry *e ); -int entry_rdwr_unlock( Entry *e, int rw ); -int entry_rdwr_runlock( Entry *e ); -int entry_rdwr_wunlock( Entry *e ); -int entry_rdwr_init( Entry *e ); +int entry_rdwr_lock LDAP_P(( Entry *e, int rw )); +int entry_rdwr_rlock LDAP_P(( Entry *e )); +int entry_rdwr_wlock LDAP_P(( Entry *e )); +int entry_rdwr_unlock LDAP_P(( Entry *e, int rw )); +int entry_rdwr_runlock LDAP_P(( Entry *e )); +int entry_rdwr_wunlock LDAP_P(( Entry *e )); +int entry_rdwr_init LDAP_P(( Entry *e )); /* * filter.c */ -int get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr ); -void filter_free( Filter *f ); -void filter_print( Filter *f ); +int get_filter LDAP_P(( Connection *conn, BerElement *ber, Filter **filt, char **fstr )); +void filter_free LDAP_P(( Filter *f )); +void filter_print LDAP_P(( Filter *f )); /* * filterentry.c */ -int test_filter( Backend *be, Connection *conn, Operation *op, Entry *e, - Filter *f ); +int test_filter LDAP_P(( Backend *be, Connection *conn, Operation *op, Entry *e, + Filter *f )); /* * lock.c */ -FILE * lock_fopen( char *fname, char *type, FILE **lfp ); -int lock_fclose( FILE *fp, FILE *lfp ); +FILE * lock_fopen LDAP_P(( char *fname, char *type, FILE **lfp )); +int lock_fclose LDAP_P(( FILE *fp, FILE *lfp )); /* * monitor.c */ -void monitor_info( Connection *conn, Operation *op ); +void monitor_info LDAP_P(( Connection *conn, Operation *op )); /* * operation.c */ -void op_free( Operation *op ); -Operation * op_add( Operation **olist, BerElement *ber, unsigned long msgid, - unsigned long tag, char *dn, int id, int connid ); -void op_delete( Operation **olist, Operation *op ); +void op_free LDAP_P(( Operation *op )); +Operation * op_add LDAP_P(( Operation **olist, BerElement *ber, unsigned long msgid, + unsigned long tag, char *dn, int id, int connid )); +void op_delete LDAP_P(( Operation **olist, Operation *op )); /* * phonetic.c */ -char * first_word( char *s ); -char * next_word( char *s ); -char * word_dup( char *w ); -char * phonetic( char *s ); +char * first_word LDAP_P(( char *s )); +char * next_word LDAP_P(( char *s )); +char * word_dup LDAP_P(( char *w )); +char * phonetic LDAP_P(( char *s )); /* * repl.c */ -void replog( Backend *be, int optype, char *dn, void *change, int flag ); +void replog LDAP_P(( Backend *be, int optype, char *dn, void *change, int flag )); /* * result.c */ -void send_ldap_result( Connection *conn, Operation *op, int err, char *matched, - char *text ); -void send_ldap_search_result( Connection *conn, Operation *op, int err, - char *matched, char *text, int nentries ); -void close_connection( Connection *conn, int opconnid, int opid ); +void send_ldap_result LDAP_P(( Connection *conn, Operation *op, int err, char *matched, + char *text )); +void send_ldap_search_result LDAP_P(( Connection *conn, Operation *op, int err, + char *matched, char *text, int nentries )); +void close_connection LDAP_P(( Connection *conn, int opconnid, int opid )); /* * schema.c */ -int oc_schema_check( Entry *e ); +int oc_schema_check LDAP_P(( Entry *e )); /* * schemaparse.c */ -void parse_oc( Backend *be, char *fname, int lineno, int argc, char **argv ); +void parse_oc LDAP_P(( Backend *be, char *fname, int lineno, int argc, char **argv )); /* * str2filter.c */ -Filter * str2filter( char *str ); +Filter * str2filter LDAP_P(( char *str )); /* * value.c */ -int value_add_fast( struct berval ***vals, struct berval **addvals, int nvals, - int naddvals, int *maxvals ); -int value_add( struct berval ***vals, struct berval **addvals ); -void value_normalize( char *s, int syntax ); -int value_cmp( struct berval *v1, struct berval *v2, int syntax, - int normalize ); -int value_ncmp( struct berval *v1, struct berval *v2, int syntax, int len, - int normalize ); -int value_find( struct berval **vals, struct berval *v, int syntax, - int normalize ); +int value_add_fast LDAP_P(( struct berval ***vals, struct berval **addvals, int nvals, + int naddvals, int *maxvals )); +int value_add LDAP_P(( struct berval ***vals, struct berval **addvals )); +void value_normalize LDAP_P(( char *s, int syntax )); +int value_cmp LDAP_P(( struct berval *v1, struct berval *v2, int syntax, + int normalize )); +int value_ncmp LDAP_P(( struct berval *v1, struct berval *v2, int syntax, int len, + int normalize )); +int value_find LDAP_P(( struct berval **vals, struct berval *v, int syntax, + int normalize )); #endif /* _proto_slap */ diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index 0a3d7c4631..cd0198ebd7 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -1,5 +1,7 @@ /* repl.c - log modifications for replication purposes */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 620c7ef13c..185cc0269d 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -1,6 +1,5 @@ /* result.c - routines to send ldap results, errors, and referrals */ -#define DISABLE_BRIDGE #include "portable.h" #include diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index ba16d9b0f1..fc5f0214fa 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -1,5 +1,7 @@ /* schema.c - routines to enforce schema definitions */ +#include "portable.h" + #include #include #include @@ -76,6 +78,11 @@ oc_check_required( Entry *e, char *ocname ) return( 0 ); } + /* check for empty oc_required */ + if(oc->oc_required == NULL) { + return( 0 ); + } + /* for each required attribute */ for ( i = 0; oc->oc_required[i] != NULL; i++ ) { /* see if it's in the entry */ @@ -111,14 +118,16 @@ oc_check_allowed( char *type, struct berval **ocl ) /* if we know about the oc */ if ( (oc = oc_find( ocl[i]->bv_val )) != NULL ) { /* does it require the type? */ - for ( j = 0; oc->oc_required[j] != NULL; j++ ) { + for ( j = 0; oc->oc_required != NULL && + oc->oc_required[j] != NULL; j++ ) { if ( strcasecmp( oc->oc_required[j], type ) == 0 ) { return( 0 ); } } /* does it allow the type? */ - for ( j = 0; oc->oc_allowed[j] != NULL; j++ ) { + for ( j = 0; oc->oc_allowed != NULL && + oc->oc_allowed[j] != NULL; j++ ) { if ( strcasecmp( oc->oc_allowed[j], type ) == 0 || strcmp( oc->oc_allowed[j], "*" ) == 0 ) diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c index 180ed71d00..70edf66b8b 100644 --- a/servers/slapd/schemaparse.c +++ b/servers/slapd/schemaparse.c @@ -1,5 +1,7 @@ /* schemaparse.c - routines to parse config file objectclass definitions */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/search.c b/servers/slapd/search.c index fc96d2fd02..721c013f84 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/shell-backends/passwd-shell.c b/servers/slapd/shell-backends/passwd-shell.c index 2210651dbf..fd354e0fe4 100644 --- a/servers/slapd/shell-backends/passwd-shell.c +++ b/servers/slapd/shell-backends/passwd-shell.c @@ -13,6 +13,8 @@ */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/shell-backends/shellutil.c b/servers/slapd/shell-backends/shellutil.c index 82eea1665b..e1a6d030a4 100644 --- a/servers/slapd/shell-backends/shellutil.c +++ b/servers/slapd/shell-backends/shellutil.c @@ -14,6 +14,8 @@ */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/shell-backends/shellutil.h b/servers/slapd/shell-backends/shellutil.h index 7ea0db057c..8c52ab5dcf 100644 --- a/servers/slapd/shell-backends/shellutil.h +++ b/servers/slapd/shell-backends/shellutil.h @@ -12,6 +12,12 @@ is provided ``as is'' without express or implied warranty. */ +#ifndef SHELLUTIL_H +#define SHELLUTIL_H + +#include + +LDAP_BEGIN_DECL #define MAXLINELEN 512 @@ -94,3 +100,6 @@ char *estrdup( char *s ); */ extern int debugflg; extern char *progname; + +LDAP_END_DECL +#endif diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 43f1eae8d1..f5dee02400 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -3,11 +3,14 @@ #ifndef _SLDAPD_H_ #define _SLDAPD_H_ -#define LDAP_SYSLOG +#include "portable.h" + +#include -#include #include -#include +#include +#include + #undef NDEBUG #include @@ -27,6 +30,8 @@ #define MAXREMATCHES 10 +LDAP_BEGIN_DECL + /* * represents an attribute value assertion (i.e., attr=value) */ @@ -134,7 +139,7 @@ struct access { char *a_dnattr; long a_access; -#ifdef ACLGROUP +#ifdef SLAPD_ACLGROUP char *a_group; #endif @@ -226,7 +231,7 @@ typedef struct op { /* LDAP_AUTH_* */ int o_opid; /* id of this operation */ int o_connid; /* id of conn initiating this op */ -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS int o_cldap; /* != 0 if this came in via CLDAP */ struct sockaddr o_clientaddr; /* client address if via CLDAP */ char o_searchbase; /* search base if via CLDAP */ @@ -248,7 +253,7 @@ typedef struct conn { char *c_dn; /* current DN bound to this conn */ pthread_mutex_t c_dnmutex; /* mutex for c_dn field */ int c_authtype; /* auth method used to bind c_dn */ -#ifdef COMPAT +#ifdef LDAP_COMPAT int c_version; /* for compatibility w/2.0, 3.0 */ #endif char *c_addr; /* address of client on this conn */ @@ -280,8 +285,8 @@ typedef struct conn { #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) #endif -#ifdef NEEDPROTOS #include "proto-slap.h" -#endif + +LDAP_END_DECL #endif /* _slap_h_ */ diff --git a/servers/slapd/str2filter.c b/servers/slapd/str2filter.c index aca9674fd8..46b80f5fe6 100644 --- a/servers/slapd/str2filter.c +++ b/servers/slapd/str2filter.c @@ -1,5 +1,7 @@ /* str2filter.c - parse an rfc 1588 string filter */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/strdup.c b/servers/slapd/strdup.c index a16928a2e8..ec7398d4a8 100644 --- a/servers/slapd/strdup.c +++ b/servers/slapd/strdup.c @@ -1,8 +1,9 @@ +#include "portable.h" + #if defined( ultrix ) || defined( nextstep ) #include - char *strdup( char *s ) { char *p; diff --git a/servers/slapd/tempnam.c b/servers/slapd/tempnam.c index 20d108c9d2..53c0e50228 100644 --- a/servers/slapd/tempnam.c +++ b/servers/slapd/tempnam.c @@ -1,3 +1,5 @@ +#include "portable.h" + #if defined( nextstep ) #include diff --git a/servers/slapd/tools/centipede.c b/servers/slapd/tools/centipede.c index 9919232b7a..5de9388b56 100644 --- a/servers/slapd/tools/centipede.c +++ b/servers/slapd/tools/centipede.c @@ -1,5 +1,7 @@ /* centipede.c - generate and install indexing information (view w/tabstop=4) */ +#include "portable.h" + #include #include #include @@ -556,6 +558,11 @@ diff_centroids( int amax, acur, dmax, dcur; char **vals; +#ifdef LDBM_USE_DB2 + DBC *ocursorp; + DBC *ncursorp; +#endif /* LDBM_USE_DB2 */ + if ( verbose ) { printf( "Generating mods for differential %s centroid...", attr ); fflush( stdout ); @@ -600,8 +607,14 @@ diff_centroids( olast.dptr = NULL; nlast.dptr = NULL; +#ifdef LDBM_USE_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 +629,13 @@ diff_centroids( } nlast = nkey; +#ifdef LDBM_USE_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 +647,12 @@ diff_centroids( ldbm_datum_free( nldbm, nlast ); } nlast = nkey; + +#ifdef LDBM_USE_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 +664,12 @@ diff_centroids( ldbm_datum_free( oldbm, olast ); } olast = okey; + +#ifdef LDBM_USE_DB2 + okey = ldbm_nextkey( oldbm, olast, ocursorp ); +#else okey = ldbm_nextkey( oldbm, olast ); +#endif } } @@ -651,7 +679,11 @@ diff_centroids( return( NULL ); } +#ifdef LDBM_USE_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 +698,11 @@ diff_centroids( return( NULL ); } +#ifdef LDBM_USE_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 +723,14 @@ diff_centroids( /* generate list of values to add */ lastkey.dptr = NULL; +#ifdef LDBM_USE_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 +754,14 @@ diff_centroids( /* generate list of values to delete */ lastkey.dptr = NULL; +#ifdef LDBM_USE_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 +821,10 @@ full_centroid( char **vals; int vcur, vmax; +#ifdef LDBM_USE_DB2 + DBC *cursorp; +#endif + if ( verbose ) { printf( "Generating mods for full %s centroid...", attr ); fflush( stdout ); @@ -800,8 +852,14 @@ full_centroid( lastkey.dptr = NULL; vals = NULL; vcur = vmax = 0; +#ifdef LDBM_USE_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 ); diff --git a/servers/slapd/tools/chlog2replog.c b/servers/slapd/tools/chlog2replog.c index f9f3b3c5d7..cd982936c8 100644 --- a/servers/slapd/tools/chlog2replog.c +++ b/servers/slapd/tools/chlog2replog.c @@ -16,6 +16,8 @@ * slapd/slurpd locking conventions. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/tools/edb2ldif.c b/servers/slapd/tools/edb2ldif.c index d46be1edfd..29bbf1f497 100644 --- a/servers/slapd/tools/edb2ldif.c +++ b/servers/slapd/tools/edb2ldif.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/tools/ldapsyntax.c b/servers/slapd/tools/ldapsyntax.c index 4fa12c407a..69703a33d0 100644 --- a/servers/slapd/tools/ldapsyntax.c +++ b/servers/slapd/tools/ldapsyntax.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/tools/ldapsyntax.h b/servers/slapd/tools/ldapsyntax.h index ddcf1f2b3e..44a23263ca 100644 --- a/servers/slapd/tools/ldapsyntax.h +++ b/servers/slapd/tools/ldapsyntax.h @@ -10,17 +10,23 @@ * is provided ``as is'' without express or implied warranty. */ +#ifndef LDAPSYNTAX_H +#define LDAPSYNTAX_H 1 + +#include + +LDAP_BEGIN_DECL /* XXX: the "master" LINE_WIDTH #define is in ../slap.h */ #define LINE_WIDTH 76 /* for lines in string rep of an entry */ -#ifdef NEEDPROTOS /* * function prototypes */ -int init_syntaxes( void ); -int av2ldif( FILE *outfp, AV_Sequence av, DN dn, short syntax, - char *attrname, PS str_ps ); +int init_syntaxes LDAP_P(( void )); +int av2ldif LDAP_P(( FILE *outfp, AV_Sequence av, DN dn, short syntax, + char *attrname, PS str_ps )); -#endif /* NEEDPROTOS */ +LDAP_END_DECL +#endif diff --git a/servers/slapd/tools/ldbmcat.c b/servers/slapd/tools/ldbmcat.c index 79465df072..b89a54f489 100644 --- a/servers/slapd/tools/ldbmcat.c +++ b/servers/slapd/tools/ldbmcat.c @@ -1,3 +1,5 @@ +#include "portable.h" + #include #include #include @@ -24,6 +26,10 @@ main( argc, argv ) char *file, *s; int printid = 1; +#ifdef LDBM_USE_DB2 + DBC *cursorp; +#endif + if ( argc < 2 || argc > 3 || ( argc == 3 && strcmp( argv[1], "-n" ) != 0 )) { usage( argv[0] ); @@ -41,8 +47,15 @@ main( argc, argv ) } last.dptr = NULL; + +#ifdef LDBM_USE_DB2 + for ( key = ldbm_firstkey( dbp, &cursorp ); key.dptr != NULL; + key = ldbm_nextkey( dbp, last, cursorp ) ) +#else for ( key = ldbm_firstkey( dbp ); key.dptr != NULL; - key = ldbm_nextkey( dbp, last ) ) { + key = ldbm_nextkey( dbp, last ) ) +#endif + { if ( last.dptr != NULL ) ldbm_datum_free( dbp, last ); data = ldbm_fetch( dbp, key ); diff --git a/servers/slapd/tools/ldbmtest.c b/servers/slapd/tools/ldbmtest.c index b202c7b79f..fd2f1a0059 100644 --- a/servers/slapd/tools/ldbmtest.c +++ b/servers/slapd/tools/ldbmtest.c @@ -1,4 +1,3 @@ -#define DISABLE_BRIDGE #include "portable.h" #include diff --git a/servers/slapd/tools/ldif.c b/servers/slapd/tools/ldif.c index dc9f25d584..adcb4b8534 100644 --- a/servers/slapd/tools/ldif.c +++ b/servers/slapd/tools/ldif.c @@ -1,3 +1,5 @@ +#include "portable.h" + #include #include #include @@ -24,7 +26,7 @@ main( argc, argv ) { char buf[BUFSIZ]; char *type, *out; - int binary = 0; + int len, binary = 0; if (argc < 2 || argc > 3 ) { usage( argv[0] ); @@ -79,7 +81,9 @@ main( argc, argv ) } /* not binary: one value per line... */ - while ( gets( buf ) != NULL ) { + while ( fgets( buf, sizeof(buf), stdin ) != NULL ) { + if( buf[len=strlen(buf)] == '\n') buf[len] = '\0'; + if (( out = ldif_type_and_value( type, buf, strlen( buf ) )) == NULL ) { perror( "ldif_type_and_value" ); diff --git a/servers/slapd/tools/ldif2id2children.c b/servers/slapd/tools/ldif2id2children.c index 0bb8e5ec6d..795a26f151 100644 --- a/servers/slapd/tools/ldif2id2children.c +++ b/servers/slapd/tools/ldif2id2children.c @@ -1,3 +1,5 @@ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/tools/ldif2id2entry.c b/servers/slapd/tools/ldif2id2entry.c index ec2bf27279..057b085307 100644 --- a/servers/slapd/tools/ldif2id2entry.c +++ b/servers/slapd/tools/ldif2id2entry.c @@ -1,3 +1,5 @@ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/tools/ldif2index.c b/servers/slapd/tools/ldif2index.c index dd03f3dc78..2e4ba0c439 100644 --- a/servers/slapd/tools/ldif2index.c +++ b/servers/slapd/tools/ldif2index.c @@ -1,7 +1,10 @@ +#include "portable.h" + #include -#include -#include -#include + +#include +#include + #include "../slap.h" #include "ldapconfig.h" diff --git a/servers/slapd/tools/ldif2ldbm.c b/servers/slapd/tools/ldif2ldbm.c index b2caa7b3cc..01021b6840 100644 --- a/servers/slapd/tools/ldif2ldbm.c +++ b/servers/slapd/tools/ldif2ldbm.c @@ -1,3 +1,5 @@ +#include "portable.h" + #include #include #include @@ -5,9 +7,8 @@ #include #include "../slap.h" #include "../back-ldbm/back-ldbm.h" +#include "ldapconfig.h" -#define DEFAULT_CONFIGFILE "%ETCDIR%/slapd.conf" -#define DEFAULT_ETCDIR "%ETCDIR%" #define INDEXCMD "ldif2index" #define ID2ENTRYCMD "ldif2id2entry" #define ID2CHILDRENCMD "ldif2id2children" @@ -52,14 +53,14 @@ static int nkids; static void usage( char *name ) { - fprintf( stderr, "usage: %s -i inputfile [-d debuglevel] [-f configfile] [-j #jobs] [-n databasenumber] [-e etcdir]\n", name ); + fprintf( stderr, "usage: %s -i inputfile [-d debuglevel] [-f configfile] [-j #jobs] [-n databasenumber] [-s sbindir]\n", name ); exit( 1 ); } main( int argc, char **argv ) { int i, stop, status; - char *linep, *buf, *etcdir; + char *linep, *buf, *sbindir; char *args[10]; char buf2[20], buf3[20]; char line[BUFSIZ]; @@ -74,17 +75,18 @@ main( int argc, char **argv ) Avlnode *avltypes = NULL; extern char *optarg; - etcdir = DEFAULT_ETCDIR; - tailorfile = DEFAULT_CONFIGFILE; + sbindir = DEFAULT_SBINDIR; + tailorfile = SLAPD_DEFAULT_CONFIGFILE; dbnum = -1; - while ( (i = getopt( argc, argv, "d:e:f:i:j:n:" )) != EOF ) { + while ( (i = getopt( argc, argv, "d:e:s:f:i:j:n:" )) != EOF ) { switch ( i ) { case 'd': /* turn on debugging */ ldap_debug = atoi( optarg ); break; - case 'e': /* alternate etcdir (index cmd location) */ - etcdir = strdup( optarg ); + case 's': /* alternate sbindir (index cmd location) */ + case 'e': /* accept -e for backwards compatibility */ + sbindir = strdup( optarg ); break; case 'f': /* specify a tailor file */ @@ -135,7 +137,7 @@ main( int argc, char **argv ) fprintf( stderr, "No ldbm database found in config file\n" ); exit( 1 ); } - } else if ( dbnum < 0 || dbnum > nbackends ) { + } else if ( dbnum < 0 || dbnum > (nbackends-1) ) { fprintf( stderr, "Database number selected via -n is out of range\n" ); fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends ); exit( 1 ); @@ -150,14 +152,14 @@ main( int argc, char **argv ) */ i = 0; - sprintf( cmd, "%s/%s", etcdir, ID2ENTRYCMD ); + sprintf( cmd, "%s/%s", sbindir, ID2ENTRYCMD ); args[i++] = cmd; args[i++] = "-i"; args[i++] = inputfile; args[i++] = "-f"; args[i++] = tailorfile; args[i++] = "-n"; - sprintf( buf2, "%d", dbnum ); + sprintf( buf2, "%d", dbnum+1 ); args[i++] = buf2; if ( ldap_debug ) { sprintf( buf3, "%d", ldap_debug ); @@ -172,14 +174,14 @@ main( int argc, char **argv ) */ i = 0; - sprintf( cmd, "%s/%s", etcdir, ID2CHILDRENCMD ); + sprintf( cmd, "%s/%s", sbindir, ID2CHILDRENCMD ); args[i++] = cmd; args[i++] = "-i"; args[i++] = inputfile; args[i++] = "-f"; args[i++] = tailorfile; args[i++] = "-n"; - sprintf( buf2, "%d", dbnum ); + sprintf( buf2, "%d", dbnum+1 ); args[i++] = buf2; if ( ldap_debug ) { sprintf( buf3, "%d", ldap_debug ); @@ -194,14 +196,14 @@ main( int argc, char **argv ) */ i = 0; - sprintf( cmd, "%s/%s", etcdir, INDEXCMD ); + sprintf( cmd, "%s/%s", sbindir, INDEXCMD ); args[i++] = cmd; args[i++] = "-i"; args[i++] = inputfile; args[i++] = "-f"; args[i++] = tailorfile; args[i++] = "-n"; - sprintf( buf2, "%d", dbnum ); + sprintf( buf2, "%d", dbnum+1 ); args[i++] = buf2; if ( ldap_debug ) { sprintf( buf3, "%d", ldap_debug ); diff --git a/servers/slapd/tools/sizecount.c b/servers/slapd/tools/sizecount.c index 45d8230100..a653796ba5 100644 --- a/servers/slapd/tools/sizecount.c +++ b/servers/slapd/tools/sizecount.c @@ -1,3 +1,5 @@ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/unbind.c b/servers/slapd/unbind.c index 500006c34f..487fbbead5 100644 --- a/servers/slapd/unbind.c +++ b/servers/slapd/unbind.c @@ -13,6 +13,8 @@ * */ +#include "portable.h" + #include #include #include diff --git a/servers/slapd/value.c b/servers/slapd/value.c index c9e6fbb577..5be4338ed0 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -1,5 +1,6 @@ /* value.c - routines for dealing with values */ +#include "portable.h" #include #include #include diff --git a/servers/slurpd/admin.c b/servers/slurpd/admin.c index 6a58b40c4c..c056cd1d8b 100644 --- a/servers/slurpd/admin.c +++ b/servers/slurpd/admin.c @@ -15,6 +15,7 @@ * reconfiguration of slurpd. */ +#include "portable.h" #include #include diff --git a/servers/slurpd/args.c b/servers/slurpd/args.c index b3cc935df8..ec4f0b52b7 100644 --- a/servers/slurpd/args.c +++ b/servers/slurpd/args.c @@ -14,8 +14,11 @@ * args.c - process command-line arguments, and set appropriate globals. */ +#include "portable.h" + #include #include +#include #include #include diff --git a/servers/slurpd/ch_malloc.c b/servers/slurpd/ch_malloc.c index 298391e4f3..22b83b9f4d 100644 --- a/servers/slurpd/ch_malloc.c +++ b/servers/slurpd/ch_malloc.c @@ -14,6 +14,8 @@ * ch_malloc.c - malloc() and friends, with check for NULL return. */ +#include "portable.h" + #include #include #include diff --git a/servers/slurpd/config.c b/servers/slurpd/config.c index 7a8261e849..617943cbac 100644 --- a/servers/slurpd/config.c +++ b/servers/slurpd/config.c @@ -15,6 +15,8 @@ * config.c - configuration file handling routines */ +#include "portable.h" + #include #include #include diff --git a/servers/slurpd/detach.c b/servers/slurpd/detach.c index 7b3fdab57a..bb28bc96a2 100644 --- a/servers/slurpd/detach.c +++ b/servers/slurpd/detach.c @@ -10,6 +10,8 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include #include #ifdef SVR4 @@ -39,6 +41,12 @@ detach() nbits = getdtablesize(); #endif /* USE_SYSCONF */ +#ifdef FD_SETSIZE + if ( nbits > FD_SETSIZE ) { + nbits = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ + #ifdef LDAP_DEBUG if ( ldap_debug == 0 ) { #endif diff --git a/servers/slurpd/fm.c b/servers/slurpd/fm.c index e517cb665a..14815549d9 100644 --- a/servers/slurpd/fm.c +++ b/servers/slurpd/fm.c @@ -14,7 +14,6 @@ * fm.c - file management routines. */ -#define DISABLE_BRIDGE #include "portable.h" #include diff --git a/servers/slurpd/globals.c b/servers/slurpd/globals.c index f8630323cb..89403fc490 100644 --- a/servers/slurpd/globals.c +++ b/servers/slurpd/globals.c @@ -14,6 +14,8 @@ * globals.c - initialization code for global data */ +#include + #include #include "slurp.h" diff --git a/servers/slurpd/globals.h b/servers/slurpd/globals.h index 5d976ff8a4..1582d1780d 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_LWP_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/ldap_op.c b/servers/slurpd/ldap_op.c index 487f7466cc..90ef27449f 100644 --- a/servers/slurpd/ldap_op.c +++ b/servers/slurpd/ldap_op.c @@ -14,7 +14,6 @@ * ldap_op.c - routines to perform LDAP operations */ -#define DISABLE_BRIDGE #include "portable.h" #include diff --git a/servers/slurpd/lock.c b/servers/slurpd/lock.c index 62aab06784..6e14c1bfa0 100644 --- a/servers/slurpd/lock.c +++ b/servers/slurpd/lock.c @@ -14,6 +14,8 @@ * lock.c - routines to open and apply an advisory lock to a file */ +#include "portable.h" + #include #include #include diff --git a/servers/slurpd/main.c b/servers/slurpd/main.c index a3b935faa5..1cd84b06ee 100644 --- a/servers/slurpd/main.c +++ b/servers/slurpd/main.c @@ -15,6 +15,8 @@ * main.c - main routine for slurpd. */ +#include "portable.h" + #include #include "slurp.h" @@ -121,6 +123,21 @@ main( * Start the main file manager thread (in fm.c). */ pthread_attr_init( &attr ); +#ifndef THREAD_MIT_PTHREADS + /* POSIX_THREADS or compatible + * This is a draft 10 or standard pthreads implementation + */ + if ( pthread_create( &(sglob->fm_tid), &attr, (void *) fm, (void *) NULL ) + != 0 ) { + Debug( LDAP_DEBUG_ANY, "file manager pthread_create failed\n", + 0, 0, 0 ); + exit( 1 ); + + } +#else /* !THREAD_MIT_PTHREADS */ + /* + * This is a draft 4 or earlier pthreads implementation + */ if ( pthread_create( &(sglob->fm_tid), attr, (void *) fm, (void *) NULL ) != 0 ) { Debug( LDAP_DEBUG_ANY, "file manager pthread_create failed\n", @@ -128,17 +145,26 @@ main( exit( 1 ); } +#endif /* !THREAD_MIT_PTHREADS */ pthread_attr_destroy( &attr ); /* * Wait for the fm thread to finish. */ +#ifdef POSIX_THREADS + 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 POSIX_THREADS + 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; diff --git a/servers/slurpd/re.c b/servers/slurpd/re.c index f8ec36d038..64f9225ddb 100644 --- a/servers/slurpd/re.c +++ b/servers/slurpd/re.c @@ -18,7 +18,6 @@ */ -#define DISABLE_BRIDGE #include "portable.h" #include diff --git a/servers/slurpd/reject.c b/servers/slurpd/reject.c index 6ba2c8e34c..95ae7b7e62 100644 --- a/servers/slurpd/reject.c +++ b/servers/slurpd/reject.c @@ -17,7 +17,6 @@ * to a replica LDAP server. */ -#define DISABLE_BRIDGE #include "portable.h" #include diff --git a/servers/slurpd/replica.c b/servers/slurpd/replica.c index ed25a62907..38da5edaf8 100644 --- a/servers/slurpd/replica.c +++ b/servers/slurpd/replica.c @@ -15,6 +15,7 @@ * replica.c - code to start up replica threads. */ +#include "portable.h" #include @@ -57,8 +58,26 @@ start_replica_thread( pthread_attr_t attr; pthread_attr_init( &attr ); +#ifdef NOTDEF + /* if main wants to join with us, we shouldn't detach */ pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED ); +#endif +#ifndef THREAD_MIT_PTHREADS + /* POSIX_THREADS or compatible + * This is a draft 10 or standard pthreads implementation + */ + if ( pthread_create( &(ri->ri_tid), &attr, (void *) replicate, + (void *) ri ) != 0 ) { + Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n", + ri->ri_hostname, ri->ri_port, 0 ); + pthread_attr_destroy( &attr ); + return -1; + } +#else /* !THREAD_MIT_PTHREADS */ + /* + * This is a draft 4 or earlier pthreads implementation + */ if ( pthread_create( &(ri->ri_tid), attr, (void *) replicate, (void *) ri ) != 0 ) { Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n", @@ -66,6 +85,7 @@ start_replica_thread( pthread_attr_destroy( &attr ); return -1; } +#endif /* !THREAD_MIT_PTHREADS */ pthread_attr_destroy( &attr ); return 0; } diff --git a/servers/slurpd/replog.c b/servers/slurpd/replog.c index eb53bf1053..a9ecdb7ecc 100644 --- a/servers/slurpd/replog.c +++ b/servers/slurpd/replog.c @@ -15,10 +15,8 @@ * replog.c - routines which read and write replication log files. */ -#define DISABLE_BRIDGE #include "portable.h" - #include #include #include diff --git a/servers/slurpd/ri.c b/servers/slurpd/ri.c index cc478d1e6a..e11fc30f7b 100644 --- a/servers/slurpd/ri.c +++ b/servers/slurpd/ri.c @@ -17,6 +17,7 @@ */ +#include "portable.h" #include #include @@ -60,7 +61,11 @@ Ri_process( int rc ; char *errmsg; +#ifdef SIGSTKFLT + (void) SIGNAL( SIGSTKFLT, (void *) do_nothing ); +#else (void) SIGNAL( SIGUSR1, (void *) do_nothing ); +#endif (void) SIGNAL( SIGPIPE, SIG_IGN ); if ( ri == NULL ) { Debug( LDAP_DEBUG_ANY, "Error: Ri_process: ri == NULL!\n", 0, 0, 0 ); @@ -146,7 +151,8 @@ Ri_process( /* - * Wake a replication thread which may be sleeping. Send it a SIGUSR1. + * Wake a replication thread which may be sleeping. + * Send it a SIG(STKFLT|USR1). */ static void Ri_wake( @@ -156,8 +162,13 @@ Ri_wake( if ( ri == NULL ) { return; } +#ifdef SIGSTKFLT + pthread_kill( ri->ri_tid, SIGSTKFLT ); + (void) SIGNAL( SIGSTKFLT, (void *) do_nothing ); +#else pthread_kill( ri->ri_tid, SIGUSR1 ); (void) SIGNAL( SIGUSR1, (void *) do_nothing ); +#endif } diff --git a/servers/slurpd/rq.c b/servers/slurpd/rq.c index 845a7a7d34..260872b7d9 100644 --- a/servers/slurpd/rq.c +++ b/servers/slurpd/rq.c @@ -31,7 +31,6 @@ * */ -#define DISABLE_BRIDGE #include "portable.h" #include diff --git a/servers/slurpd/sanity.c b/servers/slurpd/sanity.c index 04be7db86a..240e479e4a 100644 --- a/servers/slurpd/sanity.c +++ b/servers/slurpd/sanity.c @@ -18,6 +18,8 @@ * feedback to the users. */ +#include "portable.h" + #include #include #include diff --git a/servers/slurpd/slurp.h b/servers/slurpd/slurp.h index 622cd38374..d493745d22 100644 --- a/servers/slurpd/slurp.h +++ b/servers/slurpd/slurp.h @@ -17,6 +17,8 @@ #define LDAP_SYSLOG +#include "portable.h" + #include #include #include @@ -24,7 +26,6 @@ #include "lber.h" #include "ldap.h" #include "lthread.h" -#include "portable.h" #include "ldapconfig.h" #include "ldif.h" @@ -135,6 +136,7 @@ #define RETRY_SLEEP_TIME 60 +LDAP_BEGIN_DECL /* * **************************************************************************** @@ -335,15 +337,11 @@ typedef struct tsl { /* * Public functions used to instantiate and initialize queue objects. */ -#ifdef NEEDPROTOS -extern int Ri_init( Ri **ri ); -extern int Rq_init( Rq **rq ); -extern int Re_init( Re **re ); -#else /* NEEDPROTOS */ -extern int Ri_init(); -extern int Rq_init(); -extern int Re_init(); -#endif /* NEEDPROTOS */ +extern int Ri_init LDAP_P(( Ri **ri )); +extern int Rq_init LDAP_P(( Rq **rq )); +extern int Re_init LDAP_P(( Re **re )); + +LDAP_END_DECL #endif /* _SLURPD_H_ */ diff --git a/servers/slurpd/st.c b/servers/slurpd/st.c index a274674f35..64029e2dbb 100644 --- a/servers/slurpd/st.c +++ b/servers/slurpd/st.c @@ -16,7 +16,6 @@ * writing status information to disk. */ -#define DISABLE_BRIDGE #include "portable.h" #include diff --git a/servers/slurpd/tsleep.c b/servers/slurpd/tsleep.c index 5dc3ba3dea..3cb34708e4 100644 --- a/servers/slurpd/tsleep.c +++ b/servers/slurpd/tsleep.c @@ -24,6 +24,7 @@ * is so much simpler... */ +#include "portable.h" #include #include "slurp.h"