Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix not deleting stored keys when a new one is created
@ 2010-08-11 12:44 Luiz Augusto von Dentz
  2010-08-11 12:44 ` [PATCH 2/2] Fix not unmarking temporary flag when a new key " Luiz Augusto von Dentz
  2010-08-11 13:26 ` [PATCH 1/2] Fix not deleting stored keys when a new one " Johan Hedberg
  0 siblings, 2 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2010-08-11 12:44 UTC (permalink / raw)
  To: linux-bluetooth

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

When a new link key is created but it doesn't match any criteria to be
stored any previouly one should be removed from filesystem.
---
 src/dbus-hci.c |   12 +++++++-----
 src/device.c   |    2 +-
 src/device.h   |    2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index 6d27caa..22f378d 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -700,6 +700,13 @@ int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
 	/* Clear any previous debug key */
 	device_set_debug_key(device, NULL);
 
+	/* If this is not the first link key set a flag so a subsequent auth
+	 * complete event doesn't trigger SDP and remove any stored key */
+	if (old_key_type != 0xff) {
+		device_set_renewed_key(device, TRUE);
+		device_remove_bonding(device);
+	}
+
 	/* Store the link key only in runtime memory if it's a debug
 	 * key, else store the link key persistently if one of the
 	 * following is true:
@@ -734,11 +741,6 @@ int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
 	} else
 		temporary = TRUE;
 
-	/* If this is not the first link key set a flag so a subsequent auth
-	 * complete event doesn't trigger SDP */
-	if (old_key_type != 0xff)
-		device_set_renewed_key(device, TRUE);
-
 	if (!device_is_connected(device))
 		device_set_secmode3_conn(device, TRUE);
 	else if (!bonding && old_key_type == 0xff)
diff --git a/src/device.c b/src/device.c
index 10ba779..e72f289 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1056,7 +1056,7 @@ void device_get_name(struct btd_device *device, char *name, size_t len)
 	strncpy(name, device->name, len);
 }
 
