From: Aaron_shen <aarongt.shen@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Aaron_shen <aarongt.shen@gmail.com>
Subject: [PATCH BlueZ] obexd: reject to accept file when replying reject message
Date: Wed, 15 Mar 2023 18:04:35 +0800 [thread overview]
Message-ID: <20230315100435.5424-1-aarongt.shen@gmail.com> (raw)
It will accept file when obex agent replied any message
event though the message is org.bluez.obex.Error.Rejected.
The patch helps to reject a Bluetooth object push request if
user replied "org.bluez.obex.Error.Rejected" message according
to the doc/obex-agent-api.txt.
---
obexd/src/manager.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 01741fe62..849928603 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -38,6 +38,7 @@
#define TRANSFER_INTERFACE OBEXD_SERVICE ".Transfer1"
#define SESSION_INTERFACE OBEXD_SERVICE ".Session1"
#define AGENT_INTERFACE OBEXD_SERVICE ".Agent1"
+#define OBEX_ERROR_REJECT "org.bluez.obex.Error.Rejected"
#define TIMEOUT 60*1000 /* Timeout for user response (miliseconds) */
@@ -45,6 +46,7 @@ struct agent {
char *bus_name;
char *path;
gboolean auth_pending;
+ gboolean auth_reject;
char *new_name;
char *new_folder;
unsigned int watch_id;
@@ -631,6 +633,9 @@ static void agent_reply(DBusPendingCall *call, void *user_data)
if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY))
agent_cancel();
+ if (dbus_error_has_name(&derr, OBEX_ERROR_REJECT))
+ agent->auth_reject = TRUE;
+
dbus_error_free(&derr);
dbus_message_unref(reply);
return;
@@ -694,6 +699,7 @@ int manager_request_authorization(struct obex_transfer *transfer,
dbus_message_unref(msg);
agent->auth_pending = TRUE;
+ agent->auth_reject = FALSE;
got_reply = FALSE;
/* Catches errors before authorization response comes */
@@ -716,7 +722,7 @@ int manager_request_authorization(struct obex_transfer *transfer,
dbus_pending_call_unref(call);
- if (!agent || !agent->new_name)
+ if (!agent || !agent->new_name || agent->auth_reject)
return -EPERM;
*new_folder = agent->new_folder;
--
2.11.0
next reply other threads:[~2023-03-15 10:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 10:04 Aaron_shen [this message]
2023-03-15 11:10 ` [BlueZ] obexd: reject to accept file when replying reject message bluez.test.bot
2023-03-21 16:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230315100435.5424-1-aarongt.shen@gmail.com \
--to=aarongt.shen@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox