chiark / gitweb /
Remove some dead code
[elogind.git] / src / core / dbus.c
index 2a1c66054a1cb0d8d3c219955d54f40c02d8e974..b92c7d0b99923cc739f7d224fcc3f03fca3bd435 100644 (file)
@@ -406,7 +406,7 @@ static DBusHandlerResult api_bus_message_filter(DBusConnection *connection, DBus
         dbus_error_free(&error);
 
         if (reply) {
-                if (!dbus_connection_send(connection, reply, NULL))
+                if (!bus_maybe_send_reply(connection, message, reply))
                         goto oom;
 
                 dbus_message_unref(reply);
@@ -978,9 +978,8 @@ static DBusConnection* manager_bus_connect_private(Manager *m, DBusBusType type)
         }
 
         return connection;
+
 fail:
-        if (connection)
-                dbus_connection_close(connection);
         dbus_error_free(&error);
         return NULL;
 }
@@ -1054,7 +1053,7 @@ fail:
 static int bus_init_private(Manager *m) {
         DBusError error;
         int r;
-        const char *const external_only[] = {
+        static const char *const external_only[] = {
                 "EXTERNAL",
                 NULL
         };
@@ -1077,18 +1076,33 @@ static int bus_init_private(Manager *m) {
         } else {
                 const char *e;
                 char *p;
+                char *escaped;
 
                 e = secure_getenv("XDG_RUNTIME_DIR");
                 if (!e)
                         return 0;
 
-                if (asprintf(&p, "unix:path=%s/systemd/private", e) < 0) {
+                if (asprintf(&p, "%s/systemd/private", e) < 0) {
+                        r = log_oom();
+                        goto fail;
+                }
+
+                mkdir_parents_label(p, 0755);
+                unlink(p);
+                free(p);
+
+                escaped = dbus_address_escape_value(e);
+                if (!escaped) {
+                        r = log_oom();
+                        goto fail;
+                }
+                if (asprintf(&p, "unix:path=%s/systemd/private", escaped) < 0) {
+                        dbus_free(escaped);
                         r = log_oom();
                         goto fail;
                 }
+                dbus_free(escaped);
 
-                mkdir_parents_label(p+10, 0755);
-                unlink(p+10);
                 m->private_bus = dbus_server_listen(p, &error);
                 free(p);
         }