Display yes/no popup for RequestAuthorization request 51/250351/2 accepted/tizen/unified/20201229.124650 submit/tizen/20201228.031005
authorSangki Park <sangki79.park@samsung.com>
Tue, 22 Dec 2020 10:55:11 +0000 (19:55 +0900)
committerPyun DoHyun <dh79.pyun@samsung.com>
Thu, 24 Dec 2020 01:29:35 +0000 (01:29 +0000)
[Model] Wearable
[BinType] AP
[Customer] ALL

[Issue#] N/A
[Request] N/A
[Occurrence Version] N/A

[Problem] A pairing request is accepted on bluez automatically if
the I/O capability of peer device is No-Input-No-Output
[Cause & Measure] Security hole issue. To prevent, bt-frwk will launch
a bt-syspopup for user confirmation.
[Checking Method] receive a pairing request with No-Input-No-Output mode

[Team] Bluetooth
[Developer] Deokhyun Kim
[Solution company] Samsung
[Change Type] Specification change

Change-Id: I0d8609512bf6d8af9f0ddadcd397688c47502dc5
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
bt-oal/bluez_hal/src/bt-hal-gap-agent.c

index e035ae2..800b735 100644 (file)
@@ -34,6 +34,8 @@
 #include "bt-hal-msg.h"
 #include "bt-hal-utils.h"
 
+#include "bt-internal-types.h"
+
 #include <glib.h>
 #include <gio/gio.h>
 #include <dlog.h>
@@ -51,6 +53,7 @@ typedef enum {
 
 #define AGENT_ALREADY_EXIST 0x24
 
+#define GAP_UUID "00001800-0000-1000-8000-00805f9b34fb"
 #define GAP_AGENT_ERROR (gap_agent_error_quark())
 
 static GQuark gap_agent_error_quark(void)
@@ -741,7 +744,72 @@ static void __bt_gap_agent_method(GDBusConnection *connection,
                g_object_unref(device);
                return;
        } else if (g_strcmp0(method_name, "RequestAuthorization") == 0) {
+               if (!TIZEN_PROFILE_WEARABLE) {
+                       /* Accept always */
                g_dbus_method_invocation_return_value(invocation, NULL);
+               } else {
+                       /* TODO: This security feature is applicable for Mobile. */
+                       GapAgentPrivate *priv = user_data;
+                       char *sender = (char *)g_dbus_method_invocation_get_sender(invocation);
+                       GDBusProxy *device;
+                       GDBusConnection *conn;
+                       char *addr;
+                       char *path;
+
+                       if (sender == NULL)
+                               return;
+
+                       g_variant_get(parameters, "(&o)", &path);
+                       DBG("Request authorization :sender %s priv->busname %s"
+                                       "Device Path :%s",
+                                       sender, priv->busname, path);
+
+                       if (!priv->cb.authorize_func)
+                               return;
+
+                       conn = _bt_hal_get_system_gconn();
+                       if (conn == NULL)
+                               return;
+
+                       device = g_dbus_proxy_new_sync(conn,
+                                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                                       BT_HAL_BLUEZ_NAME, path,
+                                       BT_HAL_PROPERTIES_INTERFACE, NULL, &err);
+
+                       if (!device) {
+                               ERR("Fail to make device proxy");
+
+                               g_dbus_method_invocation_return_error(invocation,
+                                               GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                               "No proxy for device");
+
+                               if (err) {
+                                       ERR("Unable to create proxy: %s", err->message);
+                                       g_clear_error(&err);
+                               }
+
+                               return;
+                       }
+
+                       priv->exec_type = GAP_AGENT_EXEC_AUTHORZATION;
+                       priv->reply_context = invocation;
+
+                       addr = strstr(path, "dev_");
+                       if (addr != NULL) {
+                               char *pos = NULL;
+                               addr += 4;
+                               g_strlcpy(priv->authorize_addr, addr,
+                                                               sizeof(priv->authorize_addr));
+
+                               while ((pos = strchr(priv->authorize_addr, '_')) != NULL)
+                                       *pos = ':';
+                       }
+
+                       priv->cb.authorize_func(priv, device, GAP_UUID);
+
+                       g_object_unref(device);
+                       return;
+               }
        } else if (g_strcmp0(method_name, "ConfirmModeChange") == 0) {
                g_dbus_method_invocation_return_value(invocation, NULL);
        } else if (g_strcmp0(method_name, "Cancel") == 0) {