diff mbox series

[BlueZ] obexd: support to reply folder or error to store/reject file

Message ID 20230316084752.12071-1-aarongt.shen@gmail.com (mailing list archive)
State New, archived
Headers show
Series [BlueZ] obexd: support to reply folder or error to store/reject file | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Guiting Shen March 16, 2023, 8:47 a.m. UTC
It is not good to force agent to reply full path (including
filename) to store files because the opp_chkput() will
use the default folder and filename if folder and filename
is NULL.
The patch helps that the obex agent can reply the message
with full filename path or folder or NULL to accept file and
"org.bluez.obex.Error.Rejected" message to reject file.
---
 doc/obex-agent-api.txt | 10 ++++++----
 obexd/src/manager.c    | 12 ++++++++++--
 2 files changed, 16 insertions(+), 6 deletions(-)

Comments

bluez.test.bot@gmail.com March 16, 2023, 10:32 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=730675

---Test result---

Test Summary:
CheckPatch                    PASS      0.49 seconds
GitLint                       PASS      0.31 seconds
BuildEll                      PASS      33.46 seconds
BluezMake                     PASS      1170.79 seconds
MakeCheck                     PASS      12.33 seconds
MakeDistcheck                 PASS      186.45 seconds
CheckValgrind                 PASS      312.97 seconds
CheckSmatch                   PASS      427.50 seconds
bluezmakeextell               PASS      125.19 seconds
IncrementalBuild              PASS      954.37 seconds
ScanBuild                     PASS      1366.63 seconds



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/doc/obex-agent-api.txt b/doc/obex-agent-api.txt
index 3923da6df..14e40588e 100644
--- a/doc/obex-agent-api.txt
+++ b/doc/obex-agent-api.txt
@@ -46,10 +46,12 @@  Methods		void Release()
 			This method gets called when the service daemon
 			needs to accept/reject a Bluetooth object push request.
 
-			Returns the full path (including the filename) where
-			the object shall be stored. The tranfer object will
-			contain a Filename property that contains the default
-			location and name that can be returned.
+			Returns the full filename or directory name where
+			the object shall be stored. Or error message
+			"org.bluez.obex.Error.Rejected" to reject the request.
+			The transfer object will contain a Filename property
+			that contains the default location and name that can
+			be returned.
 
 			Possible errors: org.bluez.obex.Error.Rejected
 			                 org.bluez.obex.Error.Canceled
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 01741fe62..cd6e81942 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;
@@ -630,6 +632,8 @@  static void agent_reply(DBusPendingCall *call, void *user_data)
 
 		if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY))
 			agent_cancel();
+		else if (dbus_error_has_name(&derr, OBEX_ERROR_REJECT))
+			agent->auth_reject = TRUE;
 
 		dbus_error_free(&derr);
 		dbus_message_unref(reply);
@@ -646,7 +650,10 @@  static void agent_reply(DBusPendingCall *call, void *user_data)
 			agent->new_name = g_strdup(name);
 			agent->new_folder = NULL;
 		} else {
-			agent->new_name = g_strdup(slash + 1);
+			if (strlen(slash) == 1)
+				agent->new_name = NULL;
+			else
+				agent->new_name = g_strdup(slash + 1);
 			agent->new_folder = g_strndup(name, slash - name);
 		}
 	}
@@ -694,6 +701,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 +724,7 @@  int manager_request_authorization(struct obex_transfer *transfer,
 
 	dbus_pending_call_unref(call);
 
-	if (!agent || !agent->new_name)
+	if (!agent || agent->auth_reject)
 		return -EPERM;
 
 	*new_folder = agent->new_folder;