From c9c86a2cf57a0cb87ba469ddd69169409fc2b55b Mon Sep 17 00:00:00 2001 From: Ratan Gupta Date: Thu, 18 Oct 2018 00:47:01 +0530 Subject: phosphor-ldap-conf: Don't create the LDAP config object During restore path(i.e while phosphor-ldap-conf service restarts) after parsing the file if any of the LDAP parameter(BindDN,BaseDN,URI) is having empty value then don't create the LDAP config object. Before this commit the config object was not being created but it throws a unnecessary log in the journal due to creation of errorlog. In restore path we don't want the errorlog. This commit fixes the problem of creating unnecesary log in the journal. Change-Id: I074fe96a6c6382bc2d31e91df1275756b57c1045 Signed-off-by: Ratan Gupta Signed-off-by: Nagaraju Goruganti --- phosphor-ldap-config/ldap_configuration.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'phosphor-ldap-config/ldap_configuration.cpp') diff --git a/phosphor-ldap-config/ldap_configuration.cpp b/phosphor-ldap-config/ldap_configuration.cpp index 5582bf1..3e31e41 100644 --- a/phosphor-ldap-config/ldap_configuration.cpp +++ b/phosphor-ldap-config/ldap_configuration.cpp @@ -540,6 +540,18 @@ void ConfigMgr::restore(const char* filePath) lDAPType = ldap_base::Create::Type::OpenLdap; } + // Don't create the config object if either of the field is empty. + if (configValues["uri"] == "" || configValues["binddn"] == "" || + configValues["base"] == "") + { + log( + "LDAP config parameter value missing", + entry("URI=%s", configValues["uri"].c_str()), + entry("BASEDN=%s", configValues["base"].c_str()), + entry("BINDDN=%s", configValues["binddn"].c_str())); + return; + } + createConfig( std::move(configValues["uri"]), std::move(configValues["binddn"]), std::move(configValues["base"]), std::move(configValues["bindpw"]), -- cgit v1.2.1