Hard-coded service name replaced with call to ObjectMapper
In the openbmc code, the dbus service name is hardcoded.
The ObjectMapper provides a way to find out the service name by
issuing a GetObject method call to the ObjectMapper.
That functionality is implemented in mapper.c
The output of the call to the mapper is a service name.
Resolves openbmc/openbmc#319.
Change-Id: I724a31ede6bdf3ae4b361e730857b1f2696a8966
Signed-off-by: Sergey Solomin <sergey.solomin@us.ibm.com>
diff --git a/ipmid.cpp b/ipmid.cpp
index 7848afe..31608e9 100644
--- a/ipmid.cpp
+++ b/ipmid.cpp
@@ -35,7 +35,6 @@
}
// Host settings in DBUS
-constexpr char settings_host_bus[] = "org.openbmc.settings.Host";
constexpr char settings_host_object[] = "/org/openbmc/settings/host0";
constexpr char settings_host_intf[] = "org.freedesktop.DBus.Properties";
@@ -271,16 +270,22 @@
sd_bus_message *reply = NULL;
sd_bus_error error = SD_BUS_ERROR_NULL;
int rc = 0;
+ char *busname = NULL;
+ rc = mapper_get_service(bus, settings_host_object, &busname);
+ if (rc < 0) {
+ fprintf(stderr, "Failed to get HOST busname: %s\n", strerror(-rc));
+ goto cleanup;
+ }
rc = sd_bus_call_method(bus,
- settings_host_bus,
+ busname,
settings_host_object,
settings_host_intf,
"Get",
&error,
&reply,
"ss",
- settings_host_bus,
+ "org.openbmc.settings.Host",
"restricted_mode");
if(rc < 0)
{
@@ -303,6 +308,7 @@
cleanup:
sd_bus_error_free(&error);
reply = sd_bus_message_unref(reply);
+ free(busname);
}
static int handle_restricted_mode_change(sd_bus_message *m, void *user_data,