# -------------------------------------------------------------------------
# you will probably not need to edit anything below this point
# -------------------------------------------------------------------------
-CC = gcc
+CC = cc
PLATFORMCFLAGS= -Dfreebsd
+
+# uncomment this line if using for LDAP_CRYPT
+#PLATFORMLIBS= -lcrypt
RANLIB = "ranlib"
PLATFORMCFLAGS= -Dlinux
+
+# uncomment this if -DLDAP_CRYPT is defined
+#PLATFORMLIBS= -lcrypt
* is provided ``as is'' without express or implied warranty.
*/
-
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/socket.h>
#include <sysexits.h>
#include <ldapconfig.h>
-#include "portable.h"
+#include "bridge.h"
#include "lber.h"
#include "ldap.h"
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
#include "lber.h"
#include "ldap.h"
#include "disptmpl.h"
#include <stdio.h>
-#include <string.h>
+#include <ac/string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netdb.h>
#include <syslog.h>
#include <sys/resource.h>
-#include <sys/wait.h>
+#include <ac/wait.h>
#ifdef aix
#include <sys/select.h>
#endif /* aix */
#include <signal.h>
-#include "portable.h"
+#include "bridge.h"
#include "ldapconfig.h"
#ifdef USE_SYSCONF
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/select.h>
#endif /* aix */
#include <signal.h>
-#include "portable.h"
+#include "bridge.h"
#include "ldapconfig.h"
#include "lber.h"
#include "ldap.h"
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include "lber.h"
#include "ldap.h"
#include "disptmpl.h"
#ifdef aix
#include <sys/select.h>
#endif /* aix */
-#include "portable.h"
+#include "bridge.h"
#include "ldapconfig.h"
#ifdef USE_SYSCONF
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sysexits.h>
-#include "portable.h"
+#include "bridge.h"
#include "lber.h"
#include "ldap.h"
* All Rights Reserved
*/
+#include "portable.h"
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <string.h>
#include <ctype.h>
-#include "portable.h"
+#include "bridge.h"
#include "ldapconfig.h"
#include "rcpt500.h"
#include <termios.h>
#endif /* defined( NeXT ) || defined( ultrix ) etc. */
#endif /* !DOS */
-#if defined( aix ) || defined( __NetBSD__ )
+#if defined( aix ) || defined( __NetBSD__ ) \
+ || defined( __FreeBSD__ ) || defined( linux )
#include <sys/ioctl.h>
#endif /* aix || __NetBSD__ */
#include <ctype.h>
#include <stdio.h>
#include <signal.h>
-#include "ldap_string.h"
+#include <ac/string.h>
#ifdef DOS
#include <malloc.h>
#endif
#if !defined(DOS) && !defined(VMS)
#include <sys/types.h>
#endif
-
+#include "bridge.h"
#ifdef USE_TERMIOS
#include <termios.h>
#else /* USE_TERMIOS */
#endif /* USE_TERMIOS */
#include "ud.h"
-#include "bridge.h"
-
#if defined(VMS)
#define getch getchar
#endif
#ifndef _LTHREAD_H
#define _LTHREAD_H
-#if defined( THREAD_SUNOS4_LWP )
+#if defined ( THREAD_NEXT_CTHREADS )
+
+#define _THREAD
+
+#include <mach/cthreads.h>
+
+typedef cthread_fn_t VFP;
+typedef int pthread_attr_t;
+typedef cthread_t pthread_t;
+
+/* default attr states */
+#define pthread_mutexattr_default NULL
+#define pthread_condattr_default NULL
+
+/* thread state - joinable or not */
+#define PTHREAD_CREATE_JOINABLE 0
+#define PTHREAD_CREATE_DETACHED 1
+/* thread scope - who is in scheduling pool */
+#define PTHREAD_SCOPE_PROCESS 0
+#define PTHREAD_SCOPE_SYSTEM 1
+
+/* mutex attributes and mutex type */
+typedef int pthread_mutexattr_t;
+typedef struct mutex pthread_mutex_t;
+
+/* mutex and condition variable scope - process or system */
+#define PTHREAD_SHARE_PRIVATE 0
+#define PTHREAD_SHARE_PROCESS 1
+
+/* condition variable attributes and condition variable type */
+typedef int pthread_condattr_t;
+typedef struct condition pthread_cond_t;
+
+#elif defined( THREAD_SUNOS4_LWP )
/***********************************
* *
* thread definitions for sunos4 *
#define pthread_attr_setdetachstate( a, b ) \
pthread_attr_setdetach_np( a, b )
+#else /* end dce pthreads */
+
+#if defined( POSIX_THREADS )
+
+#define _THREAD
+
+#include <pthread.h>
+
+#define pthread_mutexattr_default NULL
+#define pthread_condattr_default NULL
+
+#endif /* posix threads */
#endif /* dce pthreads */
#endif /* mit pthreads */
#endif /* sunos5 */
#include <stdio.h>
#include "lthread.h"
-#if defined( THREAD_SUNOS4_LWP )
+#if defined( THREAD_NEXT_CTHREADS )
+
+/***********************************************************************
+ * *
+ * under NEXTSTEP or OPENSTEP use CThreads *
+ * lukeh@xedoc.com.au *
+ * *
+ ***********************************************************************/
+
+int
+pthread_attr_init( pthread_attr_t *attr )
+{
+ *attr = 0;
+ return( 0 );
+}
+
+int
+pthread_attr_destroy( pthread_attr_t *attr )
+{
+ return( 0 );
+}
+
+int
+pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate )
+{
+ *detachstate = *attr;
+ return( 0 );
+}
+
+int
+pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate )
+{
+ *attr = detachstate;
+ return( 0 );
+}
+
+/* ARGSUSED */
+int
+pthread_create(
+ pthread_t *tid,
+ pthread_attr_t attr,
+ VFP func,
+ void *arg
+)
+{
+ *tid = cthread_fork(func, arg);
+ return ( *tid == NULL ? -1 : 0 );
+}
+
+void
+pthread_yield()
+{
+ cthread_yield();
+}
+
+void
+pthread_exit( any_t a )
+{
+ cthread_exit( a );
+}
+
+void
+pthread_join( pthread_t tid, int *pStatus )
+{
+ int status;
+ status = (int) cthread_join ( tid );
+ if (pStatus != NULL)
+ {
+ *pStatus = status;
+ }
+}
+
+/* ARGSUSED */
+void
+pthread_kill( pthread_t tid, int sig )
+{
+ return;
+}
+
+/* ARGSUSED */
+int
+pthread_mutex_init( pthread_mutex_t *mp, pthread_mutexattr_t *attr )
+{
+ mutex_init( mp );
+ mp->name = NULL;
+ return ( 0 );
+}
+
+int
+pthread_mutex_destroy( pthread_mutex_t *mp )
+{
+ mutex_clear( mp );
+ return ( 0 );
+}
+
+int
+pthread_mutex_lock( pthread_mutex_t *mp )
+{
+ mutex_lock( mp );
+ return ( 0 );
+}
+
+int
+pthread_mutex_unlock( pthread_mutex_t *mp )
+{
+ mutex_unlock( mp );
+ return ( 0 );
+}
+
+int
+pthread_mutex_trylock( pthread_mutex_t *mp )
+{
+ return mutex_try_lock( mp );
+}
+
+int
+pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr )
+{
+ condition_init( cv );
+ return( 0 );
+}
+
+int
+pthread_cond_destroy( pthread_cond_t *cv )
+{
+ condition_clear( cv );
+ return( 0 );
+}
+
+int
+pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp )
+{
+ condition_wait( cv, mp );
+ return( 0 );
+}
+
+int
+pthread_cond_signal( pthread_cond_t *cv )
+{
+ condition_signal( cv );
+ return( 0 );
+}
+
+int
+pthread_cond_broadcast( pthread_cond_t *cv )
+{
+ condition_broadcast( cv );
+ return( 0 );
+}
+
+#elif defined( THREAD_SUNOS4_LWP )
/***********************************************************************
* *
kill( getpid(), sig );
}
+#else
+
+#if defined ( POSIX_THREADS )
+
+void p_thread_yield( void )
+{
+ sched_yield();
+}
+
+#endif /* posix threads */
#endif /* dce pthreads */
#endif /* mit pthreads */
#endif /* sunos5 lwp */
/* acl.c - routines to parse and check acl's */
-
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <netdb.h>
#include "regex.h"
#include "slap.h"
-#include "portable.h"
+#include "bridge.h"
extern Filter *str2filter();
extern char *re_comp();
/* attr.c - routines for dealing with attributes */
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/stat.h>
-#include "portable.h"
+#include "bridge.h"
#include "slap.h"
extern char **charray_dup();
/* ldbmcache.c - maintain a cache of open ldbm files */
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <errno.h>
-#include "portable.h"
+#include "bridge.h"
#include "slap.h"
#include "ldapconfig.h"
#include "back-ldbm.h"
}
char **
-str2charray( char *str, char *brkstr )
+str2charray( char *str_in, char *brkstr )
{
char **res;
char *s;
int i;
+ /* protect the input string from strtok */
+ char *str = strdup( str_in );
+
i = 1;
for ( s = str; *s; s++ ) {
if ( strchr( brkstr, *s ) != NULL ) {
}
res[i] = NULL;
+ free( str );
return( res );
}
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <errno.h>
#include <signal.h>
-#include "portable.h"
+#include "bridge.h"
#include "slap.h"
extern Operation *op_add();
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
- if ( pthread_create( &arg->co_op->o_tid, attr,
+ if ( pthread_create( &arg->co_op->o_tid, &attr,
(void *) connection_operation, (void *) arg ) != 0 ) {
Debug( LDAP_DEBUG_ANY, "pthread_create failed\n", 0, 0, 0 );
} else {
+
+/* Revision history
+ *
+ * 5-Jun-96 hodges
+ * Added locking of new_conn_mutex when traversing the c[] array.
+ */
+
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/select.h>
#endif
#include "slap.h"
-#include "portable.h"
+#include "bridge.h"
#include "ldapconfig.h"
#ifdef NEED_FILIO
#include <sys/filio.h>
static void do_nothing();
void
-daemon(
+slapd_daemon(
int port
)
{
#else /* USE_SYSCONF */
dtblsize = getdtablesize();
#endif /* USE_SYSCONF */
-
+ /*
+ * Add greg@greg.rim.or.jp
+ */
+ if(dtblsize > FD_SETSIZE) {
+ dtblsize = FD_SETSIZE;
+ }
c = (Connection *) ch_calloc( 1, dtblsize * sizeof(Connection) );
for ( i = 0; i < dtblsize; i++ ) {
}
(void) SIGNAL( SIGPIPE, SIG_IGN );
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
+#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
+#endif
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGUNUSED, (void *) set_shutdown );
+#else
(void) SIGNAL( SIGUSR2, (void *) set_shutdown );
+#endif
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
+ (void) SIGNAL( SIGINT, (void *) set_shutdown );
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 );
Debug( LDAP_DEBUG_CONNS,
"listening for connections on %d, activity on:",
tcps, 0, 0 );
+
+ pthread_mutex_lock( &new_conn_mutex );
for ( i = 0; i < dtblsize; i++ ) {
if ( c[i].c_sb.sb_sd != -1 ) {
FD_SET( c[i].c_sb.sb_sd, &readfds );
}
}
Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
+ pthread_mutex_unlock( &new_conn_mutex );
zero.tv_sec = 0;
zero.tv_usec = 0;
{
Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal\n", 0, 0, 0 );
slapd_shutdown = 1;
+#ifdef SIGSTKFLT
+ pthread_kill( listener_tid, SIGSTKFLT );
+#else
pthread_kill( listener_tid, SIGUSR1 );
+#endif
+#ifdef SIGUNUSED
+ (void) SIGNAL( SIGUNUSED, (void *) set_shutdown );
+#else
(void) SIGNAL( SIGUSR2, (void *) set_shutdown );
+#endif
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
+ (void) SIGNAL( SIGINT, (void *) set_shutdown );
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
}
static void
do_nothing()
{
- Debug( LDAP_DEBUG_TRACE, "slapd got SIGUSR1\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal\n", 0, 0, 0 );
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
+#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
+#endif
}
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
#include <stdio.h>
#include <sys/types.h>
#ifdef SVR4
#include <sys/file.h>
#include <sys/ioctl.h>
#include <signal.h>
-#include "portable.h"
+#include "bridge.h"
#ifdef USE_SYSCONF
#include <unistd.h>
/* 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 "bridge.h"
#include "slap.h"
static char **dn_explode();
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
-#include "portable.h"
+#include "bridge.h"
#include "slap.h"
#include "ldapconfig.h"
-extern void daemon();
+extern void slapd_daemon();
extern int lber_debug;
extern char Versionstr[];
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
- if ( pthread_create( &listener_tid, attr, (void *) daemon,
+ if ( pthread_create( &listener_tid, &attr, (void *) slapd_daemon,
(void *) port ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"listener pthread_create failed\n", 0, 0, 0 );
/* phonetic.c - routines to do phonetic matching */
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include "portable.h"
+#include "bridge.h"
#include "slap.h"
#if !defined(METAPHONE) && !defined(SOUNDEX)
/* result.c - routines to send ldap results, errors, and referrals */
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <errno.h>
#include <signal.h>
-#include "portable.h"
+#include "bridge.h"
#include "slap.h"
#ifndef SYSERRLIST_IN_STDIO
pthread_mutex_lock( &active_threads_mutex );
active_threads--;
conn->c_writewaiter = 1;
+#ifdef SIGSTKFLT
+ pthread_kill( listener_tid, SIGSTKFLT );
+#else
pthread_kill( listener_tid, SIGUSR1 );
+#endif
pthread_cond_wait( &conn->c_wcv, &active_threads_mutex );
pthread_mutex_unlock( &active_threads_mutex );
#include "portable.h"
#include <stdio.h>
-#include "ldap_string.h"
+#include <ac/string.h>
#include <ctype.h>
-#include "ldap_time.h"
+#include <ac/time.h>
#include <lber.h>
#include <ldap.h>
#include "portable.h"
#include <stdio.h>
-#include "ldap_string.h"
+#include <ac/string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include "ldap_time.h"
+#include <ac/time.h>
#include <sys/resource.h>
-#include "ldap_wait.h"
+#include <ac/wait.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <limits.h>
#include "portable.h"
#include <stdio.h>
-#include "ldap_string.h"
+#include <ac/string.h>
#include <memory.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "portable.h"
#include <stdio.h>
-#include "ldap_string.h"
+#include <ac/string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "../slap.h"
#include "portable.h"
#include <stdio.h>
-#include "ldap_string.h"
+#include <ac/string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "../slap.h"
#include "portable.h"
#include <stdio.h>
-#include "ldap_string.h"
+#include <ac/string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "../slap.h"
#include "portable.h"
#include <stdio.h>
-#include "ldap_string.h"
+#include <ac/string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
/* value.c - routines for dealing with values */
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
-#include "portable.h"
+#include "bridge.h"
#include "slap.h"
int
*/
+#include "portable.h"
+
#include <stdio.h>
#include <signal.h>
#include "slurp.h"
#include "globals.h"
+#include "bridge.h"
/*
* Eventually, do_admin will be the entry point for performing
* args.c - process command-line arguments, and set appropriate globals.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
#include "slurp.h"
#include "globals.h"
+#include "bridge.h"
+
static int
usage( char *name )
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
#include <stdio.h>
#include <sys/types.h>
#ifdef SVR4
#include <sys/file.h>
#include <sys/ioctl.h>
#include <signal.h>
-#include "portable.h"
+#include "bridge.h"
#ifdef USE_SYSCONF
#include <unistd.h>
* fm.c - file management routines.
*/
+#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include "slurp.h"
#include "globals.h"
+#include "bridge.h"
+
extern void do_admin();
static void set_shutdown();
/* Set up our signal handlers:
* SIG{TERM,INT,HUP} causes a shutdown
- * SIGUSR1 - does nothing, used to wake up sleeping threads.
- * SIGUSR2 - causes slurpd to read its administrative interface file.
+ * SIG(STKFLT|USR1) - does nothing, used to wake up sleeping threads.
+ * SIG(UNUSED|USR2) - causes slurpd to read its administrative interface file.
* (not yet implemented).
*/
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
+#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
+#endif
+#ifdef SIGUNUSED
+ (void) SIGNAL( SIGUNUSED, (void *) do_admin );
+#else
(void) SIGNAL( SIGUSR2, (void *) do_admin );
+#endif
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
(void) SIGNAL( SIGINT, (void *) set_shutdown );
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
int i;
sglob->slurpd_shutdown = 1; /* set flag */
+#ifdef SIGSTKFLT
+ pthread_kill( sglob->fm_tid, SIGSTKFLT ); /* wake up file mgr */
+#else
pthread_kill( sglob->fm_tid, SIGUSR1 ); /* wake up file mgr */
+#endif
sglob->rq->rq_lock( sglob->rq ); /* lock queue */
pthread_cond_broadcast( &(sglob->rq->rq_more) ); /* wake repl threads */
for ( i = 0; i < sglob->num_replicas; i++ ) {
void
do_nothing()
{
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
+#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
+#endif
}
* Start the main file manager thread (in fm.c).
*/
pthread_attr_init( &attr );
- if ( pthread_create( &(sglob->fm_tid), attr, (void *) fm, (void *) NULL )
+ if ( pthread_create( &(sglob->fm_tid), &attr, (void *) fm, (void *) NULL )
!= 0 ) {
Debug( LDAP_DEBUG_ANY, "file manager pthread_create failed\n",
0, 0, 0 );
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
- if ( pthread_create( &(ri->ri_tid), attr, (void *) replicate,
+ 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 );
* instance. The Ri struct is defined in slurp.h
*/
-
+#include "portable.h"
#include <stdio.h>
#include <signal.h>
#include "slurp.h"
#include "globals.h"
+#include "bridge.h"
/* External references */
#ifdef NEEDPROTOS
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
}