]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/main.c
ITS#3818 fix index_substr_any_step keyword
[openldap] / servers / slapd / main.c
index c88876e046dcfbc2c281e7f92d2ed4144a9ffab9..98857b275d7acb5b10e04b6a61ac4dd100b42b36 100644 (file)
@@ -192,11 +192,12 @@ usage( char *name )
        fprintf( stderr,
                "\t-4\t\tIPv4 only\n"
                "\t-6\t\tIPv6 only\n"
-               "\t-T {add|auth|cat|dn|index|passwd|test}\n"
+               "\t-T {acl|add|auth|cat|dn|index|passwd|test}\n"
                "\t\t\tRun in Tool mode\n"
                "\t-c cookie\tSync cookie of consumer\n"
                "\t-d level\tDebug level" "\n"
                "\t-f filename\tConfiguration file\n"
+               "\t-F dir\tConfiguration directory\n"
 #if defined(HAVE_SETUID) && defined(HAVE_SETGID)
                "\t-g group\tGroup (id or name) to run as\n"
 #endif
@@ -251,11 +252,8 @@ int main( int argc, char **argv )
        int g_argc = argc;
        char **g_argv = argv;
 
-#ifdef HAVE_NT_SERVICE_MANAGER
-       char            *configfile = ".\\slapd.conf";
-#else
-       char            *configfile = SLAPD_DEFAULT_CONFIGFILE;
-#endif
+       char            *configfile = NULL;
+       char            *configdir = NULL;
        char        *serverName;
        int         serverMode = SLAP_SERVER_MODE;
 
@@ -288,6 +286,7 @@ int main( int argc, char **argv )
        {
                int *i;
                char *newConfigFile;
+               char *newConfigDir;
                char *newUrls;
                char *regService = NULL;
 
@@ -319,11 +318,17 @@ int main( int argc, char **argv )
                        configfile = newConfigFile;
                        Debug ( LDAP_DEBUG_ANY, "new config file from registry is: %s\n", configfile, 0, 0 );
                }
+
+               newConfigDir = (char*)lutil_getRegParam( regService, "ConfigDir" );
+               if ( newConfigDir != NULL ) {
+                       configdir = newConfigDir;
+                       Debug ( LDAP_DEBUG_ANY, "new config dir from registry is: %s\n", configdir, 0, 0 );
+               }
        }
 #endif
 
        while ( (i = getopt( argc, argv,
-                            "c:d:f:h:n:o:s:StT:V"
+                            "c:d:f:F:h:n:o:s:StT:V"
 #if LDAP_PF_INET6
                                "46"
 #endif
@@ -385,6 +390,10 @@ int main( int argc, char **argv )
                        configfile = ch_strdup( optarg );
                        break;
 
+               case 'F':       /* use config dir */
+                       configdir = ch_strdup( optarg );
+                       break;
+
                case 'o': {
                        char            *val = strchr( optarg, '=' );
                        struct berval   opt;
@@ -624,7 +633,7 @@ unhandled_option:;
        }
 #endif /* SLAP_DYNACL */
 
-       if ( read_config( configfile, 0 ) != 0 ) {
+       if ( read_config( configfile, configdir ) != 0 ) {
                rc = 1;
                SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 19 );
 
@@ -764,7 +773,8 @@ unhandled_option:;
 
 #ifdef HAVE_NT_EVENT_LOG
        if (is_NT_Service)
-       lutil_LogStartedEvent( serverName, slap_debug, configfile, urls );
+       lutil_LogStartedEvent( serverName, slap_debug, configfile ?
+               configfile : SLAPD_DEFAULT_CONFIGFILE , urls );
 #endif
 
        rc = slapd_daemon();