From 72f524f19b96405367b3b5b997a271e3f07b640d Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Mon, 28 Mar 2016 10:58:18 +0900 Subject: [PATCH] Change the smack label to System for HDP / RFCOMM / AVDTP FD Change-Id: I70c23d4ac2b1a221ddfc928d53df6e7b3f4bd296 Signed-off-by: DoHyun Pyun --- profiles/audio/transport.c | 23 +++++++++++++++++++++++ profiles/health/hdp.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/profile.c | 26 ++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 112ec17..91b9cae 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -30,6 +30,12 @@ #include +#ifdef __TIZEN_PATCH__ +#include +#include +#include +#endif + #include "lib/bluetooth.h" #include "lib/sdp.h" #include "lib/uuid.h" @@ -310,6 +316,23 @@ static void a2dp_resume_complete(struct avdtp *session, media_transport_set_fd(transport, fd, imtu, omtu); +#ifdef __TIZEN_PATCH__ + { + DBG("Set smack label!"); + int ret; + + ret = fsetxattr(fd, XATTR_NAME_SMACKIPIN, "System", sizeof("System"), 0); + if (ret != 0) { + DBG("Set attr error: %d", ret); + } + + ret = fsetxattr(fd, XATTR_NAME_SMACKIPOUT, "System", sizeof("System"), 0); + if (ret != 0) { + DBG("Set attr error: %d", ret); + } + } +#endif + ret = g_dbus_send_reply(btd_get_dbus_connection(), req->msg, DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_UINT16, &imtu, diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c index bc3b38a..2637e32 100644 --- a/profiles/health/hdp.c +++ b/profiles/health/hdp.c @@ -31,6 +31,12 @@ #include +#ifdef __TIZEN_PATCH__ +#include +#include +#include +#endif + #include "lib/bluetooth.h" #include "lib/l2cap.h" #include "lib/sdp.h" @@ -513,6 +519,23 @@ static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data) return; } +#ifdef __TIZEN_PATCH__ + { + DBG("Set smack label!"); + int ret; + + ret = fsetxattr(fd, XATTR_NAME_SMACKIPIN, "System", sizeof("System"), 0); + if (ret != 0) { + DBG("Set attr error: %d", ret); + } + + ret = fsetxattr(fd, XATTR_NAME_SMACKIPOUT, "System", sizeof("System"), 0); + if (ret != 0) { + DBG("Set attr error: %d", ret); + } + } +#endif + reply = g_dbus_create_reply(dc_data->msg, DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_INVALID); g_dbus_send_message(conn, reply); @@ -603,9 +626,30 @@ static DBusMessage *channel_acquire_continue(struct hdp_tmp_dc_data *data, } fd = mcap_mdl_get_fd(data->hdp_chann->mdl); + +#ifndef __TIZEN_PATCH__ if (fd >= 0) return g_dbus_create_reply(data->msg, DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_INVALID); +#else + if (fd >= 0) { + int ret; + + DBG("Set smack label!"); + ret = fsetxattr(fd, XATTR_NAME_SMACKIPIN, "System", sizeof("System"), 0); + if (ret != 0) { + DBG("Set attr error: %d", ret); + } + + ret = fsetxattr(fd, XATTR_NAME_SMACKIPOUT, "System", sizeof("System"), 0); + if (ret != 0) { + DBG("Set attr error: %d", ret); + } + + return g_dbus_create_reply(data->msg, DBUS_TYPE_UNIX_FD, &fd, + DBUS_TYPE_INVALID); + } +#endif hdp_tmp_dc_data_ref(data); if (mcap_reconnect_mdl(data->hdp_chann->mdl, device_reconnect_mdl_cb, diff --git a/src/profile.c b/src/profile.c index f174f7e..ea8ad99 100644 --- a/src/profile.c +++ b/src/profile.c @@ -33,6 +33,12 @@ #include #include +#ifdef __TIZEN_PATCH__ +#include +#include +#include +#endif + #include "lib/bluetooth.h" #include "lib/sdp.h" #include "lib/sdp_lib.h" @@ -1041,6 +1047,8 @@ static void new_conn_reply(DBusPendingCall *call, void *user_data) DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusError err; + DBG("+"); + dbus_error_init(&err); dbus_set_error_from_message(&err, reply); @@ -1200,6 +1208,24 @@ static bool send_new_connection(struct ext_profile *ext, struct ext_io *conn) dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path); fd = g_io_channel_unix_get_fd(conn->io); + +#ifdef __TIZEN_PATCH__ +{ + DBG("Set smack label!"); + int ret; + + ret = fsetxattr(fd, XATTR_NAME_SMACKIPIN, "System", sizeof("System"), 0); + if (ret != 0) { + DBG("Set attr error: %d", ret); + } + + ret = fsetxattr(fd, XATTR_NAME_SMACKIPOUT, "System", sizeof("System"), 0); + if (ret != 0) { + DBG("Set attr error: %d", ret); + } +} +#endif + dbus_message_iter_append_basic(&iter, DBUS_TYPE_UNIX_FD, &fd); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict); -- 2.7.4