Blame SOURCES/0001-input-hog-Attempt-to-set-security-level-if-not-bonde.patch

dd55c8
From 1e083c2cd7c0284cf9dd389359a27aa6d354538c Mon Sep 17 00:00:00 2001
dd55c8
From: Gopal Tiwari <gtiwari@redhat.com>
dd55c8
Date: Wed, 26 May 2021 11:31:04 +0530
dd55c8
Subject: [PATCH BlueZ 1/2] input: hog: Attempt to set security level if not
dd55c8
 bonded
dd55c8
dd55c8
commit 35d8d895cd0b724e58129374beb0bb4a2edf9519
dd55c8
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
dd55c8
Date:   Tue Mar 10 09:59:07 2020 -0700
dd55c8
dd55c8
    input: hog: Attempt to set security level if not bonded
dd55c8
dd55c8
    This attempts to set the security if the device is not bonded, the
dd55c8
    kernel will block any communication on the ATT socket while bumping
dd55c8
    the security and if that fails the device will be disconnected which
dd55c8
    is better than having the device dangling around without being able to
dd55c8
    communicate with it until it is properly bonded.
dd55c8
---
dd55c8
 profiles/input/hog.c | 13 +++++++++++--
dd55c8
 1 file changed, 11 insertions(+), 2 deletions(-)
dd55c8
dd55c8
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
dd55c8
index dfac68921..f0226ebbd 100644
dd55c8
--- a/profiles/input/hog.c
dd55c8
+++ b/profiles/input/hog.c
dd55c8
@@ -49,6 +49,8 @@
dd55c8
 #include "src/shared/util.h"
dd55c8
 #include "src/shared/uhid.h"
dd55c8
 #include "src/shared/queue.h"
dd55c8
+#include "src/shared/att.h"
dd55c8
+#include "src/shared/gatt-client.h"
dd55c8
 #include "src/plugin.h"
dd55c8
 
dd55c8
 #include "suspend.h"
dd55c8
@@ -187,8 +189,15 @@ static int hog_accept(struct btd_service *service)
dd55c8
 	}
dd55c8
 
dd55c8
 	/* HOGP 1.0 Section 6.1 requires bonding */
dd55c8
-	if (!device_is_bonded(device, btd_device_get_bdaddr_type(device)))
dd55c8
-		return -ECONNREFUSED;
dd55c8
+	if (!device_is_bonded(device, btd_device_get_bdaddr_type(device))) {
dd55c8
+		struct bt_gatt_client *client;
dd55c8
+
dd55c8
+		client = btd_device_get_gatt_client(device);
dd55c8
+		if (!bt_gatt_client_set_security(client,
dd55c8
+						BT_ATT_SECURITY_MEDIUM)) {
dd55c8
+			return -ECONNREFUSED;
dd55c8
+		}
dd55c8
+	}
dd55c8
 
dd55c8
 	/* TODO: Replace GAttrib with bt_gatt_client */
dd55c8
 	bt_hog_attach(dev->hog, attrib);
dd55c8
-- 
dd55c8
2.26.2
dd55c8