diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-07-29 18:05:28 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-07-31 09:28:25 -0700 |
commit | d1d197e5a134db00ce26a65b8d79cfbe2bee9fac (patch) | |
tree | 62fe6b29b3e717e67da955cb5d84618d387db65e /binding | |
parent | 8b9c25f4546d190d9cf5851c5b88f50db2f8cda2 (diff) |
binding: bluetooth-map: move data transfer results to shared directoryhalibut_8.0.6halibut_8.0.5halibut_8.0.4halibut_8.0.3halibut_8.0.2halibut_8.0.1halibut_8.0.0halibut/8.0.6halibut/8.0.5halibut/8.0.4halibut/8.0.3halibut/8.0.2halibut/8.0.1halibut/8.0.08.0.68.0.58.0.48.0.38.0.28.0.18.0.0halibut
Data transfers needs to be stored in /run/user/UID/usrshr to
get the User::App-Shared Smack label on creation from obexd
Bug-AGL: SPEC-2695
Change-Id: Ia482234fe7356cb0965c1ed7e4065e72543514bd
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r-- | binding/bluetooth-map-api.c | 11 | ||||
-rw-r--r-- | binding/bluetooth-map-common.h | 17 |
2 files changed, 23 insertions, 5 deletions
diff --git a/binding/bluetooth-map-api.c b/binding/bluetooth-map-api.c index 2784243..40acb7f 100644 --- a/binding/bluetooth-map-api.c +++ b/binding/bluetooth-map-api.c @@ -314,9 +314,8 @@ static void compose(afb_req_t request) GError *error = NULL; GString *message = NULL; GVariant *params, *reply; - gchar *name, *session; + gchar *name, *session, *hash; struct call_work *cw; - int fd; call_work_lock(ns); if (!ns || !ns->session_path) { @@ -333,8 +332,10 @@ static void compose(afb_req_t request) goto err_msg_invalid; } - fd = g_file_open_tmp("obex-clientXXXXXX", &name, NULL); - close(fd); + hash = g_compute_checksum_for_string(G_CHECKSUM_MD5, + message->str, sizeof(message->str)); + name = g_strconcat(get_obex_tmpdir(), "/obex-client-", hash, NULL); + g_free(hash); g_file_set_contents(name, message->str, -1, NULL); g_string_free(message, TRUE); @@ -441,7 +442,7 @@ static void message(afb_req_t request) cw->request = request; afb_req_addref(request); - filename = g_strconcat("/tmp/obex-message-", handle, NULL); + filename = g_strconcat(get_obex_tmpdir(), "/obex-message-", handle, NULL); params = g_variant_new("(&sb)", filename, g_variant_new_boolean(FALSE)); cw->cpw = bluez_call_async(ns, BLUEZ_AT_MESSAGE, path, "Get", params, &error, diff --git a/binding/bluetooth-map-common.h b/binding/bluetooth-map-common.h index f154c91..6e93b9f 100644 --- a/binding/bluetooth-map-common.h +++ b/binding/bluetooth-map-common.h @@ -177,4 +177,21 @@ json_object *get_named_property(const struct property_info *pi, json_object *bmessage_parse(const gchar *bmessage); GString *bmessage_encoder(afb_req_t request); + +/* helper defines */ + +#define OBEX_USRSHR_PATH "/run/user/%d/usrshr" + +#define get_obex_tmpdir() \ + ({ \ + uid_t __uid = getuid(); \ + size_t __len; \ + __len = sizeof(uid_t) + 1 + sizeof(OBEX_USRSHR_PATH) + 1; \ + char *__tpath; \ + __tpath = alloca(__len + 1); \ + snprintf(__tpath, __len, \ + OBEX_USRSHR_PATH, __uid); \ + __tpath; \ + }) + #endif /* BLUETOOTH_MAP_COMMON_H */ |