1 #include "config.h"
2 
3 #include "ldap_config_mgr.hpp"
4 
5 #include <phosphor-logging/elog-errors.hpp>
6 #include <phosphor-logging/lg2.hpp>
7 #include <sdbusplus/bus.hpp>
8 #include <xyz/openbmc_project/Common/error.hpp>
9 
10 #include <filesystem>
11 
main(int,char **)12 int main(int /*argc*/, char** /*argv*/)
13 {
14     using namespace phosphor::logging;
15     using namespace sdbusplus::xyz::openbmc_project::Common::Error;
16 
17     std::filesystem::path configDir =
18         std::filesystem::path(LDAP_CONFIG_FILE).parent_path();
19 
20     if (!std::filesystem::exists(
21             configDir / phosphor::ldap::defaultNslcdFile) ||
22         !std::filesystem::exists(configDir / phosphor::ldap::nsSwitchFile))
23     {
24         lg2::error("Failed to start phosphor-ldap-manager, configfile(s) are "
25                    "missing");
26         elog<InternalFailure>();
27     }
28     auto bus = sdbusplus::bus::new_default();
29 
30     // Add sdbusplus ObjectManager for the 'root' path of the LDAP config.
31     sdbusplus::server::manager_t objManager(bus, LDAP_CONFIG_ROOT);
32 
33     phosphor::ldap::ConfigMgr mgr(bus, LDAP_CONFIG_ROOT, LDAP_CONFIG_FILE,
34                                   LDAP_CONF_PERSIST_PATH, TLS_CACERT_PATH,
35                                   TLS_CERT_FILE);
36     mgr.restore();
37 
38     bus.request_name(LDAP_CONFIG_BUSNAME);
39 
40     while (true)
41     {
42         bus.process_discard();
43         bus.wait();
44     }
45 
46     return 0;
47 }
48