Write the config data into the nslcd.conf file
In Config object we have the property enabled, when
it is true then write that config object into nslcd.conf
TestedBy: Unit tested
Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
Change-Id: I0c7bcf0f6557adb9314c94768b1adac39459fbe4
diff --git a/phosphor-ldap-config/ldap_config.cpp b/phosphor-ldap-config/ldap_config.cpp
index aa984c6..746f324 100644
--- a/phosphor-ldap-config/ldap_config.cpp
+++ b/phosphor-ldap-config/ldap_config.cpp
@@ -50,7 +50,10 @@
ConfigIface::userNameAttribute(userNameAttr);
ConfigIface::groupNameAttribute(groupNameAttr);
// Don't update the bindDN password under ConfigIface::
- writeConfig();
+ if (enabled())
+ {
+ writeConfig();
+ }
// Emit deferred signal.
this->emit_object_added();
parent.startOrStopService(nslcdService, enabled());
@@ -187,8 +190,11 @@
lDAPBindPassword = value;
try
{
- writeConfig();
- parent.startOrStopService(nslcdService, enabled());
+ if (enabled())
+ {
+ writeConfig();
+ parent.startOrStopService(nslcdService, enabled());
+ }
}
catch (const InternalFailure& e)
{
@@ -234,8 +240,11 @@
elog<NoCACertificate>();
}
val = ConfigIface::lDAPServerURI(value);
- writeConfig();
- parent.startOrStopService(nslcdService, enabled());
+ if (enabled())
+ {
+ writeConfig();
+ parent.startOrStopService(nslcdService, enabled());
+ }
}
catch (const InternalFailure& e)
{
@@ -276,8 +285,11 @@
}
val = ConfigIface::lDAPBindDN(value);
- writeConfig();
- parent.startOrStopService(nslcdService, enabled());
+ if (enabled())
+ {
+ writeConfig();
+ parent.startOrStopService(nslcdService, enabled());
+ }
}
catch (const InternalFailure& e)
{
@@ -314,8 +326,11 @@
}
val = ConfigIface::lDAPBaseDN(value);
- writeConfig();
- parent.startOrStopService(nslcdService, enabled());
+ if (enabled())
+ {
+ writeConfig();
+ parent.startOrStopService(nslcdService, enabled());
+ }
}
catch (const InternalFailure& e)
{
@@ -344,8 +359,12 @@
}
val = ConfigIface::lDAPSearchScope(value);
- writeConfig();
- parent.startOrStopService(nslcdService, enabled());
+ if (enabled())
+ {
+ writeConfig();
+
+ parent.startOrStopService(nslcdService, enabled());
+ }
}
catch (const InternalFailure& e)
{
@@ -375,9 +394,15 @@
return value;
}
isEnable = EnableIface::enabled(value);
+ if (isEnable)
+ {
+ writeConfig();
+ }
+ // TODO in later commit, one of the config would be active
+ // at any moment of time.
+ parent.startOrStopService(nslcdService, value);
// save the enabled property.
serialize(*this, parent.dbusPersistentPath);
- parent.startOrStopService(nslcdService, value);
}
catch (const InternalFailure& e)
{
@@ -402,8 +427,12 @@
}
val = ConfigIface::userNameAttribute(value);
- writeConfig();
- parent.startOrStopService(nslcdService, enabled());
+ if (enabled())
+ {
+ writeConfig();
+
+ parent.startOrStopService(nslcdService, enabled());
+ }
}
catch (const InternalFailure& e)
{
@@ -428,8 +457,12 @@
}
val = ConfigIface::groupNameAttribute(value);
- writeConfig();
- parent.startOrStopService(nslcdService, enabled());
+ if (enabled())
+ {
+ writeConfig();
+
+ parent.startOrStopService(nslcdService, enabled());
+ }
}
catch (const InternalFailure& e)
{