| Nagaraju Goruganti | 997f5e0 | 2018-08-30 03:05:11 -0500 | [diff] [blame] | 1 | #include "config.h" | 
| Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 2 |  | 
| Ratan Gupta | e1f4db6 | 2019-04-11 18:57:42 +0530 | [diff] [blame] | 3 | #include "ldap_config_mgr.hpp" | 
| Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 4 |  | 
| Nagaraju Goruganti | 997f5e0 | 2018-08-30 03:05:11 -0500 | [diff] [blame] | 5 | #include <phosphor-logging/elog-errors.hpp> | 
| Jiaqing Zhao | 11ec666 | 2022-07-05 20:55:34 +0800 | [diff] [blame] | 6 | #include <phosphor-logging/lg2.hpp> | 
| Nagaraju Goruganti | 997f5e0 | 2018-08-30 03:05:11 -0500 | [diff] [blame] | 7 | #include <sdbusplus/bus.hpp> | 
|  | 8 | #include <xyz/openbmc_project/Common/error.hpp> | 
|  | 9 |  | 
| Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 10 | #include <filesystem> | 
|  | 11 |  | 
| Ratan Gupta | 0b1ad3d | 2022-01-09 14:09:35 +0530 | [diff] [blame] | 12 | int main(int /*argc*/, char** /*argv*/) | 
| Nagaraju Goruganti | 997f5e0 | 2018-08-30 03:05:11 -0500 | [diff] [blame] | 13 | { | 
|  | 14 | using namespace phosphor::logging; | 
|  | 15 | using namespace sdbusplus::xyz::openbmc_project::Common::Error; | 
| Nagaraju Goruganti | 997f5e0 | 2018-08-30 03:05:11 -0500 | [diff] [blame] | 16 |  | 
| Gunnar Mills | 703131f | 2020-10-28 14:26:33 -0500 | [diff] [blame] | 17 | std::filesystem::path configDir = | 
|  | 18 | std::filesystem::path(LDAP_CONFIG_FILE).parent_path(); | 
|  | 19 |  | 
| Patrick Williams | 16c2b68 | 2024-08-16 15:20:56 -0400 | [diff] [blame^] | 20 | if (!std::filesystem::exists( | 
|  | 21 | configDir / phosphor::ldap::defaultNslcdFile) || | 
| Gunnar Mills | 703131f | 2020-10-28 14:26:33 -0500 | [diff] [blame] | 22 | !std::filesystem::exists(configDir / phosphor::ldap::nsSwitchFile)) | 
| Nagaraju Goruganti | 997f5e0 | 2018-08-30 03:05:11 -0500 | [diff] [blame] | 23 | { | 
| Jiaqing Zhao | 11ec666 | 2022-07-05 20:55:34 +0800 | [diff] [blame] | 24 | lg2::error("Failed to start phosphor-ldap-manager, configfile(s) are " | 
|  | 25 | "missing"); | 
| Nagaraju Goruganti | 997f5e0 | 2018-08-30 03:05:11 -0500 | [diff] [blame] | 26 | elog<InternalFailure>(); | 
|  | 27 | } | 
|  | 28 | auto bus = sdbusplus::bus::new_default(); | 
|  | 29 |  | 
|  | 30 | // Add sdbusplus ObjectManager for the 'root' path of the LDAP config. | 
| Patrick Williams | b3ef4e1 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 31 | sdbusplus::server::manager_t objManager(bus, LDAP_CONFIG_ROOT); | 
| Nagaraju Goruganti | 997f5e0 | 2018-08-30 03:05:11 -0500 | [diff] [blame] | 32 |  | 
| Nagaraju Goruganti | 3b4d06a | 2018-11-08 03:13:38 -0600 | [diff] [blame] | 33 | phosphor::ldap::ConfigMgr mgr(bus, LDAP_CONFIG_ROOT, LDAP_CONFIG_FILE, | 
| Zbigniew Kurzynski | 5d00cf2 | 2019-10-03 12:10:20 +0200 | [diff] [blame] | 34 | LDAP_CONF_PERSIST_PATH, TLS_CACERT_PATH, | 
| Ratan Gupta | 22f13f1 | 2019-04-29 15:36:40 +0530 | [diff] [blame] | 35 | TLS_CERT_FILE); | 
| Ratan Gupta | 21e88cb | 2019-04-12 17:15:52 +0530 | [diff] [blame] | 36 | mgr.restore(); | 
| Nagaraju Goruganti | 997f5e0 | 2018-08-30 03:05:11 -0500 | [diff] [blame] | 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 | } |