Enable client type certificate install interface
Added support to restart unit, incase reload is not supported
by the unit, also enabled client certificate install function.
Change-Id: I68b7eeb1f81f6faf65dcfb8e6c5b9b907145747a
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/certs_manager.cpp b/certs_manager.cpp
index 4017ff7..28b0957 100644
--- a/certs_manager.cpp
+++ b/certs_manager.cpp
@@ -73,16 +73,19 @@
{
if (!unit.empty())
{
- reload(unit);
+ reloadOrReset(unit);
}
}
void Manager::clientInstall()
{
- // Do nothing now
+ if (!unit.empty())
+ {
+ reloadOrReset(unit);
+ }
}
-void Manager::reload(const std::string& unit)
+void Manager::reloadOrReset(const std::string& unit)
{
constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
@@ -90,8 +93,9 @@
try
{
- auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
- SYSTEMD_INTERFACE, "ReloadUnit");
+ auto method =
+ bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
+ SYSTEMD_INTERFACE, "ReloadOrRestartUnit");
method.append(unit, "replace");
@@ -99,7 +103,8 @@
}
catch (const sdbusplus::exception::SdBusError& e)
{
- log<level::ERR>("Failed to reload service", entry("ERR=%s", e.what()),
+ log<level::ERR>("Failed to reload or restart service",
+ entry("ERR=%s", e.what()),
entry("UNIT=%s", unit.c_str()));
elog<InternalFailure>();
}
diff --git a/certs_manager.hpp b/certs_manager.hpp
index c71609c..027317e 100644
--- a/certs_manager.hpp
+++ b/certs_manager.hpp
@@ -77,10 +77,11 @@
/** @brief Server certificate Installation helper function **/
virtual void serverInstall();
- /** @brief systemd unit reload helper function
- * @param[in] unit - service need to reload.
+ /** @brief systemd unit reload or reset helper function
+ * Reload if the unit supports it and use a restart otherwise.
+ * @param[in] unit - service need to reload.
*/
- void reload(const std::string& unit);
+ void reloadOrReset(const std::string& unit);
/** @brief helper function to copy the file.
* @param[in] src - Source file path to copy