Add ldappasswd() tool
Add salted MD5/SHA1 password support
Add client/tools password prompting (-W)
+ Add slapd logging option
+ Add slapd alternative args/pid file locations
Fix lber leaking ber_scanf
Update client/tools Kerberos option handling
-.TH SLAPD 8C "6 November 1995" "U-M LDAP LDVERSION"
+.TH SLAPD 8C "22 September 1998" "OpenLDAP LDVERSION"
.SH NAME
slapd \- Stand-alone LDAP Daemon
.SH SYNOPSIS
-.B ETCDIR/slapd [\-d debug\-level]
+.B LIBEXECDIR/slapd [\-d debug\-level]
.B [\-f slapd\-config\-file] [\-p port\-number]
-.B [\-s syslog\-level] [\-i]
+.B [\-s syslog\-level] [\-l syslog\-local\-user] [\-i]
.B
.SH DESCRIPTION
.LP
Upon startup,
.B slapd
normally forks and disassociates itself from the invoking tty.
+In this case, the
+.B slapd
+process will print its process ID to a
+.B .pid
+file ( see
+.BR getpid (2)
+), as well as the command line options during invocation to an
+.B .args
+file. By default, these files are located in the directory
+.B LOCALSTATEDIR.
+The files' base names are derived from the
+.B slapd
+binary name, making it possible to run several
+.B slapd
+servers with differet names on the same machine, with each having
+its own
+.B .pid/.args
+files. (Those
+.B slapd
+names might be obtained via symbolic links to one binary file.)
If the
.B \-d
flag is given and debugging is set to some non-zero
.BR syslog (8)
facility.
.TP
+.BI \-l " syslog\-local\-user"
+Selects the local user of the
+.BR syslog (8)
+facility. Values can be
+.BR LOCAL0 ,
+.BR LOCAL1 ,
+and so on, up to
+.BR LOCAL7 .
+The default is
+.BR LOCAL4 .
+However, this option is only permitted on systems that support
+local users with the
+.BR syslog (8)
+facility.
+.TP
.BI \-f " slapd\-config\-file"
Specifies the slapd configuration file. The default is
.BR ETCDIR/slapd.conf .
.LP
.nf
.ft tt
- ETCDIR/slapd
+ LIBEXECDIR/slapd
.ft
.fi
.LP
.LP
.nf
.ft tt
- ETCDIR/slapd -f /usr/local/slapd/slapd.conf -d 255
+ LIBEXECDIR/slapd -f ETCDIR/slapd.conf -d 255
.ft
.fi
.LP
.SH BUGS
When using the LDBM database backend, the Modify RDN operation does not
update the attribute values in the entry that are affected by the change.
+.SH ACKNOWLEDGEMENTS
+.B OpenLDAP
+is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
+.B OpenLDAP
+is derived from University of Michigan LDAP 3.3 Release.
/*
* SHARED DEFINITIONS - things you should change
*/
+#define DEFAULT_DIRSEP "/"
#define DEFAULT_BINDIR "%BINDIR%"
#define DEFAULT_SBINDIR "%SBINDIR%"
#define DEFAULT_DATADIR "%DATADIR%"
#define DEFAULT_SYSCONFDIR "%SYSCONFDIR%"
#define DEFAULT_LIBEXECDIR "%LIBEXECDIR%"
+#define DEFAULT_RUNDIR "%RUNDIR%"
#define DEFAULT_LDAP_CONF_FILE "%SYSCONFDIR%/ldap.conf"
#define DEFAULT_LDAP_USERRC_FILE "ldaprc"
#define SLAPD_DEFAULT_SIZELIMIT 500
/* default timelimit to spend on a search */
#define SLAPD_DEFAULT_TIMELIMIT 3600
- /* location of the slapd pid file */
-#define SLAPD_PIDFILE "%RUNDIR%/slapd.pid"
- /* location of the slapd args file */
-#define SLAPD_ARGSFILE "%RUNDIR%/slapd.args"
+ /* extension of the slapd pid file */
+#define SLAPD_PIDEXT ".pid"
+ /* extension of the slapd args file */
+#define SLAPD_ARGSEXT ".args"
/* dn of the special "monitor" entry */
#define SLAPD_MONITOR_DN "cn=monitor"
/* dn of the special "config" entry */
/*
* SHARED DEFINITIONS - things you should change
*/
-/*
- * SHARED DEFINITIONS - things you should change
- */
+#define DEFAULT_DIRSEP "\\"
#define DEFAULT_BINDIR "C:\\OpenLDAP\\bin"
#define DEFAULT_SBINDIR "C:\\OpenLDAP\\sbin"
#define DEFAULT_DATADIR "C:\\OpenLDAP\\share"
#define SLAPD_DEFAULT_SIZELIMIT 500
/* default timelimit to spend on a search */
#define SLAPD_DEFAULT_TIMELIMIT 3600
- /* location of the slapd pid file */
-#define SLAPD_PIDFILE "C:\\OpenLDAP\\run\\slapd.pid"
- /* location of the slapd args file */
-#define SLAPD_ARGSFILE "C:\\OpenLDAP\\run\\slapd.args"
+ /* extension of the slapd pid file */
+#define SLAPD_PIDEXT ".pid"
+ /* extension of the slapd args file */
+#define SLAPD_ARGSEXT ".args"
/* dn of the special "monitor" entry */
#define SLAPD_MONITOR_DN "cn=monitor"
/* dn of the special "config" entry */
static void set_shutdown(int sig);
static void do_nothing (int sig);
+/* we need the server's name for constructing the pid/args file names */
+#if defined( SLAPD_PIDEXT ) || defined( SLAPD_ARGSEXT )
+extern char *serverName;
+#define DEFAULT_SERVERNAME "slapd"
+#endif
+
void *
slapd_daemon(
void *port
FILE *fp;
int on = 1;
+#ifdef SLAPD_PIDEXT
+ char pidFile[BUFSIZ];
+#endif
+#ifdef SLAPD_ARGSEXT
+ char argsFile[BUFSIZ];
+#endif
+
#ifdef HAVE_SYSCONF
dtblsize = sysconf( _SC_OPEN_MAX );
#elif HAVE_GETDTABLESIZE
(void) SIGNAL( SIGHUP, set_shutdown );
Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 );
-#ifdef SLAPD_PIDFILE
- if ( (fp = fopen( SLAPD_PIDFILE, "w" )) != NULL ) {
+
+#if defined( SLAPD_PIDEXT ) || defined( SLAPD_ARGSEXT )
+ if ( !serverName ) serverName = DEFAULT_SERVERNAME;
+
+#ifdef SLAPD_PIDEXT
+ sprintf( pidFile, "%s%s%s%s", DEFAULT_RUNDIR, DEFAULT_DIRSEP,
+ serverName, SLAPD_PIDEXT );
+ if ( (fp = fopen( pidFile, "w" )) != NULL ) {
fprintf( fp, "%d\n", (int) getpid() );
fclose( fp );
}
#endif
-#ifdef SLAPD_ARGSFILE
- if ( (fp = fopen( SLAPD_ARGSFILE, "w" )) != NULL ) {
+#ifdef SLAPD_ARGSEXT
+ sprintf( argsFile, "%s%s%s%s", DEFAULT_RUNDIR, DEFAULT_DIRSEP,
+ serverName, SLAPD_ARGSEXT );
+ if ( (fp = fopen( argsFile, "w" )) != NULL ) {
for ( i = 0; i < g_argc; i++ ) {
fprintf( fp, "%s ", g_argv[i] );
}
fclose( fp );
}
#endif
+#endif
+
while ( !slapd_shutdown ) {
struct sockaddr_in from;
#include "slap.h"
#include "lutil.h" /* Get lutil_detach() */
+/*
+ * when more than one slapd is running on one machine, each one might have
+ * it's own LOCAL for syslogging and must have its own pid/args files
+ */
+
+#ifdef LOG_LOCAL4
+
+#define DEFAULT_SYSLOG_USER LOG_LOCAL4
+
+typedef struct _str2intDispatch {
+
+ char *stringVal;
+ int abbr;
+ int intVal;
+
+} STRDISP, *STRDISP_P;
+
+
+/* table to compute syslog-options to integer */
+static STRDISP syslog_types[] = {
+
+ { "LOCAL0", 6, LOG_LOCAL0 },
+ { "LOCAL1", 6, LOG_LOCAL1 },
+ { "LOCAL2", 6, LOG_LOCAL2 },
+ { "LOCAL3", 6, LOG_LOCAL3 },
+ { "LOCAL4", 6, LOG_LOCAL4 },
+ { "LOCAL5", 6, LOG_LOCAL5 },
+ { "LOCAL6", 6, LOG_LOCAL6 },
+ { "LOCAL7", 6, LOG_LOCAL7 },
+ NULL
+
+};
+
+static int cnvt_str2int();
+
+#endif /* LOG_LOCAL4 */
+
+/*
+ * the server's name must be accessible from the daemon module,
+ * to construct the pid/args file names
+ */
+char *serverName = NULL;
+
+
static void
usage( 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]", name );
+#ifdef LOG_LOCAL4
+ fprintf( stderr, " [-l sysloguser]" );
+#endif
+ fprintf( stderr, "\n" );
}
int
int i;
int inetd = 0;
int port;
- char *myname;
int udp;
Backend *be = NULL;
FILE *fp = NULL;
char *configfile;
+#ifdef LOG_LOCAL4
+ int syslogUser = DEFAULT_SYSLOG_USER;
+#endif
configfile = SLAPD_DEFAULT_CONFIGFILE;
port = LDAP_PORT;
ldap_syslog = atoi( optarg );
break;
+#ifdef LOG_LOCAL4
+
+ case 'l': /* set syslog local user */
+ syslogUser = cnvt_str2int( optarg, syslog_types,
+ DEFAULT_SYSLOG_USER );
+ break;
+
+#endif
+
case 'u': /* do udp */
udp = 1;
break;
Debug( LDAP_DEBUG_TRACE, "%s", Versionstr, 0, 0 );
- if ( (myname = strrchr( argv[0], '/' )) == NULL ) {
- myname = ch_strdup( argv[0] );
+ if ( (serverName = strrchr( argv[0], '/' )) == NULL ) {
+ serverName = ch_strdup( argv[0] );
} else {
- myname = ch_strdup( myname + 1 );
+ serverName = ch_strdup( serverName + 1 );
}
if ( ! inetd ) {
lutil_detach( 0, 0 );
#endif
}
+
#ifdef LOG_LOCAL4
- openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL4 );
+ openlog( serverName, OPENLOG_OPTIONS, syslogUser );
#else
- openlog( myname, OPENLOG_OPTIONS );
+ openlog( serverName, OPENLOG_OPTIONS );
#endif
init();
}
return 1;
}
+
+
+#ifdef LOG_LOCAL4
+
+/*
+ * Convert a string to an integer by means of a dispatcher table
+ * if the string is not in the table return the default
+ */
+
+static int
+cnvt_str2int (stringVal, dispatcher, defaultVal)
+char *stringVal;
+STRDISP_P dispatcher;
+int defaultVal;
+{
+ int retVal = defaultVal;
+ STRDISP_P disp;
+
+ for (disp = dispatcher; disp->stringVal; disp++) {
+
+ if (!strncasecmp (stringVal, disp->stringVal, disp->abbr)) {
+
+ retVal = disp->intVal;
+ break;
+
+ }
+ }
+
+ return (retVal);
+
+} /* cnvt_str2int */
+
+#endif /* LOG_LOCAL4 */
+