bus/policy: activation: check target name 98/235398/2 accepted/tizen/unified/20200605.020519 submit/tizen/20200604.095417 submit/tizen/20200604.233300 submit/tizen/20200605.005713
authorAdrian Szyndela <adrian.s@samsung.com>
Thu, 4 Jun 2020 07:24:01 +0000 (09:24 +0200)
committerAdrian Szyndela <adrian.s@samsung.com>
Thu, 4 Jun 2020 08:09:15 +0000 (10:09 +0200)
Check target name taken from message instead of org.freedesktop.DBus in case
of no peer available. This is the case when activation is happening.

Change-Id: I181edbb28a1b26ed79552bb6df8b00892d2ceac8

bus/policy.c

index 4ba7d6f..53a6682 100644 (file)
@@ -918,6 +918,7 @@ typedef struct RuleParams {
       BusRegistry    *registry;
       dbus_bool_t     requested_reply;
       DBusConnection *peer;
+      const char     *name;
       DBusMessage    *message;
       dbus_bool_t     eavesdropping;
     } sr;
@@ -1340,11 +1341,13 @@ find_and_check_rules (DBusHashTable *rules,
                                                      privilege, matched_rule);
             }
         }
-      else
-        score = find_and_check_rules_for_name (rules, DBUS_SERVICE_DBUS, score,
-                                               check_func, params,
-                                               toggles, log, result,
-                                               privilege, matched_rule);
+      else if (p->u.sr.name != NULL)
+        {
+          score = find_and_check_rules_for_name (rules, p->u.sr.name, score,
+                                                 check_func, params,
+                                                 toggles, log, result,
+                                                 privilege, matched_rule);
+        }
     }
   else
     score = find_and_check_rules_for_name (rules, _dbus_string_get_data(p->u.name),
@@ -1446,6 +1449,7 @@ bus_client_policy_check_can_send (DBusConnection      *sender,
   params.u.sr.requested_reply = requested_reply;
   params.u.sr.peer = receiver;
   params.u.sr.message = message;
+  params.u.sr.name = dbus_message_get_destination (message);
 
   _dbus_verbose ("  (policy) checking send rules\n");
 
@@ -1704,6 +1708,7 @@ bus_client_policy_check_can_receive (BusClientPolicy     *policy,
   params.u.sr.eavesdropping =
     addressed_recipient != proposed_recipient &&
     dbus_message_get_destination (message) != NULL;
+  params.u.sr.name = dbus_message_get_sender (message);
 
   _dbus_verbose ("  (policy) checking receive rules, eavesdropping = %d\n", eavesdropping);