From e76a5b987170d76d39dd67b487290e5e98bc2b53 Mon Sep 17 00:00:00 2001 From: cantor Date: Mon, 26 Jul 2010 02:15:17 +0000 Subject: [PATCH] Default logger settings, make InProcess/OutOfProcess material optional. git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/branches/REL_2@3272 cb58f699-b61c-0410-a6fe-9272a202ed29 --- configs/shibboleth2.xml | 31 +--------------- schemas/shibboleth-2.0-native-sp-config.xsd | 4 +-- shibsp/impl/XMLServiceProvider.cpp | 55 ++++++++++++++++------------- 3 files changed, 34 insertions(+), 56 deletions(-) diff --git a/configs/shibboleth2.xml b/configs/shibboleth2.xml index 39eee7d..2682ce5 100644 --- a/configs/shibboleth2.xml +++ b/configs/shibboleth2.xml @@ -3,37 +3,8 @@ xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" - logger="syslog.logger" clockSkew="180"> + clockSkew="180"> - - - - - - - - - - - - - - - diff --git a/schemas/shibboleth-2.0-native-sp-config.xsd b/schemas/shibboleth-2.0-native-sp-config.xsd index 2e89fe9..a6f6168 100644 --- a/schemas/shibboleth-2.0-native-sp-config.xsd +++ b/schemas/shibboleth-2.0-native-sp-config.xsd @@ -653,8 +653,8 @@ - - + + diff --git a/shibsp/impl/XMLServiceProvider.cpp b/shibsp/impl/XMLServiceProvider.cpp index 0d1e50d..7511549 100644 --- a/shibsp/impl/XMLServiceProvider.cpp +++ b/shibsp/impl/XMLServiceProvider.cpp @@ -1234,29 +1234,28 @@ XMLConfigImpl::acceptNode(const DOMNode* node) const void XMLConfigImpl::doExtensions(const DOMElement* e, const char* label, Category& log) { - const DOMElement* exts=XMLHelper::getFirstChildElement(e,_Extensions); + const DOMElement* exts = XMLHelper::getFirstChildElement(e, _Extensions); if (exts) { - exts=XMLHelper::getFirstChildElement(exts,Library); + exts = XMLHelper::getFirstChildElement(exts, Library); while (exts) { - auto_ptr_char path(exts->getAttributeNS(nullptr,_path)); + string path(XMLHelper::getAttrString(exts, nullptr, _path)); try { - if (path.get()) { - if (!XMLToolingConfig::getConfig().load_library(path.get(),(void*)exts)) + if (!path.empty()) { + if (!XMLToolingConfig::getConfig().load_library(path.c_str(), (void*)exts)) throw ConfigurationException("XMLToolingConfig::load_library failed."); - log.debug("loaded %s extension library (%s)", label, path.get()); + log.debug("loaded %s extension library (%s)", label, path.c_str()); } } catch (exception& e) { - const XMLCh* fatal=exts->getAttributeNS(nullptr,_fatal); - if (fatal && (*fatal==chLatin_t || *fatal==chDigit_1)) { - log.fatal("unable to load mandatory %s extension library %s: %s", label, path.get(), e.what()); + if (XMLHelper::getAttrBool(exts, false, _fatal)) { + log.fatal("unable to load mandatory %s extension library %s: %s", label, path.c_str(), e.what()); throw; } else { - log.crit("unable to load optional %s extension library %s: %s", label, path.get(), e.what()); + log.crit("unable to load optional %s extension library %s: %s", label, path.c_str(), e.what()); } } - exts=XMLHelper::getNextSiblingElement(exts,Library); + exts = XMLHelper::getNextSiblingElement(exts, Library); } } } @@ -1278,23 +1277,31 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o SAMLConfig& samlConf=SAMLConfig::getConfig(); #endif XMLToolingConfig& xmlConf=XMLToolingConfig::getConfig(); - const DOMElement* SHAR=XMLHelper::getFirstChildElement(e,OutOfProcess); - const DOMElement* SHIRE=XMLHelper::getFirstChildElement(e,InProcess); + const DOMElement* SHAR=XMLHelper::getFirstChildElement(e, OutOfProcess); + const DOMElement* SHIRE=XMLHelper::getFirstChildElement(e, InProcess); - // Initialize log4cpp manually in order to redirect log messages as soon as possible. + // Initialize logging manually in order to redirect log messages as soon as possible. if (conf.isEnabled(SPConfig::Logging)) { - const XMLCh* logconf=nullptr; + string logconf; if (conf.isEnabled(SPConfig::OutOfProcess)) - logconf=SHAR->getAttributeNS(nullptr,logger); + logconf = XMLHelper::getAttrString(SHAR, nullptr, logger); else if (conf.isEnabled(SPConfig::InProcess)) - logconf=SHIRE->getAttributeNS(nullptr,logger); - if (!logconf || !*logconf) - logconf=e->getAttributeNS(nullptr,logger); - if (logconf && *logconf) { - auto_ptr_char logpath(logconf); - log.debug("loading new logging configuration from (%s), check log destination for status of configuration",logpath.get()); - if (!XMLToolingConfig::getConfig().log_config(logpath.get())) - log.crit("failed to load new logging configuration from (%s)", logpath.get()); + logconf = XMLHelper::getAttrString(SHIRE, nullptr, logger); + if (logconf.empty()) + logconf = XMLHelper::getAttrString(e, nullptr, logger); + if (logconf.empty() && !getenv("SHIBSP_LOGGING")) { + // No properties found, so default them. + if (conf.isEnabled(SPConfig::OutOfProcess) && !conf.isEnabled(SPConfig::InProcess)) + logconf = "shibd.logger"; + else if (!conf.isEnabled(SPConfig::OutOfProcess) && conf.isEnabled(SPConfig::InProcess)) + logconf = "native.logger"; + else + logconf = "shibboleth.logger"; + } + if (!logconf.empty()) { + log.debug("loading new logging configuration from (%s), check log destination for status of configuration", logconf.c_str()); + if (!XMLToolingConfig::getConfig().log_config(logconf.c_str())) + log.crit("failed to load new logging configuration from (%s)", logconf.c_str()); } #ifndef SHIBSP_LITE -- 2.1.4