summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2013-02-26 12:37:10 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-28 23:15:48 +0000
commit9f1c471ed47372dfff214fff7f73f861f9821491 (patch)
tree7f2c1ba1b4d6e22989a292560dd132c8689338a7 /meta
parentf436271a62687c73fed4d4f8437aa19b9f33b0e3 (diff)
downloadpoky-9f1c471ed47372dfff214fff7f73f861f9821491.tar.gz
dbus: set correct address when using --address=systemd:
Patch taken from upstream 1.7 branch. (From OE-Core rev: d7b8ae19464a3fe87822376b541b3d6865fe6115) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-core/dbus/dbus-1.6.8/systemd-address.patch187
-rw-r--r--meta/recipes-core/dbus/dbus.inc1
2 files changed, 188 insertions, 0 deletions
diff --git a/meta/recipes-core/dbus/dbus-1.6.8/systemd-address.patch b/meta/recipes-core/dbus/dbus-1.6.8/systemd-address.patch
new file mode 100644
index 0000000000..ae1291c947
--- /dev/null
+++ b/meta/recipes-core/dbus/dbus-1.6.8/systemd-address.patch
@@ -0,0 +1,187 @@
1Upstream-Status: Backport
2Signed-off-by: Ross Burton <ross.burton@intel.com>
3
4From d728fdc655f17031da3bb129ab2fd17dadf0fe3a Mon Sep 17 00:00:00 2001
5From: Simon Peeters <peeters.simon@gmail.com>
6Date: Sun, 07 Oct 2012 14:59:30 +0000
7Subject: Set correct address when using --address=systemd:
8
9When dbus gets launched through systemd, we need to create an address
10string based on the sockets passed.
11
12The _dbus_append_addres_from_socket() function is responsible for
13extracting the address information from the file-descriptor and
14formatting it in a dbus friendly way.
15
16This fixes bus activation when running dbus under a systemd session.
17
18https://bugs.freedesktop.org/show_bug.cgi?id=50962
19
20Signed-off-by: Simon Peeters <peeters.simon@gmail.com>
21---
22diff --git a/dbus/dbus-server-unix.c b/dbus/dbus-server-unix.c
23index 130f66e..d995240 100644
24--- a/dbus/dbus-server-unix.c
25+++ b/dbus/dbus-server-unix.c
26@@ -149,7 +149,7 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry,
27 }
28 else if (strcmp (method, "systemd") == 0)
29 {
30- int n, *fds;
31+ int i, n, *fds;
32 DBusString address;
33
34 n = _dbus_listen_systemd_sockets (&fds, error);
35@@ -159,27 +159,39 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry,
36 return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
37 }
38
39- _dbus_string_init_const (&address, "systemd:");
40+ if (!_dbus_string_init (&address))
41+ goto systemd_oom;
42
43- *server_p = _dbus_server_new_for_socket (fds, n, &address, NULL);
44- if (*server_p == NULL)
45+ for (i = 0; i < n; i++)
46 {
47- int i;
48-
49- for (i = 0; i < n; i++)
50+ if (i > 0)
51 {
52- _dbus_close_socket (fds[i], NULL);
53+ if (!_dbus_string_append (&address, ";"))
54+ goto systemd_oom;
55 }
56- dbus_free (fds);
57-
58- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
59- return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
60+ if (!_dbus_append_address_from_socket (fds[i], &address, error))
61+ goto systemd_err;
62 }
63
64+ *server_p = _dbus_server_new_for_socket (fds, n, &address, NULL);
65+ if (*server_p == NULL)
66+ goto systemd_oom;
67+
68 dbus_free (fds);
69
70 return DBUS_SERVER_LISTEN_OK;
71- }
72+ systemd_oom:
73+ _DBUS_SET_OOM (error);
74+ systemd_err:
75+ for (i = 0; i < n; i++)
76+ {
77+ _dbus_close_socket (fds[i], NULL);
78+ }
79+ dbus_free (fds);
80+ _dbus_string_free (&address);
81+
82+ return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
83+ }
84 #ifdef DBUS_ENABLE_LAUNCHD
85 else if (strcmp (method, "launchd") == 0)
86 {
87diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
88index b4ecc96..55743b1 100644
89--- a/dbus/dbus-sysdeps-unix.c
90+++ b/dbus/dbus-sysdeps-unix.c
91@@ -55,6 +55,7 @@
92 #include <netinet/in.h>
93 #include <netdb.h>
94 #include <grp.h>
95+#include <arpa/inet.h>
96
97 #ifdef HAVE_ERRNO_H
98 #include <errno.h>
99@@ -4160,4 +4161,71 @@ _dbus_check_setuid (void)
100 #endif
101 }
102
103+/**
104+ * Read the address from the socket and append it to the string
105+ *
106+ * @param fd the socket
107+ * @param address
108+ * @param error return location for error code
109+ */
110+dbus_bool_t
111+_dbus_append_address_from_socket (int fd,
112+ DBusString *address,
113+ DBusError *error)
114+{
115+ union {
116+ struct sockaddr sa;
117+ struct sockaddr_storage storage;
118+ struct sockaddr_un un;
119+ struct sockaddr_in ipv4;
120+ struct sockaddr_in6 ipv6;
121+ } socket;
122+ char hostip[INET6_ADDRSTRLEN];
123+ int size = sizeof (socket);
124+
125+ if (getsockname (fd, &socket.sa, &size))
126+ goto err;
127+
128+ switch (socket.sa.sa_family)
129+ {
130+ case AF_UNIX:
131+ if (socket.un.sun_path[0]=='\0')
132+ {
133+ if (_dbus_string_append_printf (address, "unix:abstract=%s", &(socket.un.sun_path[1])))
134+ return TRUE;
135+ }
136+ else
137+ {
138+ if (_dbus_string_append_printf (address, "unix:path=%s", socket.un.sun_path))
139+ return TRUE;
140+ }
141+ break;
142+ case AF_INET:
143+ if (inet_ntop (AF_INET, &socket.ipv4.sin_addr, hostip, sizeof (hostip)))
144+ if (_dbus_string_append_printf (address, "tcp:family=ipv4,host=%s,port=%u",
145+ hostip, ntohs (socket.ipv4.sin_port)))
146+ return TRUE;
147+ break;
148+#ifdef AF_INET6
149+ case AF_INET6:
150+ if (inet_ntop (AF_INET6, &socket.ipv6.sin6_addr, hostip, sizeof (hostip)))
151+ if (_dbus_string_append_printf (address, "tcp:family=ipv6,host=%s,port=%u",
152+ hostip, ntohs (socket.ipv6.sin6_port)))
153+ return TRUE;
154+ break;
155+#endif
156+ default:
157+ dbus_set_error (error,
158+ _dbus_error_from_errno (EINVAL),
159+ "Failed to read address from socket: Unknown socket type.");
160+ return FALSE;
161+ }
162+ err:
163+ dbus_set_error (error,
164+ _dbus_error_from_errno (errno),
165+ "Failed to open socket: %s",
166+ _dbus_strerror (errno));
167+ return FALSE;
168+}
169+
170 /* tests in dbus-sysdeps-util.c */
171diff --git a/dbus/dbus-sysdeps-unix.h b/dbus/dbus-sysdeps-unix.h
172index 9b70896..a265b33 100644
173--- a/dbus/dbus-sysdeps-unix.h
174+++ b/dbus/dbus-sysdeps-unix.h
175@@ -138,6 +138,10 @@ dbus_bool_t _dbus_parse_uid (const DBusString *uid_str,
176
177 void _dbus_close_all (void);
178
179+dbus_bool_t _dbus_append_address_from_socket (int fd,
180+ DBusString *address,
181+ DBusError *error);
182+
183 /** @} */
184
185 DBUS_END_DECLS
186--
187cgit v0.9.0.2-2-gbebe
diff --git a/meta/recipes-core/dbus/dbus.inc b/meta/recipes-core/dbus/dbus.inc
index 4897fd3e57..affffbc187 100644
--- a/meta/recipes-core/dbus/dbus.inc
+++ b/meta/recipes-core/dbus/dbus.inc
@@ -16,6 +16,7 @@ INC_PR = "r6"
16 16
17SRC_URI = "http://dbus.freedesktop.org/releases/dbus/dbus-${PV}.tar.gz \ 17SRC_URI = "http://dbus.freedesktop.org/releases/dbus/dbus-${PV}.tar.gz \
18 file://tmpdir.patch; \ 18 file://tmpdir.patch; \
19 file://systemd-address.patch \
19 file://dbus-1.init" 20 file://dbus-1.init"
20 21
21inherit useradd autotools pkgconfig gettext update-rc.d 22inherit useradd autotools pkgconfig gettext update-rc.d