systemd/0578-bus-proxyd-fix-compatibility-with-old-dbus-1.patch
Zbigniew Jędrzejewski-Szmek db38be6409 More patches
2014-10-13 10:21:01 -04:00

39 lines
1.7 KiB
Diff

From 547e849b722e597d70ba069e2cb8931317d66e00 Mon Sep 17 00:00:00 2001
From: Lukasz Skalski <l.skalski@samsung.com>
Date: Fri, 10 Oct 2014 16:42:19 +0200
Subject: [PATCH] bus-proxyd: fix compatibility with old dbus-1
'ListQueuedOwners' method should return 'NameHasNoOwner' error
if chosen name is not available on bus.
---
src/bus-proxyd/bus-proxyd.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index 4f44825679..52498f33d2 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -733,6 +733,7 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m) {
struct kdbus_cmd_free cmd_free;
struct kdbus_cmd_name *name;
_cleanup_strv_free_ char **owners = NULL;
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
char *arg0;
int err = 0;
@@ -743,6 +744,14 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m) {
if (!service_name_is_valid(arg0))
return synthetic_reply_method_errno(m, -EINVAL, NULL);
+ r = sd_bus_get_owner(a, arg0, 0, NULL);
+ if (r == -ESRCH || r == -ENXIO) {
+ sd_bus_error_setf(&error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Could not get owners of name '%s': no such name.", arg0);
+ return synthetic_reply_method_errno(m, r, &error);
+ }
+ if (r < 0)
+ return synthetic_reply_method_errno(m, r, NULL);
+
cmd.flags = KDBUS_NAME_LIST_QUEUED;
r = ioctl(a->input_fd, KDBUS_CMD_NAME_LIST, &cmd);
if (r < 0)