Adjust fix for SSPCPP-570, let empty r->user through.
[shibboleth/cpp-sp.git] / shibsp / SPConfig.cpp
index c79a404..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 || !*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");