Don't use "-" in a DBus interface path and name
Current code use device name "ipmi-kcs*" as a part of a naming
for Dbus interface. It is not possible to use it as is, because
"-" symbol is not permitted by DBus specification. Therefore
replace it with "_".
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Change-Id: I7de6acb52d26015c6984156f7167fe228ccc3d1e
diff --git a/kcsbridged.cpp b/kcsbridged.cpp
index 38911fa..00914b5 100644
--- a/kcsbridged.cpp
+++ b/kcsbridged.cpp
@@ -17,6 +17,7 @@
#include <linux/ipmi_bmc.h>
#include <CLI/CLI.hpp>
+#include <boost/algorithm/string/replace.hpp>
#include <boost/asio.hpp>
#include <iostream>
#include <phosphor-logging/log.hpp>
@@ -113,8 +114,9 @@
static constexpr const char pathBase[] =
"/xyz/openbmc_project/Ipmi/Channel/";
std::shared_ptr<sdbusplus::asio::dbus_interface> iface =
- server->add_interface(pathBase + channel,
- "xyz.openbmc_project.Ipmi.Channel.SMS");
+ server->add_interface(
+ pathBase + boost::replace_all_copy(channel, "-", "_"),
+ "xyz.openbmc_project.Ipmi.Channel.SMS");
iface->register_method("setAttention",
[this]() { return setAttention(); });
iface->register_method("clearAttention",
@@ -331,7 +333,7 @@
}
static constexpr const char busBase[] = "xyz.openbmc_project.Ipmi.Channel.";
- std::string busName(busBase + channel);
+ std::string busName(busBase + boost::replace_all_copy(channel, "-", "_"));
bus->request_name(busName.c_str());
io->run();