Update github.com git:// SRC_URIs
[AGL/meta-agl.git] / meta-app-framework / recipes-core / dbus-cynagora / dbus-cynagora / 0005-Perform-Cynara-runtime-policy-checks-by-default.patch
1 From 1f7ba56c9ced669951061d13b06e31d96a170e37 Mon Sep 17 00:00:00 2001
2 From: Jacek Bukarewicz <j.bukarewicz@samsung.com>
3 Date: Tue, 23 Jun 2015 11:08:48 +0200
4 Subject: [PATCH 5/8] Perform Cynara runtime policy checks by default
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 This change introduces http://tizen.org/privilege/internal/dbus privilege
10 which is supposed to be available only to trusted system resources.
11 Checks for this privilege are used in place of certain allow rules to
12 make security policy more strict.
13
14 For system bus sending and receiving signals now requires
15 http://tizen.org/privilege/internal/dbus privilege. Requesting name
16 ownership and sending methods is still denied by default.
17
18 For session bus http://tizen.org/privilege/internal/dbus privilege
19 is now required for requesting name, calling methods, sending and receiving
20 signals.
21
22 Services are supposed to override these default settings to implement their
23 own security policy.
24
25 Cherry picked from e8610297cf7031e94eb314a2e8c11246f4405403 by Jose Bollo
26
27 Updated for dbus 1.10.20 by Scott Murray and José Bollo
28
29 Signed-off-by: Jacek Bukarewicz <j.bukarewicz@samsung.com>
30 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
31 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
32 ---
33  bus/activation.c    | 42 ++++++++++++++++++++++++++----------------
34  bus/session.conf.in | 32 ++++++++++++++++++++++++++------
35  bus/system.conf.in  | 19 +++++++++++++++----
36  3 files changed, 67 insertions(+), 26 deletions(-)
37
38 diff --git a/bus/activation.c b/bus/activation.c
39 index d4b597c..8aabeaa 100644
40 --- a/bus/activation.c
41 +++ b/bus/activation.c
42 @@ -1840,22 +1840,32 @@ bus_activation_activate_service (BusActivation  *activation,
43      }
44  
45    if (auto_activation &&
46 -      entry != NULL &&
47 -      BUS_RESULT_TRUE != bus_context_check_security_policy (activation->context,
48 -        transaction,
49 -        connection, /* sender */
50 -        NULL, /* addressed recipient */
51 -        NULL, /* proposed recipient */
52 -        activation_message,
53 -        entry,
54 -        error,
55 -        NULL))
56 -    {
57 -      _DBUS_ASSERT_ERROR_IS_SET (error);
58 -      _dbus_verbose ("activation not authorized: %s: %s\n",
59 -          error != NULL ? error->name : "(error ignored)",
60 -          error != NULL ? error->message : "(error ignored)");
61 -      return FALSE;
62 +      entry != NULL)
63 +   {
64 +      BusResult result;
65 +
66 +      result = bus_context_check_security_policy (activation->context,
67 +                      transaction,
68 +                      connection, /* sender */
69 +                      NULL, /* addressed recipient */
70 +                      NULL, /* proposed recipient */
71 +                      activation_message,
72 +                      entry,
73 +                      error,
74 +                      NULL);
75 +      if (result == BUS_RESULT_FALSE)
76 +        {
77 +          _DBUS_ASSERT_ERROR_IS_SET (error);
78 +          _dbus_verbose ("activation not authorized: %s: %s\n",
79 +              error != NULL ? error->name : "(error ignored)",
80 +              error != NULL ? error->message : "(error ignored)");
81 +          return FALSE;
82 +        }
83 +      if (result == BUS_RESULT_LATER)
84 +        {
85 +          /* TODO */
86 +          _dbus_verbose ("ALERT FIX ME!!!!!!!!!!!!!!!");
87 +        }
88      }
89  
90    /* Bypass the registry lookup if we're auto-activating, bus_dispatch would not
91 diff --git a/bus/session.conf.in b/bus/session.conf.in
92 index affa7f1..157dfb4 100644
93 --- a/bus/session.conf.in
94 +++ b/bus/session.conf.in
95 @@ -27,12 +27,32 @@
96    <standard_session_servicedirs />
97  
98    <policy context="default">
99 -    <!-- Allow everything to be sent -->
100 -    <allow send_destination="*" eavesdrop="true"/>
101 -    <!-- Allow everything to be received -->
102 -    <allow eavesdrop="true"/>
103 -    <!-- Allow anyone to own anything -->
104 -    <allow own="*"/>
105 +    <!-- By default clients require internal/dbus privilege to communicate
106 +         with D-Bus services and to claim name ownership. This is internal privilege that
107 +         is only accessible to trusted system services -->
108 +    <check own="*"                  privilege="http://tizen.org/privilege/internal/dbus" />
109 +    <check send_type="method_call"  privilege="http://tizen.org/privilege/internal/dbus" />
110 +    <check send_type="signal"       privilege="http://tizen.org/privilege/internal/dbus" />
111 +    <check receive_type="signal"    privilege="http://tizen.org/privilege/internal/dbus" />
112 +
113 +    <!-- Reply messages (method returns, errors) are allowed
114 +         by default -->
115 +    <allow send_requested_reply="true" send_type="method_return"/>
116 +    <allow send_requested_reply="true" send_type="error"/>
117 +
118 +    <!-- All messages but signals may be received by default -->
119 +    <allow receive_type="method_call"/>
120 +    <allow receive_type="method_return"/>
121 +    <allow receive_type="error"/>
122 +
123 +    <!-- Allow anyone to talk to the message bus -->
124 +    <allow send_destination="org.freedesktop.DBus"/>
125 +    <allow receive_sender="org.freedesktop.DBus"/>
126 +
127 +    <!-- But disallow some specific bus services -->
128 +    <deny send_destination="org.freedesktop.DBus"
129 +          send_interface="org.freedesktop.DBus"
130 +          send_member="UpdateActivationEnvironment"/>
131    </policy>
132  
133    <!-- Include legacy configuration location -->
134 diff --git a/bus/system.conf.in b/bus/system.conf.in
135 index f139b55..19d0c04 100644
136 --- a/bus/system.conf.in
137 +++ b/bus/system.conf.in
138 @@ -50,17 +50,20 @@
139      <deny own="*"/>
140      <deny send_type="method_call"/>
141  
142 -    <!-- Signals and reply messages (method returns, errors) are allowed
143 +    <!-- By default clients require internal/dbus privilege to send and receive signaks.
144 +         This is internal privilege that is only accessible to trusted system services -->
145 +    <check send_type="signal"       privilege="http://tizen.org/privilege/internal/dbus" />
146 +    <check receive_type="signal"    privilege="http://tizen.org/privilege/internal/dbus" />
147 +
148 +    <!-- Reply messages (method returns, errors) are allowed
149           by default -->
150 -    <allow send_type="signal"/>
151      <allow send_requested_reply="true" send_type="method_return"/>
152      <allow send_requested_reply="true" send_type="error"/>
153  
154 -    <!-- All messages may be received by default -->
155 +    <!-- All messages but signals may be received by default -->
156      <allow receive_type="method_call"/>
157      <allow receive_type="method_return"/>
158      <allow receive_type="error"/>
159 -    <allow receive_type="signal"/>
160  
161      <!-- Allow anyone to talk to the message bus -->
162      <allow send_destination="org.freedesktop.DBus"
163 @@ -69,6 +72,14 @@
164             send_interface="org.freedesktop.DBus.Introspectable"/>
165      <allow send_destination="org.freedesktop.DBus"
166             send_interface="org.freedesktop.DBus.Properties"/>
167 +    <!-- If there is a need specific bus services could be protected by Cynara as well.
168 +         However, this can lead to deadlock during the boot process when such check is made and
169 +         Cynara is not yet activated (systemd calls protected method synchronously,
170 +         dbus daemon tries to consult Cynara, Cynara waits for systemd activation).
171 +         Therefore it is advised to allow root processes to use bus services.
172 +         Currently anyone is allowed to talk to the message bus -->
173 +    <allow receive_sender="org.freedesktop.DBus"/>
174 +
175      <!-- But disallow some specific bus services -->
176      <deny send_destination="org.freedesktop.DBus"
177            send_interface="org.freedesktop.DBus"
178 -- 
179 2.21.1
180