diff options
author | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2013-06-28 10:30:15 +0000 |
---|---|---|
committer | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2013-06-28 10:30:15 +0000 |
commit | daba2f7416861898b2c01926ae6a2ef19fecfaab (patch) | |
tree | 6b159c5e7d612368e6bbb8e138ae3db15005c201 /src/core/dbus.c | |
parent | 9a332ba261bea9e9f3c0915bc6f0c6a0d45a1d5d (diff) | |
parent | 606c24e3bd41207c395f24a56bcfcad791e265a5 (diff) | |
download | systemd-daba2f7416861898b2c01926ae6a2ef19fecfaab.tar.gz |
Merge tag 'v204' into new-systemd
systemd 204
Diffstat (limited to 'src/core/dbus.c')
-rw-r--r-- | src/core/dbus.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/core/dbus.c b/src/core/dbus.c index 2a1c66054a..1272c938cf 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -48,7 +48,7 @@ #include "special.h" #include "dbus-common.h" -#define CONNECTIONS_MAX 52 +#define CONNECTIONS_MAX 512 /* Well-known address (http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-types) */ #define DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:path=/var/run/dbus/system_bus_socket" @@ -203,13 +203,11 @@ static void bus_toggle_watch(DBusWatch *bus_watch, void *data) { } static int bus_timeout_arm(Manager *m, Watch *w) { - struct itimerspec its; + struct itimerspec its = {}; assert(m); assert(w); - zero(its); - if (dbus_timeout_get_enabled(w->data.bus_timeout)) { timespec_store(&its.it_value, dbus_timeout_get_interval(w->data.bus_timeout) * USEC_PER_MSEC); its.it_interval = its.it_value; @@ -365,8 +363,8 @@ static DBusHandlerResult api_bus_message_filter(DBusConnection *connection, DBus log_debug("Got D-Bus activation request for %s", name); - if (manager_unit_pending_inactive(m, SPECIAL_DBUS_SERVICE) || - manager_unit_pending_inactive(m, SPECIAL_DBUS_SOCKET)) { + if (manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SERVICE) || + manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SOCKET)) { r = -EADDRNOTAVAIL; dbus_set_error(&error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is shutting down."); } else { @@ -406,7 +404,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 +976,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 +1051,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 +1074,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); } |