-static void device_remove_bonding(struct btd_device *device)
+void device_remove_bonding(struct btd_device *device)
 {
 	char filename[PATH_MAX + 1];
 	char srcaddr[18], dstaddr[18];
diff --git a/src/device.h b/src/device.h
index 5f75e61..21f67d0 100644
--- a/src/device.h
+++ b/src/device.h
@@ -66,7 +66,7 @@ void device_set_secmode3_conn(struct btd_device *device, gboolean enable);
 DBusMessage *device_create_bonding(struct btd_device *device,
 				DBusConnection *conn, DBusMessage *msg,
 				const char *agent_path, uint8_t capability);
-void device_remove_bondind(struct btd_device *device, DBusConnection *connection);
+void device_remove_bonding(struct btd_device *device);
 void device_bonding_complete(struct btd_device *device, uint8_t status);
 void device_simple_pairing_complete(struct btd_device *device, uint8_t status);
 gboolean device_is_creating(struct btd_device *device, const char *sender);
-- 
1.7.0.4


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

* [PATCH 2/2] Fix not unmarking temporary flag when a new key is created
  2010-08-11 12:44 [PATCH 1/2] Fix not deleting stored keys when a new one is created Luiz Augusto von Dentz
@ 2010-08-11 12:44 ` Luiz Augusto von Dentz
  2010-08-11 13:27   ` Johan Hedberg
  2010-08-11 13:26 ` [PATCH 1/2] Fix not deleting stored keys when a new one " Johan Hedberg
  1 sibling, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2010-08-11 12:44 UTC (permalink / raw)
  To: linux-bluetooth

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

Device may have been marked as temporary so when a new key is generated
and it meets the requirements to be stored the device should be no longer
temporary anymore.
---
 src/dbus-hci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index 22f378d..5505d00 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -746,8 +746,8 @@ int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
 	else if (!bonding && old_key_type == 0xff)
 		hcid_dbus_bonding_process_complete(local, peer, 0);
 
-	if (temporary)
-		device_set_temporary(device, TRUE);
+	if (device_is_temporary(device) != temporary)
+		device_set_temporary(device, temporary);
 
 	return 0;
 }
-- 
1.7.0.4


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

* Re: [PATCH 1/2] Fix not deleting stored keys when a new one is created
  2010-08-11 12:44 [PATCH 1/2] Fix not deleting stored keys when a new one is created Luiz Augusto von Dentz
  2010-08-11 12:44 ` [PATCH 2/2] Fix not unmarking temporary flag when a new key " Luiz Augusto von Dentz
@ 2010-08-11 13:26 ` Johan Hedberg
  1 sibling, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2010-08-11 13:26 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Wed, Aug 11, 2010, Luiz Augusto von Dentz wrote:
> When a new link key is created but it doesn't match any criteria to be
> stored any previouly one should be removed from filesystem.
> ---
>  src/dbus-hci.c |   12 +++++++-----
>  src/device.c   |    2 +-
>  src/device.h   |    2 +-
>  3 files changed, 9 insertions(+), 7 deletions(-)

The patch is now upstream. Thanks.

Johan

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

* Re: [PATCH 2/2] Fix not unmarking temporary flag when a new key is created
  2010-08-11 12:44 ` [PATCH 2/2] Fix not unmarking temporary flag when a new key " Luiz Augusto von Dentz
@ 2010-08-11 13:27   ` Johan Hedberg
  2010-08-11 13:43     ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Hedberg @ 2010-08-11 13:27 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Wed, Aug 11, 2010, Luiz Augusto von Dentz wrote:
> --- a/src/dbus-hci.c
> +++ b/src/dbus-hci.c
> @@ -746,8 +746,8 @@ int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
>  	else if (!bonding && old_key_type == 0xff)
>  		hcid_dbus_bonding_process_complete(local, peer, 0);
>  
> -	if (temporary)
> -		device_set_temporary(device, TRUE);
> +	if (device_is_temporary(device) != temporary)
> +		device_set_temporary(device, temporary);
>  
>  	return 0;

I'd prefer if you just call device_set_temporary(device, temporary)
directly. That'd save you the if-check and a call to device_is_temporary.

Johan

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

* Re: [PATCH 2/2] Fix not unmarking temporary flag when a new key is created
  2010-08-11 13:27   ` Johan Hedberg
@ 2010-08-11 13:43     ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2010-08-11 13:43 UTC (permalink / raw)
  To: Luiz Augusto von Dentz, linux-bluetooth

Hi,

On Wed, Aug 11, 2010 at 4:27 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Luiz,
>
> On Wed, Aug 11, 2010, Luiz Augusto von Dentz wrote:
>> --- a/src/dbus-hci.c
>> +++ b/src/dbus-hci.c
>> @@ -746,8 +746,8 @@ int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
>>       else if (!bonding && old_key_type == 0xff)
>>               hcid_dbus_bonding_process_complete(local, peer, 0);
>>
>> -     if (temporary)
>> -             device_set_temporary(device, TRUE);
>> +     if (device_is_temporary(device) != temporary)
>> +             device_set_temporary(device, temporary);
>>
>>       return 0;
>
> I'd prefer if you just call device_set_temporary(device, temporary)
> directly. That'd save you the if-check and a call to device_is_temporary.

Fair enough, I will change it and send a new patch in a few minutes.

-- 
Luiz Augusto von Dentz
Computer Engineer

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

end of thread, other threads:[~2010-08-11 13:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-11 12:44 [PATCH 1/2] Fix not deleting stored keys when a new one is created Luiz Augusto von Dentz
2010-08-11 12:44 ` [PATCH 2/2] Fix not unmarking temporary flag when a new key " Luiz Augusto von Dentz
2010-08-11 13:27   ` Johan Hedberg
2010-08-11 13:43     ` Luiz Augusto von Dentz
2010-08-11 13:26 ` [PATCH 1/2] Fix not deleting stored keys when a new one " Johan Hedberg

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