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

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