From 8b907ead676c86abcdd5e1cb04b95211a19fc7a8 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Thu, 17 Dec 2015 16:35:02 +0900 Subject: [PATCH] Revert "Integrate Cynara into bluetooth-share" This reverts commit 9003c0f21d3efef490df45b4bd7865910de1f641. Change-Id: Ibdb97d7863b721e65028d29c1d2ef69c26de067a --- bt-share/CMakeLists.txt | 4 +- bt-share/include/bt-share-cynara.h | 41 -------------- bt-share/src/bt-share-cynara.c | 113 ------------------------------------- bt-share/src/bt-share-ipc.c | 22 -------- bt-share/src/bt-share-main.c | 7 --- packaging/bluetooth-share.spec | 2 - 6 files changed, 1 insertion(+), 188 deletions(-) delete mode 100644 bt-share/include/bt-share-cynara.h delete mode 100644 bt-share/src/bt-share-cynara.c diff --git a/bt-share/CMakeLists.txt b/bt-share/CMakeLists.txt index b443cfe..85d2df6 100644 --- a/bt-share/CMakeLists.txt +++ b/bt-share/CMakeLists.txt @@ -8,7 +8,6 @@ src/obex-event-handler.c src/bt-share-syspopup.c src/bt-share-ipc.c src/bt-share-noti-handler.c -src/bt-share-cynara.c ) @@ -23,8 +22,7 @@ pkg_check_modules(pkgs REQUIRED glib-2.0 bluetooth-api notification sqlite3 ecore-file appsvc appcore-efl libprivilege-control capi-content-media-content - libtzplatform-config - cynara-creds-dbus cynara-client cynara-session) + libtzplatform-config) pkg_check_modules(CALENDAR_SERVICE2 calendar-service2) pkg_check_modules(CONTACTS_SERVICE2 contacts-service2) diff --git a/bt-share/include/bt-share-cynara.h b/bt-share/include/bt-share-cynara.h deleted file mode 100644 index 79d28dd..0000000 --- a/bt-share/include/bt-share-cynara.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * bluetooth-share - * - * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef __DEF_BLUETOOTH_SHARE_CYNARA_H_ -#define __DEF_BLUETOOTH_SHARE_CYNARA_H_ - -#include -#include - -#define BT_SHARE_PRIVILEGE "http://tizen.org/privilege/bluetooth" - -typedef struct -{ - pid_t pid; - char *uid; - char *smack; -} bt_share_cynara_creds; - -int _bt_share_cynara_init(void); -int _bt_share_cynara_get_creds(DBusConnection *conn, const char *sender, - bt_share_cynara_creds *creds); -int _bt_share_cynara_check(const bt_share_cynara_creds *creds, const char *privilege); -void _bt_share_cynara_finish(void); - -#endif /* __DEF_BLUETOOTH_SHARE_CYNARA_H_ */ diff --git a/bt-share/src/bt-share-cynara.c b/bt-share/src/bt-share-cynara.c deleted file mode 100644 index 5e9e693..0000000 --- a/bt-share/src/bt-share-cynara.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * bluetooth-share - * - * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "bt-share-cynara.h" - -#include "applog.h" -#include "bt-share-common.h" - -#include -#include -#include -#include -#include - -static cynara *_cynara = NULL; -const unsigned int error_msg_size = 256; - -// initialize cynara -int _bt_share_cynara_init(void) -{ - char error_msg[error_msg_size]; - int ret; - - ret = cynara_initialize(&_cynara, NULL); - if (ret != CYNARA_API_SUCCESS) - { - cynara_strerror(ret, error_msg, error_msg_size); - ERR("cynara_initialize failed: %s\n", error_msg); - return BT_SHARE_FAIL; - } - - return BT_SHARE_ERROR_NONE; -} - -// fill creds structure with data needed to perform checks using cynara-creds lib -int _bt_share_cynara_get_creds(DBusConnection *conn, const char *sender, - bt_share_cynara_creds *creds) -{ - char error_msg[error_msg_size]; - int ret; - - ret = cynara_creds_dbus_get_pid(conn, sender, &(creds->pid)); - if (ret < 0) { - cynara_strerror(ret, error_msg, error_msg_size); - ERR("cynara_creds_dbus_get_pid failed: %s\n"); - return BT_SHARE_FAIL; - } - - ret = cynara_creds_dbus_get_user(conn, sender, USER_METHOD_UID, &(creds->uid)); - if (ret < 0) { - cynara_strerror(ret, error_msg, error_msg_size); - ERR("cynara_creds_dbus_get_user failed\n"); - return BT_SHARE_FAIL; - } - - ret = cynara_creds_dbus_get_client(conn, sender, CLIENT_METHOD_SMACK, &(creds->smack)); - if (ret < 0) { - cynara_strerror(ret, error_msg, error_msg_size); - ERR("cynara_creds_dbus_get_client failed\n"); - return BT_SHARE_FAIL; - } - - return BT_SHARE_ERROR_NONE; -} - -// check if client has required privilege -int _bt_share_cynara_check(const bt_share_cynara_creds *creds, const char *privilege) -{ - int ret; - char *client_session; - char error_msg[error_msg_size]; - - if (!creds || !privilege) - return BT_SHARE_FAIL; - - client_session = cynara_session_from_pid(creds->pid); - if (!client_session) { - ERR("cynara_session_from_pid failed\n"); - return BT_SHARE_FAIL; - } - - ret = cynara_check(_cynara, creds->smack, client_session, creds->uid, privilege); - if (ret != CYNARA_API_ACCESS_ALLOWED) { - cynara_strerror(ret, error_msg, error_msg_size); - ERR("cynara_check error: %s\n", error_msg); - } - - free(client_session); - return ret == CYNARA_API_ACCESS_ALLOWED ? BT_SHARE_ERROR_NONE : BT_SHARE_FAIL; -} - -// finish working with cynara -void _bt_share_cynara_finish(void) -{ - cynara_finish(_cynara); - _cynara = NULL; -} diff --git a/bt-share/src/bt-share-ipc.c b/bt-share/src/bt-share-ipc.c index 2a50c05..7e9ba26 100644 --- a/bt-share/src/bt-share-ipc.c +++ b/bt-share/src/bt-share-ipc.c @@ -38,7 +38,6 @@ #include "obex-event-handler.h" #include "bluetooth-share-api.h" #include "bt-share-common.h" -#include "bt-share-cynara.h" GSList *bt_transfer_list = NULL; DBusConnection *dbus_connection = NULL; @@ -223,9 +222,7 @@ static DBusHandlerResult __event_filter(DBusConnection *sys_conn, { int ret; char *member; - const char *sender; const char *path = dbus_message_get_path(msg); - bt_share_cynara_creds sender_creds; if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -236,13 +233,6 @@ static DBusHandlerResult __event_filter(DBusConnection *sys_conn, member = (char *)dbus_message_get_member(msg); DBG("member (%s)\n", member); - sender = dbus_message_get_sender(msg); - ret = _bt_share_cynara_get_creds(sys_conn, sender, &sender_creds); - if (ret != 0) { - ERR("acquiring cynara creds failed\n"); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - if (dbus_message_is_signal(msg, BT_SYSPOPUP_INTERFACE, BT_SYSPOPUP_METHOD_RESPONSE)) { int res = 0; dbus_message_get_args(msg, NULL, @@ -251,12 +241,6 @@ static DBusHandlerResult __event_filter(DBusConnection *sys_conn, __popup_res_cb(res); } else if (dbus_message_is_signal(msg, BT_UG_IPC_INTERFACE, BT_UG_IPC_METHOD_SEND)) { opc_transfer_info_t *node; - - if (_bt_share_cynara_check(&sender_creds, BT_SHARE_PRIVILEGE) != BT_SHARE_FAIL) { - ERR("Cynara denied file send\n"); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - node = __add_transfer_info(msg); if (node == NULL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -291,12 +275,6 @@ static DBusHandlerResult __event_filter(DBusConnection *sys_conn, } else if (dbus_message_is_signal(msg, BT_SHARE_UI_INTERFACE, BT_SHARE_UI_SIGNAL_SEND_FILE)) { opc_transfer_info_t *node; - - if (_bt_share_cynara_check(&sender_creds, BT_SHARE_PRIVILEGE) != BT_SHARE_FAIL) { - ERR("Cynara denied file send\n"); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - node = __add_transfer_info(msg); if (node == NULL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; diff --git a/bt-share/src/bt-share-main.c b/bt-share/src/bt-share-main.c index d9c253c..59ffc36 100644 --- a/bt-share/src/bt-share-main.c +++ b/bt-share/src/bt-share-main.c @@ -36,7 +36,6 @@ #include "bt-share-resource.h" #include "bt-share-notification.h" #include "bt-share-common.h" -#include "bt-share-cynara.h" #include "bluetooth-share-api.h" @@ -308,11 +307,6 @@ int main(void) PC_OPERATION_SUCCESS) ERR("Failed to set app privilege.\n"); - if (_bt_share_cynara_init()) { - ERR("Failed to initialize Cynara.\n"); - return -1; - } - bluetooth_register_callback(_bt_share_event_handler, NULL); ret = bluetooth_opc_init(); if (ret != BLUETOOTH_ERROR_NONE) { @@ -341,7 +335,6 @@ int main(void) _bt_delete_notification(noti); __bt_release_service(&ad); - _bt_share_cynara_finish(); return 0; } diff --git a/packaging/bluetooth-share.spec b/packaging/bluetooth-share.spec index 17cce0a..30ffccd 100644 --- a/packaging/bluetooth-share.spec +++ b/packaging/bluetooth-share.spec @@ -34,8 +34,6 @@ BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(libprivilege-control) BuildRequires: pkgconfig(capi-content-media-content) BuildRequires: pkgconfig(libtzplatform-config) -BuildRequires: pkgconfig(cynara-client) -BuildRequires: pkgconfig(cynara-session) %description Bluetooth File Share Agent -- 2.7.4