Fix the dbus permission problem in mesh 18/239818/2
authorDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 30 Jul 2020 05:08:30 +0000 (14:08 +0900)
committerAnupam Roy <anupam.r@samsung.com>
Thu, 30 Jul 2020 06:30:14 +0000 (12:00 +0530)
Change-Id: I285396eb9d57ec3aa88833e1e54d9d0caa6951f6
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c
bt-service/bluetooth-frwk-service.conf.in

index 81ca6d5..ab136a7 100644 (file)
@@ -36,6 +36,8 @@
 
 #include <hardware/bt_mesh.h>
 
+#define BT_HAL_MESH_DBUS_NAME "org.projectx.bt.mesh"
+
 #define BT_HAL_UUID_LEN 16
 #define BT_HAL_BLUEZ_MESH_NAME "org.bluez.mesh"
 
@@ -516,11 +518,23 @@ static void __mesh_dbus_client_ready(struct l_dbus_client *client_obj,
        client = client_obj;
 }
 
+static void __mesh_acquire_name_callback(struct l_dbus *dbus_obj, bool success,
+                                       bool queued, void *user_data)
+{
+       if (success == false)
+               ERR("Mesh: Fail to acquire dbus name\n");
+
+       if (!l_dbus_object_manager_enable(dbus_obj, "/"))
+               ERR("Mesh: Failed to register the ObjectManager\n");
+}
+
 static void __mesh_ready_callback(void *user_data)
 {
        INFO("Mesh: Connected to D-Bus\n");
-       if (!l_dbus_object_manager_enable(dbus, "/"))
-               ERR("Mesh: Failed to register the ObjectManager\n");
+
+       if (!l_dbus_name_acquire(dbus, BT_HAL_MESH_DBUS_NAME, false, false, false,
+                               __mesh_acquire_name_callback, NULL))
+               ERR("Mesh: Failed to own well-known name\n");
 }
 
 bool _bt_hal_mesh_stack_init(void)
index f8359d2..db71f5d 100644 (file)
@@ -3,13 +3,17 @@
 <busconfig>
     <policy user="root">
         <allow own="org.projectx.bt"/>
+        <allow own="org.projectx.bt.mesh"/>
         <allow send_destination="org.projectx.bt"/>
+        <allow send_destination="org.projectx.bt.mesh"/>
         <allow own="org.bluez.obex"/>
         <allow send_destination="org.bluez.obex"/>
     </policy>
     <policy group="network_fw">
         <allow own="org.projectx.bt"/>
+        <allow own="org.projectx.bt.mesh"/>
         <allow send_destination="org.projectx.bt"/>
+        <allow send_destination="org.projectx.bt.mesh"/>
         <allow own="org.bluez.obex"/>
         <allow send_destination="org.bluez.obex"/>
         <allow own="org.projectx.bluetooth.share"/>