/* For maintaining Application Sync API call requests */
static GSList *invocation_list = NULL;
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+struct nspid_t {
+ char *unique_name;
+ gboolean is_container;
+};
+static GSList *nspid_list = NULL;
+#endif
+
static GDBusConnection *bt_service_conn;
static guint owner_id = 0;
static guint owner_sig_id = 0;
return BLUETOOTH_ERROR_NONE;
}
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+static void __bt_service_free_nspid(struct nspid_t *nspid)
+{
+ g_free(nspid->unique_name);
+ g_free(nspid);
+}
+
+static void __bt_service_cleanup_nspid_list(const char *unique_name)
+{
+ GSList *l;
+ struct nspid_t *nspid;
+
+ for (l = nspid_list; l; l = g_slist_next(l)) {
+ nspid = l->data;
+ if (!nspid)
+ continue;
+ if (!g_strcmp0(nspid->unique_name, unique_name)) {
+ nspid_list = g_slist_remove(nspid_list, nspid);
+ __bt_service_free_nspid(nspid);
+ return;
+ }
+ }
+}
+
+static gboolean __bt_service_is_container_request(const char *unique_name)
+{
+ int ret;
+ pid_t pid;
+ char path[1024], buf[1024];
+ FILE *fp;
+ gboolean is_container = FALSE;
+ GSList *l;
+ struct nspid_t *nspid;
+
+ for (l = nspid_list; l; l = g_slist_next(l)) {
+ nspid = l->data;
+ if (!nspid)
+ continue;
+ if (!g_strcmp0(nspid->unique_name, unique_name))
+ return nspid->is_container;
+ }
+
+ ret = __bt_service_get_sender_pid(unique_name, &pid);
+ if (ret != BLUETOOTH_ERROR_NONE)
+ return FALSE;
+
+ sprintf(path, "/proc/%d/status", pid);
+ fp = fopen(path, "r");
+ if (fp == NULL) {
+ BT_ERR("fopen() failed. %d(%s)", errno, strerror(errno));
+ return FALSE;
+ }
+
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (strstr(buf, "NSpid:")) {
+ char *p = strchr(buf + 7, '\t'); /* find 2nd '\t' */
+ if (p) {
+ BT_DBG("caller is container process");
+ is_container = TRUE;
+ goto out;
+ }
+ break;
+ }
+ }
+
+out:
+ nspid = g_malloc0(sizeof(struct nspid_t));
+ nspid->unique_name = g_strdup(unique_name);
+ nspid->is_container = is_container;
+ nspid_list = g_slist_append(nspid_list, nspid);
+ fclose(fp);
+ return is_container;
+}
+#endif
+
gboolean __bt_service_check_privilege(int function_name,
int service_type,
const char *unique_name)
retv_if(unique_name == NULL, FALSE);
retv_if(bt_service_conn == NULL, FALSE);
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+ /* Privilege will be checked in container if the request is from container */
+ if (__bt_service_is_container_request(unique_name)) {
+ BT_DBG("This request is from container, temporarily allow");
+ return TRUE;
+ }
+#endif
+
ret_val = cynara_creds_get_default_client_method(&client_creds_method);
if (ret_val != CYNARA_API_SUCCESS) {
cynara_strerror(ret_val, err_msg, sizeof(err_msg));
/* Stop the Transport Discovery service */
_bt_tds_stop_by_terminated_process(name);
+
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+ /* Cleanup the NSpid list */
+ __bt_service_cleanup_nspid_list(name);
+#endif
}
static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
__bt_service_register_object(bt_service_conn, NULL, FALSE);
}
+
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+ if (nspid_list) {
+ g_slist_free_full(nspid_list, (GDestroyNotify)__bt_service_free_nspid);
+ nspid_list = NULL;
+ }
+#endif
}
int _bt_service_cynara_init(void)