]> err.no Git - systemd/commitdiff
logind: properly detect whether we got the bus name
authorLennart Poettering <lennart@poettering.net>
Mon, 27 Jun 2011 21:07:28 +0000 (23:07 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 27 Jun 2011 21:07:28 +0000 (23:07 +0200)
src/logind.c

index 25773209ea0945bd78e853828f07ade626db0468..863b1636df89a9fc8d0ee377a12a9737822d779d 100644 (file)
@@ -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;
         }