public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] device: Add btd_ prefix to device_is_trusted
@ 2022-08-02 16:34 Luiz Augusto von Dentz
  2022-08-02 16:34 ` [PATCH BlueZ 2/2] sixaxis: Fix fliping device.trusted automatically Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2022-08-02 16:34 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds btd_ prefix to device_is_trusted so it can be used by
plugins.
---
 src/adapter.c       | 2 +-
 src/device.c        | 8 ++++----
 src/device.h        | 2 +-
 src/gatt-database.c | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index b159d2135..10432b734 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -7334,7 +7334,7 @@ static gboolean process_auth_queue(gpointer user_data)
 			goto next;
 		}
 
-		if (device_is_trusted(device) == TRUE) {
+		if (btd_device_is_trusted(device) == TRUE) {
 			auth->cb(NULL, auth->user_data);
 			goto next;
 		}
diff --git a/src/device.c b/src/device.c
index 775003796..60762ac35 100644
--- a/src/device.c
+++ b/src/device.c
@@ -257,7 +257,7 @@ struct btd_device {
 
 	sdp_list_t	*tmp_records;
 
-	gboolean	trusted;
+	bool		trusted;
 	gboolean	blocked;
 	gboolean	auto_connect;
 	gboolean	disable_auto_connect;
@@ -826,7 +826,7 @@ bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type)
 	return state->bonded;
 }
 
-gboolean device_is_trusted(struct btd_device *device)
+bool btd_device_is_trusted(struct btd_device *device)
 {
 	return device->trusted;
 }
@@ -1163,7 +1163,7 @@ static gboolean dev_property_get_trusted(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
 	struct btd_device *device = data;
-	gboolean val = device_is_trusted(device);
+	gboolean val = btd_device_is_trusted(device);
 
 	dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val);
 
@@ -6031,7 +6031,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
 		 * treated as a newly discovered device.
 		 */
 		if (!device_is_paired(device, bdaddr_type) &&
-				!device_is_trusted(device))
+				!btd_device_is_trusted(device))
 			btd_device_set_temporary(device, true);
 
 		device_bonding_failed(device, status);
diff --git a/src/device.h b/src/device.h
index d7f886224..004d3a78b 100644
--- a/src/device.h
+++ b/src/device.h
@@ -88,7 +88,7 @@ gboolean device_is_temporary(struct btd_device *device);
 bool device_is_connectable(struct btd_device *device);
 bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type);
 bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type);
-gboolean device_is_trusted(struct btd_device *device);
+bool btd_device_is_trusted(struct btd_device *device);
 void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type);
 void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type);
 void btd_device_set_temporary(struct btd_device *device, bool temporary);
diff --git a/src/gatt-database.c b/src/gatt-database.c
index cf651b5f5..db8432c6b 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2989,7 +2989,7 @@ static void desc_write_cb(struct gatt_db_attribute *attrib,
 	}
 
 	if (opcode == BT_ATT_OP_PREP_WRITE_REQ) {
-		if (!device_is_trusted(device) && !desc->prep_authorized &&
+		if (!btd_device_is_trusted(device) && !desc->prep_authorized &&
 						desc->req_prep_authorization)
 			send_write(att, attrib, desc->proxy,
 					desc->pending_writes, id, value, len,
@@ -3120,7 +3120,7 @@ static void chrc_write_cb(struct gatt_db_attribute *attrib,
 		queue = NULL;
 
 	if (opcode == BT_ATT_OP_PREP_WRITE_REQ) {
-		if (!device_is_trusted(device) && !chrc->prep_authorized &&
+		if (!btd_device_is_trusted(device) && !chrc->prep_authorized &&
 						chrc->req_prep_authorization)
 			send_write(att, attrib, chrc->proxy, queue,
 					id, value, len, offset,
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH BlueZ 2/2] sixaxis: Fix fliping device.trusted automatically
  2022-08-02 16:34 [PATCH BlueZ 1/2] device: Add btd_ prefix to device_is_trusted Luiz Augusto von Dentz
@ 2022-08-02 16:34 ` Luiz Augusto von Dentz
  2022-08-02 17:21 ` [BlueZ,1/2] device: Add btd_ prefix to device_is_trusted bluez.test.bot
  2022-08-02 19:50 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2022-08-02 16:34 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

device.trusted is a user preference which controls if the devices needs
to be authorized or not so the plugin shall not overwrite it and instead
just honor what user has set and skip authorizing if already trusted.

Fixes: https://github.com/bluez/bluez/issues/372
---
 plugins/sixaxis.c | 9 +++------
 src/device.c      | 6 ++++++
 src/device.h      | 1 +
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 10cf15948..544ab399a 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -294,7 +294,6 @@ static void agent_auth_cb(DBusError *derr, void *user_data)
 	}
 
 	remove_device = false;
-	btd_device_set_trusted(closure->device, true);
 	btd_device_set_temporary(closure->device, false);
 
 	if (closure->type == CABLE_PAIRING_SIXAXIS)
@@ -336,10 +335,9 @@ static bool setup_device(int fd, const char *sysfs_path,
 	 * connected eg. to charge up battery. */
 	device = btd_adapter_find_device(adapter, &device_bdaddr,
 							BDADDR_BREDR);
-	if (device != NULL &&
-		btd_device_is_connected(device) &&
-		g_slist_find_custom(btd_device_get_uuids(device), HID_UUID,
-						(GCompareFunc)strcasecmp)) {
+	if (device && btd_device_has_uuid(device, HID_UUID) &&
+			(btd_device_is_connected(device) ||
+			 btd_device_is_trusted(device))) {
 		char device_addr[18];
 		ba2str(&device_bdaddr, device_addr);
 		DBG("device %s already known, skipping", device_addr);
@@ -352,7 +350,6 @@ static bool setup_device(int fd, const char *sysfs_path,
 
 	btd_device_device_set_name(device, cp->name);
 	btd_device_set_pnpid(device, cp->source, cp->vid, cp->pid, cp->version);
-	btd_device_set_trusted(device, false);
 	btd_device_set_temporary(device, true);
 
 	closure = g_new0(struct authentication_closure, 1);
diff --git a/src/device.c b/src/device.c
index 60762ac35..bc9942022 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4509,6 +4509,12 @@ GSList *btd_device_get_uuids(struct btd_device *device)
 	return device->uuids;
 }
 
+bool btd_device_has_uuid(struct btd_device *device, const char *uuid)
+{
+	return g_slist_find_custom(device->uuids, uuid,
+						(GCompareFunc)strcasecmp);
+}
+
 struct probe_data {
 	struct btd_device *dev;
 	GSList *uuids;
diff --git a/src/device.h b/src/device.h
index 004d3a78b..cc474bd88 100644
--- a/src/device.h
+++ b/src/device.h
@@ -54,6 +54,7 @@ struct device_addr_type {
 
 int device_addr_type_cmp(gconstpointer a, gconstpointer b);
 GSList *btd_device_get_uuids(struct btd_device *device);
+bool btd_device_has_uuid(struct btd_device *device, const char *uuid);
 void device_probe_profiles(struct btd_device *device, GSList *profiles);
 
 void btd_device_set_record(struct btd_device *device, const char *uuid,
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [BlueZ,1/2] device: Add btd_ prefix to device_is_trusted
  2022-08-02 16:34 [PATCH BlueZ 1/2] device: Add btd_ prefix to device_is_trusted Luiz Augusto von Dentz
  2022-08-02 16:34 ` [PATCH BlueZ 2/2] sixaxis: Fix fliping device.trusted automatically Luiz Augusto von Dentz
