sd-bus-Accept-no-sender-as-the-destination-field.patch 3.02 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From: Sjoerd Simons <sjoerd@luon.net>
Date: Thu, 25 Sep 2014 21:36:00 +0200
Subject: sd-bus: Accept :no-sender as the destination field

Revert 51b4ea6f485a85. Older systemd versions (e.g. v208) used
:no-sender as a fallback in direct connections. New systemd doesn't
accept this as a valid sender name and thus causes issues when new
systemctl tries to talk to old systemd.

Should be removed after jessie is released

Closes: #762146
---
 src/libsystemd/sd-bus/bus-internal.c | 13 +++++++++++++
 src/libsystemd/sd-bus/bus-internal.h |  1 +
 src/libsystemd/sd-bus/bus-message.c  |  4 ++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/libsystemd/sd-bus/bus-internal.c b/src/libsystemd/sd-bus/bus-internal.c
index 0bea8ca..2c1b69e 100644
--- a/src/libsystemd/sd-bus/bus-internal.c
+++ b/src/libsystemd/sd-bus/bus-internal.c
@@ -166,6 +166,19 @@ bool service_name_is_valid(const char *p) {
         return true;
 }
 
+bool sender_name_is_valid(const char *p) {
+        if (isempty(p))
+                return false;
+
+#ifndef NOLEGACY
+        if (streq(p, ":no-sender"))
+                return true;
+#endif
+
+        return service_name_is_valid(p);
+}
+
+
 bool member_name_is_valid(const char *p) {
         const char *q;
 
diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h
index d1183d6..de85297 100644
--- a/src/libsystemd/sd-bus/bus-internal.h
+++ b/src/libsystemd/sd-bus/bus-internal.h
@@ -342,6 +342,7 @@ struct sd_bus {
 
 bool interface_name_is_valid(const char *p) _pure_;
 bool service_name_is_valid(const char *p) _pure_;
+bool sender_name_is_valid(const char *p) _pure_;
 bool member_name_is_valid(const char *p) _pure_;
 bool object_path_is_valid(const char *p) _pure_;
 char *object_path_startswith(const char *a, const char *b) _pure_;
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 4768a1f..0cc2915 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -5035,7 +5035,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
                         if (!streq(signature, "s"))
                                 return -EBADMSG;
 
-                        r = message_peek_field_string(m, service_name_is_valid, &ri, item_size, &m->destination);
+                        r = message_peek_field_string(m, sender_name_is_valid, &ri, item_size, &m->destination);
                         break;
 
                 case BUS_MESSAGE_HEADER_SENDER:
@@ -5046,7 +5046,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
                         if (!streq(signature, "s"))
                                 return -EBADMSG;
 
-                        r = message_peek_field_string(m, service_name_is_valid, &ri, item_size, &m->sender);
+                        r = message_peek_field_string(m, sender_name_is_valid, &ri, item_size, &m->sender);
 
                         if (r >= 0 && m->sender[0] == ':' && m->bus->bus_client && !m->bus->is_kernel) {
                                 m->creds.unique_name = (char*) m->sender;