]> err.no Git - systemd/commitdiff
dbus: fix name allocation logic
authorLennart Poettering <lennart@poettering.net>
Mon, 27 Jun 2011 21:15:57 +0000 (23:15 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 27 Jun 2011 21:15:57 +0000 (23:15 +0200)
src/hostnamed.c
src/localed.c
src/timedated.c

index c6b63cd9777ef900a5171e1ef3195f38acefd87a..7b2ce691a378a244bbb5112753ffad8792c98659 100644 (file)
@@ -524,8 +524,15 @@ static int connect_bus(DBusConnection **_bus) {
                 goto fail;
         }
 
-        if (dbus_bus_request_name(bus, "org.freedesktop.hostname1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) < 0) {
-                log_error("Failed to register name on bus: %s", error.message);
+        r = dbus_bus_request_name(bus, "org.freedesktop.hostname1", 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 = -EEXIST;
+                goto fail;
+        }
+
+        if (r != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+                log_error("Failed to acquire name.");
                 r = -EEXIST;
                 goto fail;
         }
index 5efee0b2ac99b747c786906c34b9f19dadedd6c1..93e4e9bd56f2e181863ccdbc28337d17924fbd2c 100644 (file)
@@ -540,8 +540,15 @@ static int connect_bus(DBusConnection **_bus) {
                 goto fail;
         }
 
-        if (dbus_bus_request_name(bus, "org.freedesktop.locale1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) < 0) {
-                log_error("Failed to register name on bus: %s", error.message);
+        r = dbus_bus_request_name(bus, "org.freedesktop.locale1", 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 = -EEXIST;
+                goto fail;
+        }
+
+        if (r != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+                log_error("Failed to acquire name.");
                 r = -EEXIST;
                 goto fail;
         }
index 097e0a00c27e6abfe58b29fc5d124a55516d5453..55cc904f0cd236d9ea99e8bb9e0e0fe90f1bcb43 100644 (file)
@@ -543,8 +543,15 @@ static int connect_bus(DBusConnection **_bus) {
                 goto fail;
         }
 
-        if (dbus_bus_request_name(bus, "org.freedesktop.timedate1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) < 0) {
-                log_error("Failed to register name on bus: %s", error.message);
+        r = dbus_bus_request_name(bus, "org.freedesktop.timedate1", 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 = -EEXIST;
+                goto fail;
+        }
+
+        if (r != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)  {
+                log_error("Failed to acquire name.");
                 r = -EEXIST;
                 goto fail;
         }