2015-06-19 06:58:50

by Gowtham Anandha Babu

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

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



2015-06-23 15:30:42

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH ] obexd/opp: Fix OPP GET request path

Hi Gowtham,

On Mon, Jun 22, 2015 at 3:46 PM, Gowtham Anandha Babu
<[email protected]> wrote:
> Ping.
>
>> -----Original Message-----
>> From: [email protected] [mailto:linux-bluetooth-
>> [email protected]] On Behalf Of Gowtham Anandha Babu
>> Sent: Friday, June 19, 2015 12:29 PM
>> To: [email protected]
>> Cc: [email protected]; Gowtham Anandha Babu
>> Subject: [PATCH ] obexd/opp: Fix OPP GET request path
>>
>> 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 [email protected] More majordomo
>> info at http://vger.kernel.org/majordomo-info.html

Applied, thanks.


--
Luiz Augusto von Dentz

2015-06-22 12:46:19

by Gowtham Anandha Babu

[permalink] [raw]
Subject: RE: [PATCH ] obexd/opp: Fix OPP GET request path

Ping.

> -----Original Message-----
> From: [email protected] [mailto:linux-bluetooth-
> [email protected]] On Behalf Of Gowtham Anandha Babu
> Sent: Friday, June 19, 2015 12:29 PM
> To: [email protected]
> Cc: [email protected]; Gowtham Anandha Babu
> Subject: [PATCH ] obexd/opp: Fix OPP GET request path
>
> 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 [email protected] More majordomo
> info at http://vger.kernel.org/majordomo-info.html