Add the privilege check for GATT SERVER APIs 72/73172/1
authorHyuk Lee <hyuk0512.lee@samsung.com>
Tue, 7 Jun 2016 04:49:43 +0000 (13:49 +0900)
committerHyuk Lee <hyuk0512.lee@samsung.com>
Tue, 7 Jun 2016 04:49:43 +0000 (13:49 +0900)
Change-Id: I8cb8bcbb333837f06918b5e02b8742642abfe1db
Signed-off-by: Hyuk Lee <hyuk0512.lee@samsung.com>
bt-api/bt-gatt-service.c
bt-service/bt-request-handler.c
include/bt-internal-types.h

index 0963319..ff3d748 100644 (file)
@@ -23,6 +23,7 @@
 #include<stdint.h>
 
 #include "bt-common.h"
+#include "bt-internal-types.h"
 
 #define NUMBER_OF_FLAGS        10
 
@@ -2020,6 +2021,12 @@ int bluetooth_gatt_get_service(const char *svc_uuid)
 BT_EXPORT_API int bluetooth_gatt_register_service(
                        const char *svc_path)
 {
+       if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_GATT_REGISTER_SERVICE)
+                       == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have aprivilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
        register_pending_cnt++;
 
        if (__bt_gatt_get_service_state(svc_path)) {
@@ -2036,6 +2043,12 @@ BT_EXPORT_API int bluetooth_gatt_register_application(void)
 {
        GDBusProxy *proxy = NULL;
 
+       if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_GATT_REGISTER_APPLICATION)
+                       == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have aprivilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
        proxy = __bt_gatt_gdbus_get_manager_proxy("org.bluez",
                                        "/org/bluez/hci0", GATT_MNGR_INTERFACE);
        if (proxy == NULL || app_path == NULL)
@@ -2251,6 +2264,12 @@ BT_EXPORT_API int bluetooth_gatt_send_response(int request_id, guint req_type,
 {
        struct gatt_req_info *req_info = NULL;
 
+       if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_GATT_SEND_RESPONSE)
+                       == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have aprivilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
        req_info = __bt_gatt_find_request_info(request_id);
 
        if (req_info) {
index 0deefbf..f6f0254 100644 (file)
@@ -2586,6 +2586,9 @@ gboolean __bt_service_check_privilege(int function_name,
         case BT_GATT_SET_PROPERTY_REQUEST:
         case BT_GATT_READ_CHARACTERISTIC:
         case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
+        case BT_GATT_REGISTER_APPLICATION:
+        case BT_GATT_REGISTER_SERVICE:
+        case BT_GATT_SEND_RESPONSE:
                case BT_PBAP_CONNECT:
                case BT_PBAP_DISCONNECT:
                case BT_PBAP_GET_PHONEBOOK_SIZE:
index e288029..2fa871f 100644 (file)
@@ -290,6 +290,9 @@ typedef enum {
        BT_GATT_WATCH_CHARACTERISTIC,
        BT_GATT_UNWATCH_CHARACTERISTIC,
 #endif
+       BT_GATT_REGISTER_APPLICATION,
+       BT_GATT_REGISTER_SERVICE,
+       BT_GATT_SEND_RESPONSE,
        BT_LE_IPSP_INIT = BT_FUNC_IPSP_BASE,
        BT_LE_IPSP_DEINIT,
        BT_LE_IPSP_CONNECT,