From 10c9533ff9247c695185b340c77e42e428f6e14c Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Thu, 13 Aug 2015 12:11:56 +0900 Subject: [PATCH] Remove unused dependency and deprecated APIs Change-Id: Ib950fc07dcff4463f97d739eb6ac00c3a2d18269 Signed-off-by: Yunjin Lee --- capi/CMakeLists.txt | 12 +-- capi/include/privilege_checker.h | 45 -------- capi/include/privilege_db_manager.h | 13 ++- capi/include/privilege_info.h | 6 +- capi/include/privilege_info_types.h | 4 +- capi/include/privilege_manager.h | 19 ++-- capi/src/privilege_checker.c | 198 ----------------------------------- capi/src/privilege_manager.c | 114 -------------------- packaging/privilege-checker.manifest | 3 - packaging/privilege-checker.spec | 10 +- 10 files changed, 28 insertions(+), 396 deletions(-) delete mode 100755 capi/include/privilege_checker.h delete mode 100755 capi/src/privilege_checker.c diff --git a/capi/CMakeLists.txt b/capi/CMakeLists.txt index 8478a81..1265af8 100644 --- a/capi/CMakeLists.txt +++ b/capi/CMakeLists.txt @@ -12,10 +12,10 @@ INCLUDE_DIRECTORIES( "${INC_DIR}" ) -SET(pc_requires "capi-base-common") +SET(pc_requires "") INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_name} REQUIRED capi-base-common dlog pkgmgr-info capi-appfw-package-manager glib-2.0) +pkg_check_modules(${fw_name} REQUIRED dlog pkgmgr-info glib-2.0) FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) @@ -30,14 +30,12 @@ ENDIF("${ARCH}" STREQUAL "arm") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DSLP_DEBUG") MESSAGE("PROFILE_TYPE = ${PROFILE_TYPE}") -IF("${PROFILE_TYPE}" STREQUAL "TV") - ADD_DEFINITIONS("-DPROFILE_TYPE_TV") -ELSEIF("${PROFILE_TYPE}" STREQUAL "WEARABLE") +IF("${PROFILE_TYPE}" STREQUAL "WEARABLE") ADD_DEFINITIONS("-DPROFILE_TYPE_WEARABLE") ELSEIF("${PROFILE_TYPE}" STREQUAL "MOBILE") ADD_DEFINITIONS("-DPROFILE_TYPE_MOBILE") -ELSE() - ADD_DEFINITIONS("-DPROFILE_TYPE_COMMON") +ELSEIF("${PROFILE_TYPE}" STREQUAL "TV") + ADD_DEFINITIONS("-DPROFILE_TYPE_TV") ENDIF() SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIBDIR}") diff --git a/capi/include/privilege_checker.h b/capi/include/privilege_checker.h deleted file mode 100755 index 2bf3084..0000000 --- a/capi/include/privilege_checker.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 __TIZEN_SECURITY_PRIVILEGE_CHECKER_H -#define __TIZEN_SECURITY_PRIVILEGE_CHECKER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Enumerations of error code for Privilege Information. - */ -typedef enum -{ - PRIV_CHECKER_ERR_NONE = TIZEN_ERROR_NONE, - PRIV_CHECKER_ERR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, - PRIV_CHECKER_ERR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, - PRIV_CHECKER_ERR_INTERNAL_ERROR = TIZEN_ERROR_UNKNOWN, - PRIV_CHECKER_ERR_NO_DATA = TIZEN_ERROR_NO_DATA, - PRIV_CHECKER_ERR_INVALID_PRIVILEGE = TIZEN_ERROR_PERMISSION_DENIED, -} privilege_checker_error_e; - -EXPORT_API int privilege_checker_check_package_privilege(const char* package_id, const char *privilege); - -#ifdef __cplusplus -} -#endif - -#endif // __TIZEN_SECURITY_PRIVILEGE_INFO_H diff --git a/capi/include/privilege_db_manager.h b/capi/include/privilege_db_manager.h index be87159..d60ad1d 100755 --- a/capi/include/privilege_db_manager.h +++ b/capi/include/privilege_db_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ #ifndef __PRIVILEGE_DB_MANAGER_H #define __PRIVILEGE_DB_MANAGER_H -#include #include typedef struct @@ -38,11 +37,11 @@ typedef struct typedef enum { - PRIVILEGE_DB_MANAGER_ERR_NONE = TIZEN_ERROR_NONE, - PRIVILEGE_DB_NO_EXIST_RESULT = TIZEN_ERROR_NO_DATA, - PRIVILEGE_DB_MANAGER_ERR_CONNECTION_FAIL = TIZEN_ERROR_UNKNOWN, - PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY = TIZEN_ERROR_INVALID_PARAMETER, - PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, + PRIVILEGE_DB_MANAGER_ERR_NONE = 0, + PRIVILEGE_DB_NO_EXIST_RESULT = 1, + PRIVILEGE_DB_MANAGER_ERR_CONNECTION_FAIL = 2, + PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY = 3, + PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY = 4, } privilege_db_manager_error_e; typedef enum diff --git a/capi/include/privilege_info.h b/capi/include/privilege_info.h index 2feb9bf..55b245e 100644 --- a/capi/include/privilege_info.h +++ b/capi/include/privilege_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -17,7 +17,9 @@ #ifndef __TIZEN_SECURITY_PRIVILEGE_INFO_H #define __TIZEN_SECURITY_PRIVILEGE_INFO_H -#include +#ifndef EXPORT_API +#define EXPORT_API __attribute__((__visibility__("default"))) +#endif #ifdef __cplusplus extern "C" { #endif diff --git a/capi/include/privilege_info_types.h b/capi/include/privilege_info_types.h index 7fb2a6a..d9cddd1 100644 --- a/capi/include/privilege_info_types.h +++ b/capi/include/privilege_info_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -17,8 +17,6 @@ #ifndef __TIZEN_SECURITY_PRIVILEGE_INFO_TYPES_H #define __TIZEN_SECURITY_PRIVIELGE_INFO_TYPES_H -#include - #ifdef __cplusplus extern "C" { #endif diff --git a/capi/include/privilege_manager.h b/capi/include/privilege_manager.h index 4bcb9c0..5c10f8c 100755 --- a/capi/include/privilege_manager.h +++ b/capi/include/privilege_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -17,7 +17,10 @@ #ifndef __TIZEN_SECURITY_PRIVILEGE_MANAGER_H #define __TIZEN_SECURITY_PRIVILEGE_MANAGER_H -#include +#ifndef EXPORT_API +#define EXPORT_API __attribute__((__visibility__("default"))) +#endif + #include #include "privilege_info.h" @@ -41,23 +44,21 @@ typedef enum /** - * @brief verify privilege name and level in the privilege list. + * @brief verify privilege in the privilege list by checking its name and level at given api version. * @remarks @a privilege_list must be released with free() by you. - * @remarks @a error_privilege_name must be released with free() by you. + * @remarks @a error_message must be released with free() by you. + * @param [in] api_version The api version of the application * @param [in] privilege_manager_package_type_e The privilege_manager_package_type_e * @param [in] privilege_list The privilege_list * @param [in] privilege_manager_visibility_e The privilege_manager_visibility_e - * @param [out] error_privilege_name The error_privilege_name's value is assigned when PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL and PRVMGR_ERR_NO_EXIST_PRIVILEGE are returned, otherwise null is assigned. + * @param [out] error_message The error_message's value is assigned when the return value isn't PRVMGR_ERR_NONE, otherwise null is assigned. * @return 0 on success, otherwise a negative error value. * @retval #PRVMGR_ERR_NONE Successful - * @retval #PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL privilege level is higher than visibility. Error_privilege_name'value is assigned. - * @retval #PRVMGR_ERR_NO_EXIST_PRIVILEGE privilege don't exist. Error_privilege_name'value is assigned. * @retval #PRVMGR_ERR_OUT_OF_MEMORY Out of memory + * @retvak #PRVMGR_ERR_INVALID_PRIVILEGE The privilege_list contains invalid privilege(s). * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error */ -EXPORT_API int privilege_manager_verify_privilege_list(privilege_manager_package_type_e package_type, GList* privilege_list, privilege_manager_visibility_e visibility, char **error_privilege_name); - EXPORT_API int privilege_manager_verify_privilege(const char* api_version, privilege_manager_package_type_e package_type, GList* privilege_list, privilege_manager_visibility_e visibility, char **error_message); #ifdef __cplusplus diff --git a/capi/src/privilege_checker.c b/capi/src/privilege_checker.c deleted file mode 100755 index fc875f8..0000000 --- a/capi/src/privilege_checker.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 -#include -#include -#include -#include -#include - -#define COLOR_RED "\033[0;40;31m" -#define COLOR_LIGHTBLUE "\033[1;40;34m" -#define COLOR_YELLOW "\033[1;40;33m" -#define COLOR_END "\033[0;m" -#define COLOR_GRAY "\033[1;40;30m" -#define COLOR_MAGENTA "\033[1;35m" - -#define LOG_PREFIX -#define FUNC_BEGIN() \ - do {\ - LOGD(COLOR_LIGHTBLUE""LOG_PREFIX" BEGIN >>>>"COLOR_END);\ - } while (0); - -#ifdef LOG_TAG -#undef LOG_TAG -#define LOG_TAG "PRIVILEGE_CHECKER" -#endif - -#define TryReturn(condition, returnValue, ...) \ - if (!(condition)) { \ - LOGE(__VA_ARGS__); \ - return returnValue; \ - } \ - else {;} - -#define CACHED_PRIVILEGE_MAX 256 -#define SUB_HASH(str, len, value) ( (str[len-1] << 24) | (str[len-2] << 16) | value ) - -typedef struct _cached_privilege_s{ - char* privilege_name; - int hash_value; -} cached_privilege_s; - -static cached_privilege_s g_cached_privileges[CACHED_PRIVILEGE_MAX]; -static int g_cached_privileges_size = 0; -static int g_isMached = false; - -int __privilege_checker_hash(const char* privilege_name) -{ - TryReturn(privilege_name != NULL, -1, "[PRIV_CHECKER_ERR_INVALID_PARAMETER] privilege_name is NULL!"); - int len = strlen(privilege_name); - TryReturn(len >= 2, -1, "[PRIV_CHECKER_ERR_INVALID_PARAMETER] privilege_name's size must be more than 2!"); - int hash_value = 0; - int i=0; - - for(i=0; i 1){ - LOGD("There are %d matched hash value", matched_cnt); - LOGD("Check privilege string"); - - LOGD("Privilege Name : %s", privilege_name); - LOGD("Cached Privilege Name : %s", g_cached_privileges[matched_index].privilege_name); - - //check string privilege with last hash-matched one. - if(strncmp(privilege_name, g_cached_privileges[matched_index].privilege_name, len) == 0) - { - LOGD("Found cached string privilege"); - return PRIV_CHECKER_ERR_NONE; - } - - //check string privilege with rest of them. - for(i=0; inext) - { - privilege_info_db_row_s* privilege_info_db_row = (privilege_info_db_row_s*)l->data; - if(privilege_info_db_row->privilege_name != NULL) - free(privilege_info_db_row->privilege_name); - } -} - static int __privilege_manager_check_privilege_list(const char* api_version, const char* privilege, GList* vaild_privilege_list, int* privilege_level, char** changed_to, char** valid_api_version) { @@ -325,97 +305,3 @@ FINISH: } -static int __privilege_manager_core_privilege_level(const char* privilege, int* privilege_level) -{ - TryReturn(privilege != NULL, PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL"); - - int ret; - GList* privilege_list; - ret = privilege_db_manager_get_privilege_list("2.4",PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_CORE, &privilege_list); - if(ret != PRIVILEGE_DB_MANAGER_ERR_NONE){ - LOGE("[FAIL TO CALL FUNCTION] privilege_db_manager_get_privilege_list()"); - return PRVMGR_ERR_INTERNAL_ERROR; - } - - GList* l = NULL; - for (l = privilege_list; l != NULL; l = l->next) - { - privilege_info_db_row_s* privilege_info_db_row = (privilege_info_db_row_s*)l->data; - if (strcmp(privilege_info_db_row->privilege_name, privilege) == 0) - { - *privilege_level = privilege_info_db_row->privilege_level_id; - __free_privilege_list(privilege_list); - return PRVMGR_ERR_NONE; - } - } - __free_privilege_list(privilege_list); - - return PRVMGR_ERR_NO_EXIST_PRIVILEGE; -} - -int privilege_manager_verify_privilege_list(privilege_manager_package_type_e package_type, GList* privilege_list, privilege_manager_visibility_e visibility, char** error_privilege_name) -{ - LOGD("privilege_info_compare_privilege_level called"); - GList *l; - int ret; - int i = 0; - *error_privilege_name = NULL; - - TryReturn(privilege_list != NULL, PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege_list is NULL"); - - for (l = privilege_list; l != NULL; l = l->next) - { - int privilege_level_id; - char* privilege_name = (char*)l->data; - - TryReturn(privilege_name != NULL, PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege_list[%d] is NULL", i); - i++; - - LOGD("Checking privilege : %s", privilege_name); - - ret = __privilege_manager_core_privilege_level(privilege_name, &privilege_level_id); - if(ret == PRVMGR_ERR_NO_EXIST_PRIVILEGE) - { - LOGE("[PRVMGR_ERR_NO_EXIST_PRIVILEGE] There are no privilege %s in DB", privilege_name); - *error_privilege_name = (char*)calloc(strlen(privilege_name) + 1, sizeof(char)); - TryReturn(*error_privilege_name != NULL, PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] Memory allocation failed."); - memcpy(*error_privilege_name, privilege_name, strlen(privilege_name)); - - return PRVMGR_ERR_NO_EXIST_PRIVILEGE; - } - else if(ret == PRVMGR_ERR_NONE) - { - if(visibility == PRVMGR_PACKAGE_VISIBILITY_PARTNER){ - if(privilege_level_id == PRIVILEGE_DB_MANAGER_PRIVILEGE_LEVEL_PLATFORM) - { - LOGE("[PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL] Visibility and Privilege level are mismatched"); - LOGE("[PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL] Visibility : partner, Privilege Level : %d", privilege_level_id); - *error_privilege_name = (char*)calloc(strlen(privilege_name) + 1, sizeof(char)); - TryReturn(*error_privilege_name != NULL, PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] Memory allocation failed."); - memcpy(*error_privilege_name, privilege_name, strlen(privilege_name)); - - return PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL; - } - } - else if(visibility == PRVMGR_PACKAGE_VISIBILITY_PUBLIC){ - if(privilege_level_id == PRIVILEGE_DB_MANAGER_PRIVILEGE_LEVEL_PARTNER || privilege_level_id == PRIVILEGE_DB_MANAGER_PRIVILEGE_LEVEL_PLATFORM) - { - LOGE("[PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL] Visibility and Privilege level are mismatched"); - LOGE("[PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL] Visibility : public, Privilege Level : %d", privilege_level_id); - *error_privilege_name = (char*)calloc(strlen(privilege_name) + 1, sizeof(char)); - TryReturn(*error_privilege_name != NULL, PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] Memory allocation failed."); - memcpy(*error_privilege_name, privilege_name, strlen(privilege_name)); - - return PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL; - } - } - } - else - { - return ret; - } - } - - return PRVMGR_ERR_NONE; -} - diff --git a/packaging/privilege-checker.manifest b/packaging/privilege-checker.manifest index 9647171..c00c25b 100644 --- a/packaging/privilege-checker.manifest +++ b/packaging/privilege-checker.manifest @@ -1,7 +1,4 @@ - - - diff --git a/packaging/privilege-checker.spec b/packaging/privilege-checker.spec index a8ad6d2..87dd6af 100644 --- a/packaging/privilege-checker.spec +++ b/packaging/privilege-checker.spec @@ -8,7 +8,6 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(sqlite3) -BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(glib-2.0) %description @@ -28,14 +27,12 @@ Group: TO_BE/FILLED_IN License: TO BE FILLED IN BuildRequires: cmake BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(capi-base-common) BuildRequires: gettext-tools BuildRequires: pkgconfig(pkgmgr-info) -BuildRequires: pkgconfig(capi-appfw-package-manager) BuildRequires: pkgconfig(glib-2.0) %description -n capi-security-privilege-manager -The Privilege Manager API provides functions to get information about privilege information of installed packages. +The Privilege Manager API provides functions to verify privilege information of packages to be installed. %package -n capi-security-privilege-manager-devel Summary: Privilege Manager API (Development) @@ -43,7 +40,7 @@ Group: TO_BE/FILLED_IN Requires: capi-security-privilege-manager %description -n capi-security-privilege-manager-devel -The Privilege Manager API provides functions to get information about privilege information of installed packages.(DEV) +The Privilege Manager API provides functions to verify privilege information of packages to be installed.(DEV) #%package -n tc-privilege-checker #Summary: tc-privilege-checker @@ -63,8 +60,6 @@ The Privilege Manager API provides functions to get information about privilege __PROFILE_TYPE="WEARABLE" %else if "%{?profile}" == "mobile" __PROFILE_TYPE="MOBILE" -%else - __PROFILE_TYPE="COMMON" %endif export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE" @@ -123,7 +118,6 @@ sqlite3 /%{buildroot}%{_datadir}/privilege-manager/.wrt_privilege_info.db "selec #%files -n tc-privilege-checker #%{_bindir}/tc-privilege-db-manager #%{_bindir}/tc-privilege-manager -#%{_bindir}/tc-privilege-checker #%{_bindir}/tc-privilege-hash #%{_bindir}/tc-privilege-info -- 2.7.4