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

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