@ 2022-08-02 17:21 ` bluez.test.bot
  2022-08-02 19:50 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2022-08-02 17:21 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=664876

---Test result---

Test Summary:
CheckPatch                    PASS      1.79 seconds
GitLint                       PASS      1.08 seconds
Prep - Setup ELL              PASS      27.37 seconds
Build - Prep                  PASS      0.67 seconds
Build - Configure             PASS      8.50 seconds
Build - Make                  PASS      850.55 seconds
Make Check                    PASS      11.23 seconds
Make Check w/Valgrind         PASS      285.34 seconds
Make Distcheck                PASS      238.54 seconds
Build w/ext ELL - Configure   PASS      8.67 seconds
Build w/ext ELL - Make        PASS      82.08 seconds
Incremental Build w/ patches  PASS      195.11 seconds
Scan Build                    PASS      599.70 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH BlueZ 1/2] device: Add btd_ prefix to device_is_trusted
  2022-08-02 16:34 [PATCH BlueZ 1/2] device: Add btd_ prefix to device_is_trusted Luiz Augusto von Dentz
  2022-08-02 16:34 ` [PATCH BlueZ 2/2] sixaxis: Fix fliping device.trusted automatically Luiz Augusto von Dentz
  2022-08-02 17:21 ` [BlueZ,1/2] device: Add btd_ prefix to device_is_trusted bluez.test.bot
@ 2022-08-02 19:50 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2022-08-02 19:50 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue,  2 Aug 2022 09:34:40 -0700 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This adds btd_ prefix to device_is_trusted so it can be used by
> plugins.
> ---
>  src/adapter.c       | 2 +-
>  src/device.c        | 8 ++++----
>  src/device.h        | 2 +-
>  src/gatt-database.c | 4 ++--
>  4 files changed, 8 insertions(+), 8 deletions(-)

Here is the summary with links:
  - [BlueZ,1/2] device: Add btd_ prefix to device_is_trusted
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7adb3aa7efc3
  - [BlueZ,2/2] sixaxis: Fix fliping device.trusted automatically
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a65ddf710584

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-02 19:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-02 16:34 [PATCH BlueZ 1/2] device: Add btd_ prefix to device_is_trusted Luiz Augusto von Dentz
2022-08-02 16:34 ` [PATCH BlueZ 2/2] sixaxis: Fix fliping device.trusted automatically Luiz Augusto von Dentz
2022-08-02 17:21 ` [BlueZ,1/2] device: Add btd_ prefix to device_is_trusted bluez.test.bot
2022-08-02 19:50 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox