Leave the following blank line there!! Autoheader needs it. */
\f
+/* 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
fi
])
if test $ol_cv_berkeley_db2 = yes ; then
- AC_DEFINE(HAVE_BERKELEY_DB2)
+ AC_DEFINE(HAVE_BERKELEY_DB2,1)
fi
])dnl
dnl
fi
])
if test $ol_cv_berkeley_db = yes ; then
- AC_DEFINE(HAVE_BERKELEY_DB)
+ AC_DEFINE(HAVE_BERKELEY_DB,1)
fi
])dnl
dnl
fi
])
if test $ol_cv_gdbm = yes ; then
- AC_DEFINE(HAVE_GDBM)
+ AC_DEFINE(HAVE_GDBM,1)
fi
])dnl
dnl
fi
])
if test $ol_cv_ndbm = yes ; then
- AC_DEFINE(HAVE_NDBM)
+ AC_DEFINE(HAVE_NDBM,1)
fi
])dnl
dnl
])
])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 <ctypes.h>
+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.
# 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 <errno.h>],
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 "(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 <<EOF
-#line 5442 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/param.h>
-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 <<EOF
-#line 5457 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/param.h>
-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*
+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
- 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 <<EOF
-#line 5488 "configure"
+#line 5445 "configure"
#include "confdefs.h"
-main () {
- /* Are we little or big endian? From Harbison&Steele. */
- union
- {
- long l;
- char c[sizeof (long)];
- } u;
- u.l = 1;
- exit (u.c[sizeof (long) - 1] == 1);
+
+#include <ctypes.h>
+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 <<EOF
-#line 5530 "configure"
+#line 5485 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:5579: \"$ac_compile\") 1>&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
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
ac_cv_func_memcmp_clean=no
else
cat > conftest.$ac_ext <<EOF
-#line 5610 "configure"
+#line 5565 "configure"
#include "confdefs.h"
main()
}
EOF
-if { (eval echo configure:5620: \"$ac_link\") 1>&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
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 <<EOF
-#line 5643 "configure"
+#line 5598 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char strftime(); below. */
; return 0; }
EOF
-if { (eval echo configure:5666: \"$ac_link\") 1>&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
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
ac_save_LIBS="$LIBS"
LIBS="-lintl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 5696 "configure"
+#line 5651 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
strftime()
; return 0; }
EOF
-if { (eval echo configure:5707: \"$ac_link\") 1>&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
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 <<EOF
-#line 5739 "configure"
+#line 5694 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vprintf(); below. */
; return 0; }
EOF
-if { (eval echo configure:5762: \"$ac_link\") 1>&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
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 <<EOF
-#line 5791 "configure"
+#line 5746 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char _doprnt(); below. */
; return 0; }
EOF
-if { (eval echo configure:5814: \"$ac_link\") 1>&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
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
ac_cv_func_wait3_rusage=no
else
cat > conftest.$ac_ext <<EOF
-#line 5847 "configure"
+#line 5802 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
}
}
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
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 <<EOF
-#line 5935 "configure"
+#line 5890 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:5958: \"$ac_link\") 1>&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
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 <<EOF
-#line 5991 "configure"
+#line 5946 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:6014: \"$ac_link\") 1>&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
# 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 <<EOF
-#line 6050 "configure"
+#line 6005 "configure"
#include "confdefs.h"
#include <stdio.h>
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
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 <<EOF
-#line 6087 "configure"
+#line 6042 "configure"
#include "confdefs.h"
#include <errno.h>
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
AC_HEADER_TIME
AC_STRUCT_TM
-AC_C_BIGENDIAN
+OL_C_UPPER_LOWER
AC_C_CONST
dnl AC_CHECK_SIZEOF(short)
/* Define to `int' if <sys/types.h> 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
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include <ac/socket.h>
+
#include "slap.h"
extern Backend *select_backend();
/* acl.c - routines to parse and check acl's */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* acl.c - routines to parse and check acl's */
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
-#include "regex.h"
+#include <unistd.h>
+#include <regex.h>
+
#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();
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,
}
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;
}
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;
free( alist );
} else {
fprintf( stderr,
- "%s: line %d: expecting <what> got \"%s\"\n",
+ "%s: line %d: expecting <what> got \"%s\"\n",
fname, lineno, left );
acl_usage();
}
} 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();
}
} 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,
/* 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 );
}
}
}
-#endif
+#endif /* LDAP_DEBUG */
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <time.h>
/* attr.c - routines for dealing with attributes */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
/* ava.c - routines for dealing with attribute value assertions */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* abandon.c - ldbm backend abandon routine */
+#include "portable.h"
+
ldbm_back_abandon()
{
}
/* add.c - ldap ldbm back-end add routine */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* attr.c - backend routines for dealing with attributes */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#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
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_ */
/* bind.c - ldbm backend bind and unbind routines */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* cache.c - routines to maintain an in-core cache of entries */
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
/* close.c - close ldbm backend */
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
/* compare.c - ldbm backend compare routine */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* config.c - ldbm backend configuration file routine */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
}
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,
/* ldbmcache.c - maintain a cache of open ldbm files */
-#define DISABLE_BRIDGE /* disable LDAP_BRIDGE code */
#include "portable.h"
#include <stdio.h>
/* delete.c - ldbm backend delete routine */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* dn2id.c - routines to deal with the dn2id index */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* filterindex.c - generate the list of candidate entries from a filter */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* compare.c - ldbm backend compare routine */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* id2children.c - routines to deal with the id2children index */
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
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 );
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,
/* id2entry.c - routines to deal with the id2entry index */
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
/* idl.c - ldap id list handling routines */
-#define DISABLE_BRIDGE
#include "portable.h"
#include <stdio.h>
/* index.c - routines for dealing with attribute indexes */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
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 );
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 );
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 );
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;
/* init.c - initialize ldbm backend */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
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) );
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,
/* kerberos.c - ldbm backend kerberos bind routines */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* modify.c - ldbm backend modify routine */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* modrdn.c - ldbm backend modrdn routine */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* id.c - keep track of the next id to be given out */
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#ifndef _PROTO_BACK_LDBM
#define _PROTO_BACK_LDBM
+#include <ldap_cdefs.h>
+
+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
/* search.c - ldbm backend search function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* unbind.c - handle an ldap unbind operation */
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
/* config.c - passwd backend configuration file routine */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
/* search.c - /etc/passwd backend search function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
/* abandon.c - shell backend abandon function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* add.c - shell backend add function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* bind.c - shell backend bind function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* compare.c - shell backend compare function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* config.c - shell backend configuration file routine */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* delete.c - shell backend delete function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* fork.c - fork and exec a process, connecting stdin/out w/pipes */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* init.c - initialize shell backend */
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
/* modify.c - shell backend modify function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* modrdn.c - shell backend modrdn function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* result.c - shell backend result reading function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* search.c - shell backend search function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* shell.h - shell backend header file */
+#ifndef SLAPD_SHELL_H
+#define SLAPD_SHELL_H
+
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
+
struct shellinfo {
char **si_bind; /* cmd + args to exec for bind */
char **si_unbind; /* cmd + args to exec for unbind */
char **si_delete; /* cmd + args to exec for delete */
char **si_abandon; /* cmd + args to exec for abandon */
};
+
+LDAP_END_DECL
+
+#endif
/* unbind.c - shell backend unbind function */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* backend.c - routines for dealing with back-end databases */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
extern int ldbm_back_config();
extern int ldbm_back_init();
extern int ldbm_back_close();
+extern int ldbm_back_group();
#endif
#ifdef LDAP_PASSWD
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;
}
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;
}
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;
}
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 ) {
}
}
}
+
+#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
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* ch_malloc.c - malloc routines that test returns from malloc and friends */
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
/* charray.c - routines for dealing with char * arrays */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
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 ) {
}
res[i] = NULL;
+ free( str );
return( res );
}
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
/* config.c - configuration file handling routines */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
-#define DISABLE_BRIDGE
#include "portable.h"
#include <stdio.h>
* Added locking of new_conn_mutex when traversing the c[] array.
*/
-#define DISABLE_BRIDGE /* disable bridge code */
#include "portable.h"
#include <stdio.h>
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#ifdef SVR4
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
/* dn.c - routines for dealing with distinguished names */
+#include "portable.h"
+
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include "portable.h"
#include "slap.h"
static char **dn_explode();
}
}
- return( NULL );
+ return( strdup("") );
}
/*
/* entry.c - routines for dealing with entries */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
/* filter.c - routines for parsing and dealing with filters */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
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 );
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 );
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 );
/* filterentry.c - apply a filter to an entry */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
-#ifdef sunos5
-#include "regexpr.h"
-#else
-#include "regex.h"
-#endif
+#include <regex.h>
#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();
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
char pat[BUFSIZ];
char buf[BUFSIZ];
struct berval *val;
+ regex_t re;
Debug( LDAP_DEBUG_FILTER, "begin test_substring_filter\n", 0, 0, 0 );
}
/* 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++ ) {
}
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 );
/* init.c - initialize various things */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
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()
{
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
}
/* lock.c - routines to open and apply an advisory lock to a file */
+#include "portable.h"
+
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#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
*/
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 )
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;
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 );
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <time.h>
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
* Added locking of currenttime_mutex to protect call(s) to localtime().
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <time.h>
/* operation.c - routines to deal with pending ldap operations */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* phonetic.c - routines to do phonetic matching */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifndef _PROTO_SLAP
#define _PROTO_SLAP
+#include <ldap_cdefs.h>
+
/*
* 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 */
/* repl.c - log modifications for replication purposes */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
/* result.c - routines to send ldap results, errors, and referrals */
-#define DISABLE_BRIDGE
#include "portable.h"
#include <stdio.h>
/* schema.c - routines to enforce schema definitions */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
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 */
/* 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 )
/* schemaparse.c - routines to parse config file objectclass definitions */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
*/
+#include "portable.h"
+
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
*/
+#include "portable.h"
+
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
is provided ``as is'' without express or implied warranty.
*/
+#ifndef SHELLUTIL_H
+#define SHELLUTIL_H
+
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
#define MAXLINELEN 512
*/
extern int debugflg;
extern char *progname;
+
+LDAP_END_DECL
+#endif
#ifndef _SLDAPD_H_
#define _SLDAPD_H_
-#define LDAP_SYSLOG
+#include "portable.h"
+
+#include <stdlib.h>
-#include <syslog.h>
#include <sys/types.h>
-#include <regex.h>
+#include <ac/syslog.h>
+#include <ac/regex.h>
+
#undef NDEBUG
#include <assert.h>
#define MAXREMATCHES 10
+LDAP_BEGIN_DECL
+
/*
* represents an attribute value assertion (i.e., attr=value)
*/
char *a_dnattr;
long a_access;
-#ifdef ACLGROUP
+#ifdef SLAPD_ACLGROUP
char *a_group;
#endif
/* 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 */
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 */
#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
#endif
-#ifdef NEEDPROTOS
#include "proto-slap.h"
-#endif
+
+LDAP_END_DECL
#endif /* _slap_h_ */
/* str2filter.c - parse an rfc 1588 string filter */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
+#include "portable.h"
+
#if defined( ultrix ) || defined( nextstep )
#include <string.h>
-
char *strdup( char *s )
{
char *p;
+#include "portable.h"
+
#if defined( nextstep )
#include <string.h>
/* centipede.c - generate and install indexing information (view w/tabstop=4) */
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
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 );
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 );
}
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 ) {
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 ) {
ldbm_datum_free( oldbm, olast );
}
olast = okey;
+
+#ifdef LDBM_USE_DB2
+ okey = ldbm_nextkey( oldbm, olast, ocursorp );
+#else
okey = ldbm_nextkey( oldbm, olast );
+#endif
}
}
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 );
}
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 );
}
/* 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 );
/* 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 );
char **vals;
int vcur, vmax;
+#ifdef LDBM_USE_DB2
+ DBC *cursorp;
+#endif
+
if ( verbose ) {
printf( "Generating mods for full %s centroid...", attr );
fflush( stdout );
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 );
* slapd/slurpd locking conventions.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <dirent.h>
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
* is provided ``as is'' without express or implied warranty.
*/
+#ifndef LDAPSYNTAX_H
+#define LDAPSYNTAX_H 1
+
+#include <ldap_cdefs.h>
+
+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
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
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] );
}
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 );
-#define DISABLE_BRIDGE
#include "portable.h"
#include <stdio.h>
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <memory.h>
{
char buf[BUFSIZ];
char *type, *out;
- int binary = 0;
+ int len, binary = 0;
if (argc < 2 || argc > 3 ) {
usage( argv[0] );
}
/* 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" );
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
#include "../slap.h"
#include "ldapconfig.h"
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/param.h>
#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"
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];
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 */
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 );
*/
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 );
*/
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 );
*/
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 );
+#include "portable.h"
+
#include <stdio.h>
#include <ldbm.h>
#include <lber.h>
*
*/
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
/* value.c - routines for dealing with values */
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
* reconfiguration of slurpd.
*/
+#include "portable.h"
#include <stdio.h>
#include <signal.h>
* args.c - process command-line arguments, and set appropriate globals.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
+#include <time.h>
#include <lber.h>
#include <ldap.h>
* ch_malloc.c - malloc() and friends, with check for NULL return.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
* config.c - configuration file handling routines
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <sys/types.h>
#ifdef SVR4
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
* fm.c - file management routines.
*/
-#define DISABLE_BRIDGE
#include "portable.h"
#include <stdio.h>
* globals.c - initialization code for global data
*/
+#include <portable.h>
+
#include <stdio.h>
#include "slurp.h"
* 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.
#include "slurp.h"
+LDAP_BEGIN_DECL
+
typedef struct globals {
/* Thread ID for file manager thread */
pthread_t fm_tid;
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 */
extern Globals *sglob;
+
+LDAP_END_DECL
+
+#endif /* SLURPD_GLOBALS_H */
* ldap_op.c - routines to perform LDAP operations
*/
-#define DISABLE_BRIDGE
#include "portable.h"
#include <stdio.h>
* lock.c - routines to open and apply an advisory lock to a file
*/
+#include "portable.h"
+
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
* main.c - main routine for slurpd.
*/
+#include "portable.h"
+
#include <stdio.h>
#include "slurp.h"
* 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",
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;
*/
-#define DISABLE_BRIDGE
#include "portable.h"
#include <stdio.h>
* to a replica LDAP server.
*/
-#define DISABLE_BRIDGE
#include "portable.h"
#include <stdio.h>
* replica.c - code to start up replica threads.
*/
+#include "portable.h"
#include <stdio.h>
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",
pthread_attr_destroy( &attr );
return -1;
}
+#endif /* !THREAD_MIT_PTHREADS */
pthread_attr_destroy( &attr );
return 0;
}
* replog.c - routines which read and write replication log files.
*/
-#define DISABLE_BRIDGE
#include "portable.h"
-
#include <errno.h>
#include <stdio.h>
#include <syslog.h>
*/
+#include "portable.h"
#include <stdio.h>
#include <signal.h>
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 );
/*
- * 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(
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
}
*
*/
-#define DISABLE_BRIDGE
#include "portable.h"
#include <stdio.h>
* feedback to the users.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#define LDAP_SYSLOG
+#include "portable.h"
+
#include <syslog.h>
#include <errno.h>
#include <sys/types.h>
#include "lber.h"
#include "ldap.h"
#include "lthread.h"
-#include "portable.h"
#include "ldapconfig.h"
#include "ldif.h"
#define RETRY_SLEEP_TIME 60
+LDAP_BEGIN_DECL
/*
* ****************************************************************************
/*
* 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_ */
* writing status information to disk.
*/
-#define DISABLE_BRIDGE
#include "portable.h"
#include <stdio.h>
* is so much simpler...
*/
+#include "portable.h"
#include <stdio.h>
#include "slurp.h"