Change the nslcd configuration based on CertificateString Property
- When ever replace client certificate method is called by the
certificate manager, it sends out a PropertyChange Signal which
will be captured by the phosphor-user-manager and inturn it re-writes
the configuration & restarts nslcd accordingly.
- The idea of this commit is to only consider the Property change on
CertificateString Property and write the configuration and not consider
the change in any other property under the same Interface.
TestedBy:
Tried replacing a new client certificate using bustcl call, and verified
that we write the configuration only when the CertificateString Property
is changed.
Signed-off-by: manojkiraneda <manojkiran.eda@gmail.com>
Change-Id: Id1392365127807d2069c391b8ccc2c4c0a9b7215
diff --git a/phosphor-ldap-config/ldap_config.cpp b/phosphor-ldap-config/ldap_config.cpp
index 526310f..e7e191a 100644
--- a/phosphor-ldap-config/ldap_config.cpp
+++ b/phosphor-ldap-config/ldap_config.cpp
@@ -119,7 +119,6 @@
bus, sdbusplus::bus::match::rules::interfacesAdded(authObjPath),
std::bind(std::mem_fn(&Config::certificateInstalled), this,
std::placeholders::_1)),
-
certificateChangedSignal(
bus,
sdbusplus::bus::match::rules::propertiesChanged(certObjPath, certIface),
@@ -160,24 +159,32 @@
void Config::certificateChanged(sdbusplus::message::message& msg)
{
- // TODO: Property filtering needs to be done, we need to write
- // the config only when the property is "Certificate String".
- try
+ std::string objectName;
+ std::map<std::string, sdbusplus::message::variant<std::string>> msgData;
+ msg.read(objectName, msgData);
+ auto valPropMap = msgData.find(certProperty);
{
- if (enabled())
+ if (valPropMap != msgData.end())
{
- writeConfig();
+ try
+ {
+ if (enabled())
+ {
+
+ writeConfig();
+ }
+ parent.startOrStopService(nslcdService, enabled());
+ }
+ catch (const InternalFailure& e)
+ {
+ throw;
+ }
+ catch (const std::exception& e)
+ {
+ log<level::ERR>(e.what());
+ elog<InternalFailure>();
+ }
}
- parent.startOrStopService(nslcdService, enabled());
- }
- catch (const InternalFailure& e)
- {
- throw;
- }
- catch (const std::exception& e)
- {
- log<level::ERR>(e.what());
- elog<InternalFailure>();
}
}