Skip to contentSkip to conversation

Trusted devices

PATCH In review Claudio Takahasi 2 participants 2 messages Nov 28, 2006 – Dec 3, 2006 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Trusted devices

Hi Marcel,

This patch implements the funcionality that we discussed previously and fix some minor bugs:

* new errors added
* if the remote device is trusted reply directly instead of ask the authorization agent
* fix case sensitive bug

Comments?
BR,
Claudio

Signature · 3 lines
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT

Index: hcid/dbus-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-api.txt,v retrieving revision 1.87

dbus-api.txt +8 -0
diff -u -r1.87 dbus-api.txt
@@ -1163,16 +1163,24 @@
 
 			Marks the user as trusted.
 
+			Possible errors: org.bluez.Error.InvalidArguments
+					 org.bluez.Error.AlreadyExists
+
 		boolean IsTrusted(string address)
 
 			Returns true if the user is trusted or false otherwise.
 			The address parameter must match one of the
 			current users of the service.
 
+			Possible errors: org.bluez.Error.InvalidArguments
+
 		void RemoveTrust(string address)
 
 			Marks the user as not trusted.
 
+			Possible errors: org.bluez.Error.InvalidArguments
+					 org.bluez.Error.DoesNotExist
+
 Signals		void Started()
 
 			The object path of this signal contains which service

Index: hcid/dbus-error.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-error.c,v retrieving revision 1.32

dbus-error.c +11 -0
diff -u -r1.32 dbus-error.c
@@ -268,6 +268,17 @@
 	return error_already_exists(conn, msg, "Audit already performed");
 }
 
+DBusHandlerResult error_trusted_device_already_exists(DBusConnection *conn, DBusMessage *msg)
+{
+	return error_already_exists(conn, msg, "Trusted device already exists");
+}
+
+DBusHandlerResult error_trusted_device_does_not_exists(DBusConnection *conn, DBusMessage *msg)
+{
+	return error_does_not_exist(conn, msg, "Trusted device does not exist");
+}
+
+
 static const char *strsdperror(int err)
 {
 	switch (err) {

Index: hcid/dbus-error.h
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-error.h,v retrieving revision 1.2

dbus-error.h +2 -0
diff -u -r1.2 dbus-error.h
@@ -63,5 +63,7 @@
 DBusHandlerResult error_connect_canceled(DBusConnection *conn, DBusMessage *msg);
 DBusHandlerResult error_sdp_failed(DBusConnection *conn, DBusMessage *msg, int err);
 DBusHandlerResult error_audit_already_exists(DBusConnection *conn, DBusMessage *msg);
+DBusHandlerResult error_trusted_device_already_exists(DBusConnection *conn, DBusMessage *msg);
+DBusHandlerResult error_trusted_device_does_not_exists(DBusConnection *conn, DBusMessage *msg);
 
 #endif /* __BLUEZ_DBUS_ERROR_H */

Index: hcid/dbus-security.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-security.c,v retrieving revision 1.57

dbus-security.c +7 -0
diff -u -r1.57 dbus-security.c
@@ -761,6 +761,7 @@
 {
 	const char *service_path, *adapter_path, *address, *action;
 	struct service_agent *sagent;
+	struct slist *l;
 
 	if (!dbus_message_get_args(msg, NULL,
 				DBUS_TYPE_STRING, &service_path,
@@ -783,6 +784,12 @@
 	if (strcmp(dbus_message_get_sender(msg), sagent->id))
 		return error_rejected(conn, msg);
 
+	/* Check it is a trusted device */
+	l = slist_find(sagent->trusted_devices, address, (cmp_func_t) strcasecmp);
+	if (l)
+		return send_message_and_unref(conn,
+				dbus_message_new_method_return(msg));
+
 	if (!default_auth_agent)
 		return error_auth_agent_does_not_exist(conn, msg);
 

Index: hcid/dbus-service.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-service.c,v retrieving revision 1.53

dbus-service.c +5 -9
diff -u -r1.53 dbus-service.c
@@ -561,8 +561,6 @@
 	DBusMessage *reply;
 	const char *address;
 
-	/* FIXME: Missing define security policy */
-
 	if (!dbus_message_get_args(msg, NULL,
 			DBUS_TYPE_STRING, &address,
 			DBUS_TYPE_INVALID))
@@ -571,9 +569,9 @@
 	if (check_address(address) < 0)
 		return error_invalid_arguments(conn, msg);
 
-	l = slist_find(agent->trusted_devices, address, (cmp_func_t) strcmp);
+	l = slist_find(agent->trusted_devices, address, (cmp_func_t) strcasecmp);
 	if (l)
-		return error_failed(conn, msg, EINVAL);
+		return error_trusted_device_already_exists(conn, msg);
 
 	reply = dbus_message_new_method_return(msg);
 	if (!reply)
@@ -598,7 +596,7 @@
 			DBUS_TYPE_INVALID))
 		return error_invalid_arguments(conn, msg);
 
-	l = slist_find(agent->trusted_devices, address, (cmp_func_t) strcmp);
+	l = slist_find(agent->trusted_devices, address, (cmp_func_t) strcasecmp);
 	trusted = (l? TRUE : FALSE);
 
 	reply = dbus_message_new_method_return(msg);
@@ -621,16 +619,14 @@
 	const char *address;
 	void *paddress;
 
-	/* FIXME: Missing define security policy */
-
 	if (!dbus_message_get_args(msg, NULL,
 			DBUS_TYPE_STRING, &address,
 			DBUS_TYPE_INVALID))
 		return error_invalid_arguments(conn, msg);
 
-	l = slist_find(agent->trusted_devices, address, (cmp_func_t) strcmp);
+	l = slist_find(agent->trusted_devices, address, (cmp_func_t) strcasecmp);
 	if (!l)
-		return error_invalid_arguments(conn, msg); /* FIXME: find a better error name */
+		return error_trusted_device_does_not_exists(conn, msg);
 
 	reply = dbus_message_new_method_return(msg);
 	if (!reply)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#1 lore raw

Hi Claudio,

Quoted 7 lines

This patch implements the funcionality that we discussed previously and fix some minor bugs:

* new errors added
* if the remote device is trusted reply directly instead of ask the authorization agent
* fix case sensitive bug

looks good to me. Please commit it to the CVS.

Regards

Marcel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel