summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-02-07 21:14:56 +0000
committerLennart Poettering <lennart@poettering.net>2013-03-06 17:23:49 +0100
commit92f303495868f7d6971b7f42c69f63cb0e2e0ebd (patch)
tree1133ae68c25c705b6f6dc0c490a66bc6c1b2b9ab /src/core
parentf1324eaa6868f196cccfec839e126ea0046cb6b6 (diff)
bus: Escape environment-based D-Bus addresses properly
If XDG_RUNTIME_DIR contains a character like ":" (for instance if it's formed from an X11 display name), then it isn't valid to substitute it into a D-Bus address without escaping. http://bugs.freedesktop.org/show_bug.cgi?id=60499
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dbus.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/core/dbus.c b/src/core/dbus.c
index 2a1c66054a..08aff1fd2b 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -1077,18 +1077,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+10, 0755);
- unlink(p+10);
+ 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);
+
m->private_bus = dbus_server_listen(p, &error);
free(p);
}