blob: 5386c0e87c24c426ca3232d4ac42b46f0ef17a7f [file] [log] [blame]
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -05001#include "config.h"
Patrick Williams9638afb2021-02-22 17:16:24 -06002
Ratan Guptae1f4db62019-04-11 18:57:42 +05303#include "ldap_config_mgr.hpp"
Patrick Williams9638afb2021-02-22 17:16:24 -06004
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -05005#include <phosphor-logging/elog-errors.hpp>
Jiaqing Zhao11ec6662022-07-05 20:55:34 +08006#include <phosphor-logging/lg2.hpp>
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -05007#include <sdbusplus/bus.hpp>
8#include <xyz/openbmc_project/Common/error.hpp>
9
Patrick Williams9638afb2021-02-22 17:16:24 -060010#include <filesystem>
11
Ratan Gupta0b1ad3d2022-01-09 14:09:35 +053012int main(int /*argc*/, char** /*argv*/)
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050013{
14 using namespace phosphor::logging;
15 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050016
Gunnar Mills703131f2020-10-28 14:26:33 -050017 std::filesystem::path configDir =
18 std::filesystem::path(LDAP_CONFIG_FILE).parent_path();
19
Patrick Williams16c2b682024-08-16 15:20:56 -040020 if (!std::filesystem::exists(
21 configDir / phosphor::ldap::defaultNslcdFile) ||
Gunnar Mills703131f2020-10-28 14:26:33 -050022 !std::filesystem::exists(configDir / phosphor::ldap::nsSwitchFile))
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050023 {
Jiaqing Zhao11ec6662022-07-05 20:55:34 +080024 lg2::error("Failed to start phosphor-ldap-manager, configfile(s) are "
25 "missing");
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050026 elog<InternalFailure>();
27 }
28 auto bus = sdbusplus::bus::new_default();
29
30 // Add sdbusplus ObjectManager for the 'root' path of the LDAP config.
Patrick Williamsb3ef4e12022-07-22 19:26:55 -050031 sdbusplus::server::manager_t objManager(bus, LDAP_CONFIG_ROOT);
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050032
Nagaraju Goruganti3b4d06a2018-11-08 03:13:38 -060033 phosphor::ldap::ConfigMgr mgr(bus, LDAP_CONFIG_ROOT, LDAP_CONFIG_FILE,
Zbigniew Kurzynski5d00cf22019-10-03 12:10:20 +020034 LDAP_CONF_PERSIST_PATH, TLS_CACERT_PATH,
Ratan Gupta22f13f12019-04-29 15:36:40 +053035 TLS_CERT_FILE);
Ratan Gupta21e88cb2019-04-12 17:15:52 +053036 mgr.restore();
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050037
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}