]> git.sur5r.net Git - openldap/commitdiff
Fix config selection:
authorHoward Chu <hyc@openldap.org>
Sun, 1 May 2005 20:55:15 +0000 (20:55 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 1 May 2005 20:55:15 +0000 (20:55 +0000)
if -f but no -F, just read config file
if -f and -F, convert config file to config dir
else, try reading config dir
if no config dir, try config filE

servers/slapd/bconfig.c
servers/slapd/main.c
servers/slapd/slapcommon.c

index 50e1b8214ea952a170e64b8ec6fece56a6010390..f32f8e98121000b3f9f6b1cbdc9bc1a1807057c8 100644 (file)
@@ -2369,7 +2369,7 @@ config_ldif_resp( Operation *op, SlapReply *rs )
 
 /* Configure and read the underlying back-ldif store */
 static int
-config_setup_ldif( BackendDB *be, const char *dir ) {
+config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
        CfBackInfo *cfb = be->be_private;
        ConfigArgs c = {0};
        ConfigTable *ct;
@@ -2426,35 +2426,37 @@ config_setup_ldif( BackendDB *be, const char *dir ) {
        if ( backend_startup_one( &cfb->cb_db ))
                return 1;
 
-       op = (Operation *)opbuf;
-       connection_fake_init( &conn, op, cfb );
+       if ( readit ) {
+               op = (Operation *)opbuf;
+               connection_fake_init( &conn, op, cfb );
 
-       filter.f_desc = slap_schema.si_ad_objectClass;
-       
-       op->o_tag = LDAP_REQ_SEARCH;
+               filter.f_desc = slap_schema.si_ad_objectClass;
 
-       op->ors_filter = &filter;
-       op->ors_filterstr = filterstr;
-       op->ors_scope = LDAP_SCOPE_SUBTREE;
+               op->o_tag = LDAP_REQ_SEARCH;
 
-       op->o_dn = be->be_rootdn;
-       op->o_ndn = be->be_rootndn;
+               op->ors_filter = &filter;
+               op->ors_filterstr = filterstr;
+               op->ors_scope = LDAP_SCOPE_SUBTREE;
 
-       op->o_req_dn = be->be_suffix[0];
-       op->o_req_ndn = be->be_nsuffix[0];
+               op->o_dn = be->be_rootdn;
+               op->o_ndn = be->be_rootndn;
 
-       op->ors_tlimit = SLAP_NO_LIMIT;
-       op->ors_slimit = SLAP_NO_LIMIT;
+               op->o_req_dn = be->be_suffix[0];
+               op->o_req_ndn = be->be_nsuffix[0];
 
-       op->ors_attrs = slap_anlist_all_attributes;
-       op->ors_attrsonly = 0;
+               op->ors_tlimit = SLAP_NO_LIMIT;
+               op->ors_slimit = SLAP_NO_LIMIT;
 
-       op->o_callback = &cb;
-       cb.sc_private = cfb;
+               op->ors_attrs = slap_anlist_all_attributes;
+               op->ors_attrsonly = 0;
+
+               op->o_callback = &cb;
+               cb.sc_private = cfb;
+
+               op->o_bd = &cfb->cb_db;
+               op->o_bd->be_search( op, &rs );
+       }
 
-       op->o_bd = &cfb->cb_db;
-       op->o_bd->be_search( op, &rs );
-       
        cfb->cb_use_ldif = 1;
 
        return 0;
@@ -2505,15 +2507,32 @@ read_config(const char *fname, const char *dir) {
 
        cfb = be->be_private;
 
-       /* Setup the underlying back-ldif backend */
-       if ( config_setup_ldif( be, dir ))
-               return 1;
+       /* If no .conf, or a dir was specified, setup the dir */
+       if ( !fname || dir ) {
+               if ( dir ) {
+                       /* If explicitly given, check for existence */
+                       struct stat st;
+
+                       if ( stat( dir, &st ) < 0 ) {
+                               Debug( LDAP_DEBUG_ANY,
+                                       "invalid config directory %s, error %d\n",
+                                               dir, errno, 0 );
+                               return 1;
+                       }
+               } else {
+                       dir = SLAPD_DEFAULT_CONFIGDIR;
+               }
+               /* if fname is defaulted, try reading .d */
+               if ( config_setup_ldif( be, dir, !fname ))
+                       return 1;
 
-#ifdef SLAP_USE_CONFDIR
-       /* If we read the config from back-ldif, nothing to do here */
-       if ( cfb->cb_got_ldif )
-               return 0;
-#endif
+               /* If we read the config from back-ldif, nothing to do here */
+               if ( cfb->cb_got_ldif )
+                       return 0;
+       }
+
+       if ( !fname )
+               fname = SLAPD_DEFAULT_CONFIGFILE;
        ber_str2bv( fname, 0, 1, &cf_prv.c_file );
 
        return read_config_file(fname, 0, NULL);
index 8ba7f78291e550661590d3922acc2fc0a9b89fc2..98857b275d7acb5b10e04b6a61ac4dd100b42b36 100644 (file)
@@ -252,13 +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";
-       char            *configdir = ".\\slapd.d";
-#else
-       char            *configfile = SLAPD_DEFAULT_CONFIGFILE;
-       char            *configdir = SLAPD_DEFAULT_CONFIGDIR;
-#endif
+       char            *configfile = NULL;
+       char            *configdir = NULL;
        char        *serverName;
        int         serverMode = SLAP_SERVER_MODE;
 
@@ -778,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();
index 10a1548ec65dc8520b34022e7ad390e7585ebacf..48122b53d1ff3040333b9ad5b77dfbab5eb504c6 100644 (file)
@@ -166,8 +166,8 @@ slap_tool_init(
        int argc, char **argv )
 {
        char *options;
-       char *conffile = SLAPD_DEFAULT_CONFIGFILE;
-       char *confdir = SLAPD_DEFAULT_CONFIGDIR;
+       char *conffile = NULL;
+       char *confdir = NULL;
        struct berval base = BER_BVNULL;
        char *filterstr = NULL;
        char *subtree = NULL;