public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] Trusted devices
@ 2006-11-28 21:48 Claudio Takahasi
  2006-12-03 13:52 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Claudio Takahasi @ 2006-11-28 21:48 UTC (permalink / raw)
  To: BlueZ development

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

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
-- 
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT

[-- Attachment #2: trusted03.patch --]
[-- Type: text/x-patch, Size: 5379 bytes --]

Index: hcid/dbus-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-api.txt,v
retrieving revision 1.87
diff -u -r1.87 dbus-api.txt
--- hcid/dbus-api.txt	23 Nov 2006 19:50:25 -0000	1.87
+++ hcid/dbus-api.txt	28 Nov 2006 21:35:10 -0000
@@ -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
diff -u -r1.32 dbus-error.c
--- hcid/dbus-error.c	1 Nov 2006 17:13:17 -0000	1.32
+++ hcid/dbus-error.c	28 Nov 2006 21:35:10 -0000
@@ -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
diff -u -r1.2 dbus-error.h
--- hcid/dbus-error.h	1 Nov 2006 17:13:17 -0000	1.2
+++ hcid/dbus-error.h	28 Nov 2006 21:35:10 -0000
@@ -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
diff -u -r1.57 dbus-security.c
--- hcid/dbus-security.c	20 Nov 2006 18:46:28 -0000	1.57
+++ hcid/dbus-security.c	28 Nov 2006 21:35:11 -0000
@@ -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
diff -u -r1.53 dbus-service.c
--- hcid/dbus-service.c	17 Nov 2006 22:36:47 -0000	1.53
+++ hcid/dbus-service.c	28 Nov 2006 21:35:11 -0000
@@ -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)

[-- Attachment #3: Type: text/plain, Size: 347 bytes --]

-------------------------------------------------------------------------
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

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

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

end of thread, other threads:[~2006-12-03 13:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-28 21:48 [Bluez-devel] [PATCH] Trusted devices Claudio Takahasi
2006-12-03 13:52 ` Marcel Holtmann

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