Add new LDAP config package

Package app phosphor-ldap-conf. This app implements an API to update
the LDAP config file i.e /etc/nslcd.conf.

This commit also creates a file:/etc/nslcd.conf.default, which is to
be restored as /etc/nslcd.conf when we disable LDAP configuration.

Change-Id: Icde4264f4a9337775563f344fd2e300bf0897c52
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
diff --git a/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb b/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
index d6537f5..6e23d15 100644
--- a/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
+++ b/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
@@ -139,4 +139,5 @@
 RDEPENDS_${PN}-user-mgmt = " \
         ${VIRTUAL-RUNTIME_obmc-user-mgmt} \
         ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', 'nss-pam-ldapd', '', d)} \
+        ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', 'phosphor-ldap', '', d)} \
         "
diff --git a/recipes-phosphor/users/phosphor-user-manager/xyz.openbmc_project.Ldap.Config.service b/recipes-phosphor/users/phosphor-user-manager/xyz.openbmc_project.Ldap.Config.service
new file mode 100644
index 0000000..dc6d0da
--- /dev/null
+++ b/recipes-phosphor/users/phosphor-user-manager/xyz.openbmc_project.Ldap.Config.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Phosphor Ldap config updater
+Wants=nslcd.service nscd.service
+After=nslcd.service nscd.service
+Before=xyz.openbmc_project.Software.Sync.service
+
+[Service]
+ExecStart=/usr/bin/env phosphor-ldap-conf
+SyslogIdentifier=phosphor-ldap-conf
+Restart=always
+Type=dbus
+BusName={BUSNAME}
+
+[Install]
+WantedBy={SYSTEMD_DEFAULT_TARGET}
diff --git a/recipes-phosphor/users/phosphor-user-manager_git.bb b/recipes-phosphor/users/phosphor-user-manager_git.bb
index 87d2d94..d0f261f 100644
--- a/recipes-phosphor/users/phosphor-user-manager_git.bb
+++ b/recipes-phosphor/users/phosphor-user-manager_git.bb
@@ -15,17 +15,22 @@
 DEPENDS += "phosphor-dbus-interfaces"
 DEPENDS += "boost"
 DEPENDS += "nss-pam-ldapd"
+PACKAGE_BEFORE_PN = "phosphor-ldap"
 RDEPENDS_${PN} += "libsystemd"
 RDEPENDS_${PN} += "phosphor-logging"
 
 inherit useradd
 
-USERADD_PACKAGES = "${PN}"
+USERADD_PACKAGES = "${PN} phosphor-ldap"
+DBUS_PACKAGES = "${USERADD_PACKAGES}"
 # add groups needed for privilege maintenance
 GROUPADD_PARAM_${PN} = "priv-admin; priv-operator; priv-user; priv-callback "
-
+GROUPADD_PARAM_phosphor-ldap = "priv-admin; priv-operator; priv-user; priv-callback "
 DBUS_SERVICE_${PN} += "xyz.openbmc_project.User.Manager.service"
-
+FILES_phosphor-ldap += " \
+        ${sbindir}/phosphor-ldap-conf \
+"
+DBUS_SERVICE_phosphor-ldap = "xyz.openbmc_project.Ldap.Config.service"
 SRC_URI += "git://github.com/openbmc/phosphor-user-manager"
 SRCREV = "9891f2f8f330cfe678098342bd1cb536e5810233"
 S = "${WORKDIR}/git"
diff --git a/recipes-support/nss-pam-ldapd_fix/nss-pam-ldapd_%.bbappend b/recipes-support/nss-pam-ldapd_fix/nss-pam-ldapd_%.bbappend
new file mode 100644
index 0000000..d1b092d
--- /dev/null
+++ b/recipes-support/nss-pam-ldapd_fix/nss-pam-ldapd_%.bbappend
@@ -0,0 +1,3 @@
+do_install_append() {
+        install -m 0644 ${D}${sysconfdir}/nslcd.conf ${D}${sysconfdir}/nslcd.conf.default
+}