LDAP: start or stop nslcd on service starting
`nslcd` service should be started only if there is a valid endpoint.
This commit adds a call that starts or stops `nslcd.service` after
the Dbus objects has been deserialized, depending by the presence of
enabled endpoint.
Tested:
1. Made sure `nslcd` is stopped by default.
2. Added a configuration for AD/LDAP endpoint and made sure `nslcd`
is started.
3. Rebooted BMC and made sure `nslcd` is started.
Change-Id: I06d91cb450e92bdfb12c4f65dce4e250113ab461
Signed-off-by: Alexander Filippov <a.filippov@yadro.com>
diff --git a/phosphor-ldap-config/ldap_config_mgr.cpp b/phosphor-ldap-config/ldap_config_mgr.cpp
index e8490e4..1218d18 100644
--- a/phosphor-ldap-config/ldap_config_mgr.cpp
+++ b/phosphor-ldap-config/ldap_config_mgr.cpp
@@ -12,6 +12,7 @@
namespace ldap
{
+constexpr auto nslcdService = "nslcd.service";
constexpr auto nscdService = "nscd.service";
constexpr auto LDAPscheme = "ldap";
constexpr auto LDAPSscheme = "ldaps";
@@ -211,6 +212,9 @@
openLDAPConfigPtr->restoreRoleMapping();
openLDAPConfigPtr->emit_object_added();
}
+
+ startOrStopService(phosphor::ldap::nslcdService,
+ ADConfigPtr->enabled() || openLDAPConfigPtr->enabled());
}
} // namespace ldap