From bafd4449ff851076b69ffaf918068465a726d928 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 27 Jun 2011 23:07:28 +0200 Subject: [PATCH] logind: properly detect whether we got the bus name --- src/logind.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/logind.c b/src/logind.c index 25773209..863b1636 100644 --- a/src/logind.c +++ b/src/logind.c @@ -764,8 +764,15 @@ static int manager_connect_bus(Manager *m) { goto fail; } - if (dbus_bus_request_name(m->bus, "org.freedesktop.login1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) < 0) { - log_error("Failed to register name on bus: %s", error.message); + r = dbus_bus_request_name(m->bus, "org.freedesktop.login1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error); + if (dbus_error_is_set(&error)) { + log_error("Failed to register name on bus: %s", bus_error_message(&error)); + r = -EIO; + goto fail; + } + + if (r != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + log_error("Failed to acquire name."); r = -EEXIST; goto fail; } -- 2.39.5