diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/dbus-common.c | 11 | ||||
-rw-r--r-- | src/shared/dbus-common.h | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/shared/dbus-common.c b/src/shared/dbus-common.c index e161273cd8..ddb50b1eca 100644 --- a/src/shared/dbus-common.c +++ b/src/shared/dbus-common.c @@ -245,7 +245,8 @@ int bus_connect_system_polkit(DBusConnection **_bus, DBusError *error) { } const char *bus_error_message(const DBusError *error) { - assert(error); + if (!error) + return NULL; /* Sometimes the D-Bus server is a little bit too verbose with * its error messages, so let's override them here */ @@ -255,6 +256,14 @@ const char *bus_error_message(const DBusError *error) { return error->message; } +const char *bus_error_message_or_strerror(const DBusError *error, int err) { + + if (error && dbus_error_is_set(error)) + return bus_error_message(error); + + return strerror(err); +} + DBusHandlerResult bus_default_message_handler( DBusConnection *c, DBusMessage *message, diff --git a/src/shared/dbus-common.h b/src/shared/dbus-common.h index edb8107347..9ae35df9c5 100644 --- a/src/shared/dbus-common.h +++ b/src/shared/dbus-common.h @@ -91,6 +91,7 @@ int bus_connect_system_ssh(const char *user, const char *host, DBusConnection ** int bus_connect_system_polkit(DBusConnection **_bus, DBusError *error); const char *bus_error_message(const DBusError *error); +const char *bus_error_message_or_strerror(const DBusError *error, int err); typedef int (*BusPropertyCallback)(DBusMessageIter *iter, const char *property, void *data); typedef int (*BusPropertySetCallback)(DBusMessageIter *iter, const char *property, void *data); |