X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=servers%2Fslapd%2Fmain.c;h=785806497e40c26e6d4c710c51afa2230977aa54;hb=4f302fd19714591bd94bbf2a160dd8ecc704d693;hp=d3972ca0f1a0c0088d111bb97262a9d5c05c60c4;hpb=edb1d671f838ae3a841d08816c0865e2f306b582;p=openldap
diff --git a/servers/slapd/main.c b/servers/slapd/main.c
index d3972ca0f1..b32e60e4d2 100644
--- a/servers/slapd/main.c
+++ b/servers/slapd/main.c
@@ -1,57 +1,93 @@
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2005 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
+ */
+/* Portions Copyright (c) 1995 Regents of the University of Michigan.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of Michigan at Ann Arbor. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+
#include "portable.h"
#include
-#include
+#include
#include
#include
#include
#include
#include
-#include
#include
-#include "ldap_defaults.h"
#include "slap.h"
#include "lutil.h"
+#include "ldif.h"
+
+#ifdef LDAP_SLAPI
+#include "slapi/slapi.h"
+#endif
#ifdef LDAP_SIGCHLD
static RETSIGTYPE wait4child( int sig );
#endif
-#ifdef HAVE_WINSOCK
+#ifdef HAVE_NT_SERVICE_MANAGER
#define MAIN_RETURN(x) return
-struct sockaddr_in bind_addr;
-
-/* in nt_main.c */
-extern SERVICE_STATUS SLAPDServiceStatus;
-extern SERVICE_STATUS_HANDLE hSLAPDServiceStatus;
-extern ldap_pvt_thread_cond_t started_event, stopped_event;
-extern int is_NT_Service;
-
-void LogSlapdStartedEvent( char *svc, int slap_debug, char *configfile, short port, int udp );
-void LogSlapdStoppedEvent( char *svc );
-
-void CommenceStartupProcessing( LPCTSTR serviceName,
- void(*stopper)(int));
-void ReportSlapdShutdownComplete( void );
-void *getRegParam( char *svc, char *value );
-
-#define SERVICE_EXIT( e, n ) \
- if ( is_NT_Service ) \
-{ \
- SLAPDServiceStatus.dwWin32ExitCode = e; \
- SLAPDServiceStatus.dwServiceSpecificExitCode = n; \
-}
+static struct sockaddr_in bind_addr;
+
+#define SERVICE_EXIT( e, n ) do { \
+ if ( is_NT_Service ) { \
+ lutil_ServiceStatus.dwWin32ExitCode = (e); \
+ lutil_ServiceStatus.dwServiceSpecificExitCode = (n); \
+ } \
+} while ( 0 )
+
#else
#define SERVICE_EXIT( e, n )
#define MAIN_RETURN(x) return(x)
#endif
-short port = LDAP_PORT;
-#ifdef HAVE_TLS
-short tls_port = LDAP_TLS_PORT;
-#endif
+typedef int (MainFunc) LDAP_P(( int argc, char *argv[] ));
+extern MainFunc slapadd, slapcat, slapdn, slapindex, slappasswd,
+ slaptest, slapauth, slapacl;
+
+static struct {
+ char *name;
+ MainFunc *func;
+} tools[] = {
+ {"slapadd", slapadd},
+ {"slapcat", slapcat},
+ {"slapdn", slapdn},
+ {"slapindex", slapindex},
+ {"slappasswd", slappasswd},
+ {"slaptest", slaptest},
+ {"slapauth", slapauth},
+ {"slapacl", slapacl},
+ /* NOTE: new tools must be added in chronological order,
+ * not in alphabetical order, because for backwards
+ * compatibility name[4] is used to identify the
+ * tools; so name[4]=='a' must refer to "slapadd" and
+ * not to "slapauth". Alphabetical order can be used
+ * for tools whose name[4] is not used yet */
+ {NULL, NULL}
+};
+
/*
* 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
@@ -63,244 +99,372 @@ const char Versionstr[] =
#endif
#ifdef LOG_LOCAL4
-
#define DEFAULT_SYSLOG_USER LOG_LOCAL4
typedef struct _str2intDispatch {
- char *stringVal;
- int abbr;
- int intVal;
+ 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 STRDISP syslog_types[] = {
+ { "LOCAL0", sizeof("LOCAL0"), LOG_LOCAL0 },
+ { "LOCAL1", sizeof("LOCAL1"), LOG_LOCAL1 },
+ { "LOCAL2", sizeof("LOCAL2"), LOG_LOCAL2 },
+ { "LOCAL3", sizeof("LOCAL3"), LOG_LOCAL3 },
+ { "LOCAL4", sizeof("LOCAL4"), LOG_LOCAL4 },
+ { "LOCAL5", sizeof("LOCAL5"), LOG_LOCAL5 },
+ { "LOCAL6", sizeof("LOCAL6"), LOG_LOCAL6 },
+ { "LOCAL7", sizeof("LOCAL7"), LOG_LOCAL7 },
+#ifdef LOG_USER
+ { "USER", sizeof("USER"), LOG_USER },
+#endif
+#ifdef LOG_DAEMON
+ { "DAEMON", sizeof("DAEMON"), LOG_DAEMON },
+#endif
+ { NULL, 0, 0 }
};
-static int cnvt_str2int( char *, STRDISP_P, int );
+static int cnvt_str2int( char *, STRDISP_P, int );
+#endif /* LOG_LOCAL4 */
+
+#define CHECK_NONE 0x00
+#define CHECK_CONFIG 0x01
+static int check = CHECK_NONE;
+static int version = 0;
-#endif /* LOG_LOCAL4 */
+void *slap_tls_ctx;
+static int
+slapd_opt_slp( const char *val, void *arg )
+{
+#ifdef HAVE_SLP
+ /* NULL is default */
+ if ( val == NULL || strcasecmp( val, "on" ) == 0 ) {
+ slapd_register_slp = 1;
+
+ } else if ( strcasecmp( val, "off" ) == 0 ) {
+ slapd_register_slp = 0;
+
+ /* NOTE: add support for URL specification? */
+
+ } else {
+ fprintf(stderr, "unrecognized value \"%s\" for SLP option\n", val );
+ return -1;
+ }
+
+ return 0;
+
+#else
+ fputs( "slapd: SLP support is not available\n", stderr );
+ return 0;
+#endif
+}
+
+/*
+ * Option helper structure:
+ *
+ * oh_nam is left-hand part of