Skip to content

Commit

Permalink
obexd: reject to accept file when replying reject message
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Aaron_shen authored and Vudentz committed Mar 21, 2023
1 parent 1de4178 commit 338ba43
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion obexd/src/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@
#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) */

struct agent {
char *bus_name;
char *path;
gboolean auth_pending;
gboolean auth_reject;
char *new_name;
char *new_folder;
unsigned int watch_id;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
Expand Down

0 comments on commit 338ba43

Please sign in to comment.