summaryrefslogtreecommitdiffstats
path: root/phosphor-ldap-config/ldap_configuration.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'phosphor-ldap-config/ldap_configuration.hpp')
-rw-r--r--phosphor-ldap-config/ldap_configuration.hpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/phosphor-ldap-config/ldap_configuration.hpp b/phosphor-ldap-config/ldap_configuration.hpp
index f2bf02a..a0324c1 100644
--- a/phosphor-ldap-config/ldap_configuration.hpp
+++ b/phosphor-ldap-config/ldap_configuration.hpp
@@ -1,9 +1,14 @@
#pragma once
-#include <sdbusplus/bus.hpp>
-#include <sdbusplus/server/object.hpp>
+#include "config.h"
#include <xyz/openbmc_project/User/Ldap/Config/server.hpp>
#include <xyz/openbmc_project/User/Ldap/Create/server.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server/object.hpp>
#include <string>
namespace phosphor
@@ -15,6 +20,8 @@ static constexpr auto nsSwitchFile = "/etc/nsswitch.conf";
static constexpr auto LDAPNsSwitchFile = "/etc/nsswitch_ldap.conf";
static constexpr auto linuxNsSwitchFile = "/etc/nsswitch_linux.conf";
+using namespace phosphor::logging;
+using namespace sdbusplus::xyz::openbmc_project::Common::Error;
namespace ldap_base = sdbusplus::xyz::openbmc_project::User::Ldap::server;
using ConfigIface = sdbusplus::server::object::object<ldap_base::Config>;
using CreateIface = sdbusplus::server::object::object<ldap_base::Create>;
@@ -144,9 +151,19 @@ class ConfigMgr : public CreateIface
* @param[in] filePath - LDAP configuration file.
*/
ConfigMgr(sdbusplus::bus::bus& bus, const char* path) :
- CreateIface(bus, path), bus(bus)
+ CreateIface(bus, path, true), bus(bus)
{
- // TODO restore config object if config file exists.
+ try
+ {
+ restore(LDAP_CONFIG_FILE);
+ emit_object_added();
+ }
+ catch (const std::exception& e)
+ {
+ configPtr.reset(nullptr);
+ log<level::ERR>(e.what());
+ elog<InternalFailure>();
+ }
}
/** @brief concrete implementation of the pure virtual funtion
@@ -179,6 +196,11 @@ class ConfigMgr : public CreateIface
/** @brief Pointer to a Config D-Bus object */
std::unique_ptr<Config> configPtr = nullptr;
+
+ /** @brief Populate existing config into D-Bus properties
+ * @param[in] filePath - LDAP config file path
+ */
+ virtual void restore(const char* filePath);
};
} // namespace ldap
} // namespace phosphor
OpenPOWER on IntegriCloud