X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=shibsp%2FSPConfig.cpp;h=e8b6d2f507a99971054cd87c13defb83997bb492;hb=HEAD;hp=75317ea64048e04702ef5323960000ea80f8bd4a;hpb=3968f4eac0a112d55ca7ec0041f9cdb98400e7b3;p=shibboleth%2Fcpp-sp.git diff --git a/shibsp/SPConfig.cpp b/shibsp/SPConfig.cpp index 75317ea..e8b6d2f 100644 --- a/shibsp/SPConfig.cpp +++ b/shibsp/SPConfig.cpp @@ -66,7 +66,6 @@ #endif #include -#include #include #include #include @@ -184,19 +183,25 @@ 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"); + Category& log=Category::getInstance(SHIBSP_LOGCAT ".Config"); log.debug("%s library initialization started", PACKAGE_STRING); #ifndef SHIBSP_LITE @@ -228,35 +233,40 @@ bool SPConfig::init(const char* catalog_path, const char* inst_prefix) return false; } #endif - if (!catalog_path) - catalog_path = getenv("SHIBSP_SCHEMAS"); - if (!catalog_path) - catalog_path = SHIBSP_SCHEMAS; - if (!XMLToolingConfig::getConfig().getValidatingParser().loadCatalogs(catalog_path)) { - log.warn("failed to load schema catalogs into validating parser"); - } PathResolver* pr = XMLToolingConfig::getConfig().getPathResolver(); pr->setDefaultPackageName(PACKAGE_NAME); 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); + if (!catalog_path) + catalog_path = getenv("SHIBSP_SCHEMAS"); + 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"); + } + XMLToolingConfig::getConfig().setTemplateEngine(new TemplateEngine()); XMLToolingConfig::getConfig().getTemplateEngine()->setTagPrefix("shibmlp"); @@ -331,7 +341,7 @@ bool SPConfig::init(const char* catalog_path, const char* inst_prefix) void SPConfig::term() { - Category& log=Category::getInstance(SHIBSP_LOGCAT".Config"); + Category& log=Category::getInstance(SHIBSP_LOGCAT ".Config"); log.info("%s library shutting down", PACKAGE_STRING); setServiceProvider(nullptr); @@ -440,7 +450,7 @@ bool SPConfig::instantiate(const char* config, bool rethrow) catch (exception& ex) { if (rethrow) throw; - Category::getInstance(SHIBSP_LOGCAT".Config").fatal("caught exception while loading configuration: %s", ex.what()); + Category::getInstance(SHIBSP_LOGCAT ".Config").fatal("caught exception while loading configuration: %s", ex.what()); } return false; } @@ -454,7 +464,7 @@ bool SPInternalConfig::init(const char* catalog_path, const char* inst_prefix) Lock initLock(m_lock); if (m_initCount == INT_MAX) { - Category::getInstance(SHIBSP_LOGCAT".Config").crit("library initialized too many times"); + Category::getInstance(SHIBSP_LOGCAT ".Config").crit("library initialized too many times"); return false; } @@ -479,7 +489,7 @@ void SPInternalConfig::term() Lock initLock(m_lock); if (m_initCount == 0) { - Category::getInstance(SHIBSP_LOGCAT".Config").crit("term without corresponding init"); + Category::getInstance(SHIBSP_LOGCAT ".Config").crit("term without corresponding init"); return; } else if (--m_initCount > 0) {