From eb9b814403895d6435e04f02a9ff6c2b1b02cf54 Mon Sep 17 00:00:00 2001 From: Sergey Solomin Date: Tue, 23 Aug 2016 09:07:28 -0500 Subject: 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 --- ipmid.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'ipmid.cpp') diff --git a/ipmid.cpp b/ipmid.cpp index 7848afe..31608e9 100644 --- a/ipmid.cpp +++ b/ipmid.cpp @@ -35,7 +35,6 @@ void print_usage(void) { } // 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 @@ void cache_restricted_mode() 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 @@ void cache_restricted_mode() 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, -- cgit v1.2.1