SSPCPP-568 The INSTALL_DIR has to have a trailing backslash or else keygen fails.
[shibboleth/cpp-sp.git] / shibsp / SPConfig.cpp
index 6206236..0e42344 100644 (file)
@@ -183,17 +183,23 @@ bool SPConfig::init(const char* catalog_path, const char* inst_prefix)
         ++inst_prefix;
     }
 
-    const char* loglevel=getenv("SHIBSP_LOGGING");
-    if (!loglevel)
-        loglevel = SHIBSP_LOGGING;
-    std::string ll(loglevel);
+    const char* logconf = getenv("SHIBSP_LOGGING");
+    if (!logconf || !*logconf) {
+        if (isEnabled(SPConfig::Logging) && isEnabled(SPConfig::OutOfProcess) && !isEnabled(SPConfig::InProcess))
+            logconf = SHIBSP_OUTOFPROC_LOGGING;
+        else if (isEnabled(SPConfig::Logging) && isEnabled(SPConfig::InProcess) && !isEnabled(SPConfig::OutOfProcess))
+            logconf = SHIBSP_INPROC_LOGGING;
+        else
+            logconf = SHIBSP_LOGGING;
+    }
     PathResolver localpr;
     localpr.setDefaultPrefix(inst_prefix2.c_str());
     inst_prefix = getenv("SHIBSP_CFGDIR");
-    if (!inst_prefix)
+    if (!inst_prefix || !*inst_prefix)
         inst_prefix = SHIBSP_CFGDIR;
     localpr.setCfgDir(inst_prefix);
-    XMLToolingConfig::getConfig().log_config(localpr.resolve(ll, PathResolver::XMLTOOLING_CFG_FILE, PACKAGE_NAME).c_str());
+    std::string lc(logconf);
+    XMLToolingConfig::getConfig().log_config(localpr.resolve(lc, PathResolver::XMLTOOLING_CFG_FILE, PACKAGE_NAME).c_str());
 
     Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
     log.debug("%s library initialization started", PACKAGE_STRING);
@@ -229,7 +235,7 @@ bool SPConfig::init(const char* catalog_path, const char* inst_prefix)
 #endif
     if (!catalog_path)
         catalog_path = getenv("SHIBSP_SCHEMAS");
-    if (!catalog_path)
+    if (!catalog_path || !*catalog_path)
         catalog_path = SHIBSP_SCHEMAS;
     if (!XMLToolingConfig::getConfig().getValidatingParser().loadCatalogs(catalog_path)) {
         log.warn("failed to load schema catalogs into validating parser");
@@ -240,19 +246,23 @@ bool SPConfig::init(const char* catalog_path, const char* inst_prefix)
     pr->setDefaultPrefix(inst_prefix2.c_str());
     pr->setCfgDir(inst_prefix);
     inst_prefix = getenv("SHIBSP_LIBDIR");
-    if (!inst_prefix)
+    if (!inst_prefix || !*inst_prefix)
         inst_prefix = SHIBSP_LIBDIR;
     pr->setLibDir(inst_prefix);
     inst_prefix = getenv("SHIBSP_LOGDIR");
-    if (!inst_prefix)
+    if (!inst_prefix || !*inst_prefix)
         inst_prefix = SHIBSP_LOGDIR;
     pr->setLogDir(inst_prefix);
     inst_prefix = getenv("SHIBSP_RUNDIR");
-    if (!inst_prefix)
+    if (!inst_prefix || !*inst_prefix)
         inst_prefix = SHIBSP_RUNDIR;
     pr->setRunDir(inst_prefix);
+    inst_prefix = getenv("SHIBSP_CACHEDIR");
+    if (!inst_prefix || !*inst_prefix)
+        inst_prefix = SHIBSP_CACHEDIR;
+    pr->setCacheDir(inst_prefix);
     inst_prefix = getenv("SHIBSP_XMLDIR");
-    if (!inst_prefix)
+    if (!inst_prefix || !*inst_prefix)
         inst_prefix = SHIBSP_XMLDIR;
     pr->setXMLDir(inst_prefix);