In order to patch #471812, I needed to read a lot of D-Bus properties. Created this function to do the work. Can probably rewrite the get_connection() function to use this new function too, but I will save that for a rainy day. --- loader/net.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ loader/net.h | 2 + 2 files changed, 73 insertions(+), 0 deletions(-) diff --git a/loader/net.c b/loader/net.c index aead300..14508c7 100644 --- a/loader/net.c +++ b/loader/net.c @@ -2020,4 +2020,75 @@ int get_connection(iface_t *iface) { return 9; } +/* + * Get a specific NetworkManager D-Bus property given the D-Bus interface, + * the D-Bus path, and the D-Bus property name. + */ +DBusMessage *get_nm_dbus_property(char *interface, char *path, char *property) { + char *dbus_interface = NULL; + char *dbus_path = NULL; + char *dbus_property = NULL; + DBusConnection *connection = NULL; + DBusError error; + DBusMessage *message = NULL; + DBusMessage *reply = NULL; + + if ((property == NULL) || (path == NULL) || (interface == NULL)) { + fprintf(stderr, "%s (%d): missing required argument\n", + __func__, __LINE__); + return NULL; + } + + dbus_error_init(&error); + connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error); + if (connection == NULL) { + dbus_error_free(&error); + fprintf(stderr, "%s (%d): %s: %s\n", __func__, __LINE__, + error.name, error.message); + return NULL; + } + + dbus_interface = strdup(interface); + dbus_path = strdup(path); + message = dbus_message_new_method_call(dbus_interface, + dbus_path, + DBUS_INTERFACE_PROPERTIES, + "Get"); + if (!message) { + fprintf(stderr, "%s (%d): %s: %s\n", __func__, __LINE__, + error.name, error.message); + free(dbus_interface); + free(dbus_path); + return NULL; + } + + dbus_property = strdup(property); + if (!dbus_message_append_args(message, + DBUS_TYPE_STRING, &dbus_interface, + DBUS_TYPE_STRING, &dbus_property, + DBUS_TYPE_INVALID)) { + dbus_message_unref(message); + fprintf(stderr, "%s (%d): %s: %s\n", __func__, __LINE__, + error.name, error.message); + free(dbus_interface); + free(dbus_path); + free(dbus_property); + return NULL; + } + + reply = dbus_connection_send_with_reply_and_block(connection, message, + -1, &error); + dbus_message_unref(message); + if (!reply) { + fprintf(stderr, "%s (%d): %s: %s\n", __func__, __LINE__, + error.name, error.message); + } + + dbus_connection_unref(connection); + free(dbus_interface); + free(dbus_path); + free(dbus_property); + return reply; +} + /* vim:set shiftwidth=4 softtabstop=4: */ diff --git a/loader/net.h b/loader/net.h index 8245084..25708fb 100644 --- a/loader/net.h +++ b/loader/net.h @@ -20,6 +20,7 @@ #ifndef H_LOADER_NET #define H_LOADER_NET +#include <dbus/dbus.h> #include <newt.h> #include "../isys/iface.h" #include "loader.h" @@ -73,5 +74,6 @@ int kickstartNetworkUp(struct loaderData_s * loaderData, iface_t * iface); void splitHostname (char *str, char **host, char **port); int get_connection(iface_t * iface); +DBusMessage *get_nm_dbus_property(char *interface, char *path, char *property); #endif -- 1.6.0.3 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list