[PATCH ] obexd/opp: Fix OPP GET request path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The default path is /etc/bluetooth/vcard.vcf which obexd
is not able to access.

obexd[11654]: obexd/src/obex.c:cmd_get() session 0x64edff0
obexd[11654]: GET(0x3), (null)(0xffffffff)
obexd[11654]: obexd/src/obex.c:parse_type() TYPE: text/x-vcard
obexd[11654]: open(/etc/bluetooth/vcard.vcf): Operation not permitted (1)
obexd[11654]: GET(0x3), NOT_FOUND(0x44)

After making this path as obex root folder,
it is able to succeed.

obexd[12246]: obexd/src/obex.c:cmd_get() session 0x64ed830
obexd[12246]: GET(0x3), (null)(0xffffffff)
obexd[12246]: obexd/src/obex.c:parse_type() TYPE: text/x-vcard
obexd[12246]: obexd/src/obex.c:driver_get_headers() name=(null) type=text/x-vcard object=0x8
obexd[12246]: GET(0x3), CONTINUE(0x10)
obexd[12246]: obexd/src/obex.c:send_data() name=(null) type=text/x-vcard file=0x8 size=3061
obexd[12246]: obexd/src/obex.c:driver_read() 73 read
obexd[12246]: obexd/src/obex.c:send_data() name=(null) type=text/x-vcard file=0x8 size=3066
obexd[12246]: obexd/src/obex.c:driver_read() 0 read
obexd[12246]: obexd/src/obex.c:transfer_complete()
---
 obexd/plugins/opp.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/obexd/plugins/opp.c b/obexd/plugins/opp.c
index 445688d..5bb7667 100644
--- a/obexd/plugins/opp.c
+++ b/obexd/plugins/opp.c
@@ -42,7 +42,6 @@
 #include "filesystem.h"
 
 #define VCARD_TYPE "text/x-vcard"
-#define VCARD_FILE CONFIGDIR "/vcard.vcf"
 
 static void *opp_connect(struct obex_session *os, int *err)
 {
@@ -132,6 +131,8 @@ static int opp_put(struct obex_session *os, void *user_data)
 static int opp_get(struct obex_session *os, void *user_data)
 {
 	const char *type;
+	char *folder, *path;
+	int err = 0;
 
 	if (obex_get_name(os))
 		return -EPERM;
@@ -141,14 +142,19 @@ static int opp_get(struct obex_session *os, void *user_data)
 	if (type == NULL)
 		return -EPERM;
 
+	folder = g_strdup(obex_option_root_folder());
+	path = g_build_filename(folder, "/vcard.vcf", NULL);
+
 	if (g_ascii_strcasecmp(type, VCARD_TYPE) == 0) {
-		if (obex_get_stream_start(os, VCARD_FILE) < 0)
-			return -ENOENT;
+		if (obex_get_stream_start(os, path) < 0)
+			err = -ENOENT;
 
 	} else
-		return -EPERM;
+		err = -EPERM;
 
-	return 0;
+	g_free(folder);
+	g_free(path);
+	return err;
 }
 
 static void opp_disconnect(struct obex_session *os, void *user_data)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux