]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/main.c
SLAPI - Netscape plugin API for slapd - based on patch contributed by Steve Omrani...
[openldap] / servers / slapd / main.c
index b48f222450b9b3552c8c1d58719294718ff3196b..40a036ce8928174ac48e5ae7c1836c922dd9d8b4 100644 (file)
@@ -4,6 +4,7 @@
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 #include "portable.h"
+#include "slapi_common.h"
 
 #include <stdio.h>
 
@@ -16,7 +17,9 @@
 
 #include "ldap_pvt.h"
 
+
 #include "slap.h"
+#include "slapi.h"
 #include "lutil.h"
 #include "ldif.h"
 
@@ -96,6 +99,8 @@ usage( char *name )
        fprintf( stderr,
                "usage: %s options\n", name );
        fprintf( stderr,
+               "\t-4\t\tIPv4 only\n"
+               "\t-6\t\tIPv6 only\n"
                "\t-d level\tDebug level" "\n"
                "\t-f filename\tConfiguration file\n"
 #if defined(HAVE_SETUID) && defined(HAVE_SETGID)
@@ -175,8 +180,10 @@ int main( int argc, char **argv )
                {
                        slap_debug = *i;
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                                  "main: new debug level from registry is: %d\n", slap_debug ));
+                       lutil_log_initialize( argc, argv );
+                       LDAP_LOG( SLAPD, INFO, 
+                               "main: new debug level from registry is: %d\n", 
+                               slap_debug, 0, 0 );
 #else
                        Debug( LDAP_DEBUG_ANY, "new debug level from registry is: %d\n", slap_debug, 0, 0 );
 #endif
@@ -190,8 +197,8 @@ int main( int argc, char **argv )
 
                    urls = ch_strdup(newUrls);
 #ifdef NEW_LOGGING
-                   LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                              "main: new urls from registry: %s\n", urls ));
+                   LDAP_LOG( SLAPD, INFO, 
+                               "main: new urls from registry: %s\n", urls, 0, 0 );
 #else
                    Debug(LDAP_DEBUG_ANY, "new urls from registry: %s\n",
                          urls, 0, 0);
@@ -204,8 +211,8 @@ int main( int argc, char **argv )
                {
                        configfile = newConfigFile;
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                                  "main: new config file from registry is: %s\n", configfile ));
+                       LDAP_LOG( SLAPD, INFO, 
+                               "main: new config file from registry is: %s\n", configfile, 0, 0 );
 #else
                        Debug ( LDAP_DEBUG_ANY, "new config file from registry is: %s\n", configfile, 0, 0 );
 #endif
@@ -216,6 +223,9 @@ int main( int argc, char **argv )
 
        while ( (i = getopt( argc, argv,
                             "d:f:h:s:n:t"
+#if LDAP_PF_INET6
+                               "46"
+#endif
 #ifdef HAVE_CHROOT
                                "r:"
 #endif
@@ -227,6 +237,15 @@ int main( int argc, char **argv )
 #endif
                             )) != EOF ) {
                switch ( i ) {
+#ifdef LDAP_PF_INET6
+               case '4':
+                       slap_inet4or6 = AF_INET;
+                       break;
+               case '6':
+                       slap_inet4or6 = AF_INET6;
+                       break;
+#endif
+
                case 'h':       /* listen URLs */
                        if ( urls != NULL ) free( urls );
                        urls = ch_strdup( optarg );
@@ -296,16 +315,15 @@ int main( int argc, char **argv )
 
 #ifdef NEW_LOGGING
        lutil_log_initialize( argc, argv );
-#endif
-
+#else
        lutil_set_debug_level( "slapd", slap_debug );
        ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &slap_debug);
        ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &slap_debug);
        ldif_debug = slap_debug;
+#endif
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                  "%s", Versionstr ));
+       LDAP_LOG( SLAPD, INFO, "%s", Versionstr, 0, 0 );
 #else
        Debug( LDAP_DEBUG_TRACE, "%s", Versionstr, 0, 0 );
 #endif
@@ -370,8 +388,7 @@ int main( int argc, char **argv )
 
        if ( slap_schema_init( ) != 0 ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
-                          "main: schema initialization error\n" ));
+               LDAP_LOG( OPERATION, CRIT, "main: schema initialization error\n", 0, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                    "schema initialization error\n",
@@ -391,7 +408,21 @@ int main( int argc, char **argv )
        (void) ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &rc );
 #endif
 
-       if ( read_config( configfile ) != 0 ) {
+#ifdef LDAP_SLAPI
+       if ( slapi_init() != 0 ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG( OPERATION, CRIT, "main: slapi initialization error\n", 0, 0, 0 );
+#else
+               Debug( LDAP_DEBUG_ANY,
+                   "slapi initialization error\n",
+                   0, 0, 0 );
+#endif
+
+               goto destroy;
+       }
+#endif /* LDAP_SLAPI */
+
+       if ( read_config( configfile, 0 ) != 0 ) {
                rc = 1;
                SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 19 );
 
@@ -410,8 +441,7 @@ int main( int argc, char **argv )
 
        if ( glue_sub_init( ) != 0 ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
-                          "main: subordinate config error\n"));
+               LDAP_LOG( SLAPD, CRIT, "main: subordinate config error\n", 0, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                    "subordinate config error\n",
@@ -422,8 +452,7 @@ int main( int argc, char **argv )
 
        if ( slap_schema_check( ) != 0 ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
-                          "main: schema prep error\n"));
+               LDAP_LOG( SLAPD, CRIT, "main: schema prep error\n", 0, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                    "schema prep error\n",
@@ -437,8 +466,7 @@ int main( int argc, char **argv )
        rc = ldap_pvt_tls_init();
        if( rc != 0) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
-                          "main: tls init failed: %d\n", rc ));
+               LDAP_LOG( SLAPD, CRIT, "main: tls init failed: %d\n", rc, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                    "main: TLS init failed: %d\n",
@@ -452,12 +480,11 @@ int main( int argc, char **argv )
        rc = ldap_pvt_tls_init_def_ctx();
        if( rc != 0) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
-                          "main: tls init def ctx failed: %d\n", rc ));
+               LDAP_LOG( SLAPD, CRIT, "main: tls init def ctx failed: %d\n", rc, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                    "main: TLS init def ctx failed: %d\n",
-                   0, 0, 0 );
+                   rc, 0, 0 );
 #endif
                rc = 1;
                SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
@@ -502,8 +529,7 @@ int main( int argc, char **argv )
                FILE *fp;
 
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                          "main: slapd starting.\n" ));
+               LDAP_LOG( SLAPD, INFO, "main: slapd starting.\n", 0, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 );
 #endif
@@ -561,8 +587,7 @@ stop:
 #endif
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
-                  "main: slapd stopped.\n" ));
+       LDAP_LOG( SLAPD, CRIT, "main: slapd stopped.\n", 0, 0, 0 );
 #else
        Debug( LDAP_DEBUG_ANY, "slapd stopped.\n", 0, 0, 0 );
 #endif
@@ -620,7 +645,7 @@ wait4child( int sig )
     errno = save_errno;
 }
 
-#endif /* SIGCHLD || SIGCLD */
+#endif /* LDAP_SIGCHLD */
 
 
 #ifdef LOG_LOCAL4