From 398019b40c35f499212b8d2a13ed6a0c2701858b Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Thu, 27 Jun 2019 17:14:21 +0900 Subject: [PATCH 01/16] Make gcov package when --define 'gcov ON' is given Change-Id: Id552076230ef6415ac02d1f760dca4ae6ddd6c61 Signed-off-by: Yunjin Lee --- packaging/privilege-info.spec | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index faf710b..eefdaa9 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -18,6 +18,9 @@ BuildRequires: pkgconfig(cynara-session) BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(capi-system-info) +%if 0%{?gcov:1} +BuildRequires: lcov +%endif Requires: tizen-locale %description @@ -39,6 +42,15 @@ Requires: %{name} = %{version}-%{release} %description -n tc-privilege-info Privilege Info API Internal Test +%if 0%{?gcov:1} +%package gcov +Summary: Privilege Info(gcov) +Group: Security/Testing +%description gcov +New Privilege Info gcov objects +%endif + + %prep %setup -q @@ -48,13 +60,21 @@ export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE" export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE" export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE" +%if 0%{?gcov:1} +export CFLAGS+=" -fprofile-arcs -ftest-coverage" +export CXXFLAGS+=" -fprofile-arcs -ftest-coverage" +export FFLAGS+=" -fprofile-arcs -ftest-coverage" +export LDFLAGS+=" -lgcov" +%endif + echo cmake . -DPREFIX=%{_prefix} \ -DLIBDIR=%{_libdir} \ -DINCLUDEDIR=%{_includedir} \ -DCMAKE_BUILD_TYPE=%{build_type} \ -DVERSION=%{version} \ -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES \ - -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP + -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP \ + -DBUILD_GCOV={?gcov:1}%{!?gcov:0} cmake . -DPREFIX=%{_prefix} \ -DLIBDIR=%{_libdir} \ @@ -62,15 +82,26 @@ cmake . -DPREFIX=%{_prefix} \ -DCMAKE_BUILD_TYPE=%{build_type} \ -DVERSION=%{version} \ -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES \ - -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP + -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP \ + -DBUILD_GCOV={?gcov:1}%{!?gcov:0} make %{?jobs:-j%jobs} +%if 0%{?gcov:1} +mkdir -p gcov-obj +find . \( -name '*.gcno' ! -name 'tc_*' \) -exec cp '{}' gcov-obj ';' +%endif + %install rm -rf %{buildroot} %make_install +%if 0%{?gcov:1} +mkdir -p %{buildroot}%{_datadir}/gcov/obj +install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj +%endif + %post -n privilege-info -p /sbin/ldconfig %postun -n privilege-info -p /sbin/ldconfig @@ -93,6 +124,10 @@ cyad -s -k MANIFESTS -c User::Pkg::org.tizen.test-privilege-info -u '*' -p http: %{TZ_SYS_RO_PACKAGES}/org.tizen.test-privilege-info.xml %{_bindir}/tc-privilege-info +%if 0%{?gcov:1} +%files gcov +%{_datadir}/gcov/obj/* +%endif %clean rm -rf %{buildroot} -- 2.7.4 From b8071545bedde6d535c10a3dc60d443aae367520 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Fri, 13 Dec 2019 10:55:27 +0900 Subject: [PATCH 02/16] Update doc - Modify developer.tizen.org to docs.tizen.org Change-Id: I271774bc44d6262a9fe38b1e41dcffa23c3587bc Signed-off-by: Yunjin Lee --- doc/privilege-info_doc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/privilege-info_doc.h b/doc/privilege-info_doc.h index 816e384..d4c8d9e 100755 --- a/doc/privilege-info_doc.h +++ b/doc/privilege-info_doc.h @@ -36,7 +36,7 @@ * It is recommended to design feature related codes in your application for reliability.\n * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\n * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n - * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature Element. */ -- 2.7.4 From fab6061851a664a85d0ee7ec89bcad3e1da3eb07 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Fri, 13 Dec 2019 11:10:02 +0900 Subject: [PATCH 03/16] Update docs for wrong url Change-Id: If2918afb3c1a490578bdf4841a3d5ec2c65e183d Signed-off-by: Yunjin Lee --- doc/privilege-info_doc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/privilege-info_doc.h b/doc/privilege-info_doc.h index d4c8d9e..b8119dd 100755 --- a/doc/privilege-info_doc.h +++ b/doc/privilege-info_doc.h @@ -36,7 +36,7 @@ * It is recommended to design feature related codes in your application for reliability.\n * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\n * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n - * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature Element. */ -- 2.7.4 From 5e5ff434f2e452acddf37438dc8e7491103f868f Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Thu, 19 Dec 2019 15:11:58 +0900 Subject: [PATCH 04/16] Update API reference Change-Id: I940705e80207ca8f71b9cffda68ad97fb760bf67 Signed-off-by: Yunjin Lee --- src/include/privilege_information.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/privilege_information.h b/src/include/privilege_information.h index d85e6d8..fa525da 100755 --- a/src/include/privilege_information.h +++ b/src/include/privilege_information.h @@ -71,7 +71,7 @@ int privilege_info_get_display_name(const char *api_version, const char *privile * @brief Gets the display name of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). - * @remarks package_type must be one of followings: PRVINFO_PACKAGE_TYPE_NATIVE, PRVINFO_PACKAGE_TYPE_WEB + * @remarks package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege @@ -107,7 +107,7 @@ int privilege_info_get_description(const char *api_version, const char *privileg * @brief Gets the description of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). - * @remarks package_type must be one of followings: PRVINFO_PACKAGE_TYPE_NATIVE, PRVINFO_PACKAGE_TYPE_WEB + * @remarks package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege -- 2.7.4 From fe7a03a822a6a06591465553fa3690ad83bc5d91 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Wed, 8 Jan 2020 18:05:00 +0900 Subject: [PATCH 05/16] Fix build errors from toolchain upgrade (gcc6-> gcc9) Change-Id: I7d51eff01901cf3e2d0ec43b933bf2c4f8dae59e Signed-off-by: Yunjin Lee --- src/privilege_information.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/privilege_information.c b/src/privilege_information.c index 995c29c..6a283d9 100755 --- a/src/privilege_information.c +++ b/src/privilege_information.c @@ -352,7 +352,7 @@ int privilege_info_get_privilege_info_list(const char* locale, GList* privilege_ char *orig_locale = NULL; char *result = (char *)setlocale(LC_ALL, NULL); if (!result) { - LOGE("failed to get original locale. orig_locale = %s", orig_locale); + LOGE("failed to get original locale. errno = %d", errno); } else { orig_locale = strdup(result); TryReturn(orig_locale != NULL, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] strdup of orig_locale failed"); @@ -362,7 +362,7 @@ int privilege_info_get_privilege_info_list(const char* locale, GList* privilege_ if (result) { LOGI("succeeded in setting locale = %s", result); } else { - LOGE("failed to set locale. result = %s", result); + LOGE("failed to set locale. set locale to en_US.UTF8. errno = %d", errno); setlocale(LC_ALL, "en_US.UTF8"); consumer_return_code = PRIVILEGE_CONSUMER_RETURN_CODE_UNKNOWN_LOCALE_CODE; -- 2.7.4 From ef624e0602b992c784da21806122263a9adc498f Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Wed, 29 Jan 2020 15:34:29 +0900 Subject: [PATCH 06/16] Add null check before strdup() Change-Id: Ia67e28c0efeda6987d6e8591574c1cc34060b454 Signed-off-by: Yunjin Lee --- packaging/privilege-info.spec | 2 +- src/privilege_information.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index eefdaa9..b4fc806 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -1,6 +1,6 @@ Name: privilege-info Summary: Privilege Information -Version: 0.0.3 +Version: 0.0.4 Release: 1 Group: Security/API License: Apache-2.0 diff --git a/src/privilege_information.c b/src/privilege_information.c index 6a283d9..aa1cffa 100755 --- a/src/privilege_information.c +++ b/src/privilege_information.c @@ -169,6 +169,7 @@ int privilege_info_get_display_name(const char *api_version, const char *privile temp = token; token = strtok_r(NULL, "/", &save); } + TryReturn(temp != NULL, free(tempPrivilege), PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid privilege <%s>", privilege); *display_name = strdup(temp); TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); free(tempPrivilege); @@ -231,6 +232,7 @@ int privilege_info_get_display_name_by_pkgtype(const char *package_type, const c temp = token; token = strtok_r(NULL, "/", &save); } + TryReturn(temp != NULL, free(tempPrivilege), PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid privilege <%s>", privilege); *display_name = strdup(temp); TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); free(tempPrivilege); -- 2.7.4 From 53351337cfb127e2e536471e8fb1d6ed53a8fcc9 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Mon, 13 Apr 2020 17:13:55 +0900 Subject: [PATCH 07/16] Return error if there's no matched privilege - Return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE when the given privilege is non-existence privilege Change-Id: I05631362a1add37b9d227b019df08182cb91df8f Signed-off-by: Yunjin Lee --- doc/privilege-info_doc.h | 4 +- packaging/privilege-info.spec | 2 +- src/include/privilege_information.h | 17 ++++- src/privilege_information.c | 146 +++++++++++------------------------- test/tc_privilege_info.c | 54 +++++-------- 5 files changed, 76 insertions(+), 147 deletions(-) diff --git a/doc/privilege-info_doc.h b/doc/privilege-info_doc.h index b8119dd..d47d785 100755 --- a/doc/privilege-info_doc.h +++ b/doc/privilege-info_doc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014-2020 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. @@ -28,7 +28,7 @@ * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_OVERVIEW Overview * A library for reading privilege information of the given privilege and API issue version. * It provides the display name or description of privileges. - * If there's no matching privilege then it shows last token of given privilege or description string for undefined privileges. + * If there's no matching privilege then it returns error. * * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_FEATURE Related Features * This API is related with the following features:\n diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index b4fc806..6201068 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -107,7 +107,7 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %post -n tc-privilege-info tpk-backend -y org.tizen.test-privilege-info --preload -cyad -s -k MANIFESTS -c User::Pkg::org.tizen.test-privilege-info -u '*' -p http://tizen.org/privilege/contact.read -t DENY +cyad -s -k MANIFESTS_GLOBAL -c User::Pkg::org.tizen.test-privilege-info -u '*' -p http://tizen.org/privilege/contact.read -t DENY %files -n privilege-info %{_libdir}/libprivilege-info.so* diff --git a/src/include/privilege_information.h b/src/include/privilege_information.h index fa525da..29e83f2 100755 --- a/src/include/privilege_information.h +++ b/src/include/privilege_information.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014-2020 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. @@ -46,7 +46,8 @@ typedef enum { PRVINFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */ PRVINFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ PRVINFO_ERROR_INTERNAL_ERROR = TIZEN_ERROR_UNKNOWN, /**< Unknown error */ - PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not supported (Since 5.0) */ + PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported (Since 5.0) */ + PRVINFO_ERROR_NO_MATCHING_PRIVILEGE = TIZEN_ERROR_PRIVILEGE_INFORMATION | 0x01 /**< No matched privilege (Since 6.0) */ } privilege_info_error_e; @@ -54,12 +55,14 @@ typedef enum { * @brief Gets the display name of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). + * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege * @param[out] display_name The display name of the privilege * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful + * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -71,7 +74,8 @@ int privilege_info_get_display_name(const char *api_version, const char *privile * @brief Gets the display name of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). - * @remarks package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" + * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" + * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege @@ -79,6 +83,7 @@ int privilege_info_get_display_name(const char *api_version, const char *privile * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful + * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -90,12 +95,14 @@ int privilege_info_get_display_name_by_pkgtype(const char *package_type, const c * @brief Gets the description of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). + * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege * @param[out] description The description of the privilege * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful + * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -107,7 +114,8 @@ int privilege_info_get_description(const char *api_version, const char *privileg * @brief Gets the description of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). - * @remarks package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" + * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" + * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege @@ -115,6 +123,7 @@ int privilege_info_get_description(const char *api_version, const char *privileg * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful + * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error diff --git a/src/privilege_information.c b/src/privilege_information.c index aa1cffa..1c7687b 100755 --- a/src/privilege_information.c +++ b/src/privilege_information.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014-2020 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. @@ -65,15 +65,8 @@ #define PI_API __attribute__((visibility("default"))) #endif -typedef enum { - PRVINFO_ERROR_NO_MATCHING_PRIVILEGE = TIZEN_ERROR_PRIVILEGE_INFORMATION | 0x01 -} privilege_info_internal_error_e; - int privilege_info_get_string_id(const char *package_type_string, int display, const char *api_version, const char *privilege, char **string_id) { - TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); - TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - char* temp = NULL; int ret; privilege_manager_package_type_e package_type; @@ -87,10 +80,10 @@ int privilege_info_get_string_id(const char *package_type_string, int display, c else ret = privilege_db_manager_get_privilege_description(PRVMGR_PACKAGE_TYPE_CORE, privilege, api_version, &temp); - if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE) - goto err_none; + if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && temp != NULL) + goto string_id_found; else if (ret != PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) - goto err_internal_error; + goto err; /* Check WEB */ @@ -107,35 +100,31 @@ get_string_id_with_package_type: else ret = privilege_db_manager_get_privilege_description(package_type, privilege, api_version, &temp); - - if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE) - goto err_none; - else if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) - goto err_no_matching_privilege; + if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && temp != NULL) + goto string_id_found; else - goto err_internal_error; + goto err; -err_none: +string_id_found: *string_id = strdup(temp); TryReturn(*string_id != NULL, free(temp), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed."); free(temp); return PRVINFO_ERROR_NONE; -err_no_matching_privilege: +err: *string_id = NULL; - free(temp); - return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE; - -err_internal_error: - free(temp); - return PRVINFO_ERROR_INTERNAL_ERROR; + if (temp != NULL) + free(temp); + if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) + return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE; + else + return PRVINFO_ERROR_INTERNAL_ERROR; } int privilege_info_get_string_by_string_id(const char *string_id, char **string) { - char *temp = NULL; TryReturn(string_id != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] string_id is NULL"); - + char* temp = NULL; temp = dgettext("privilege", string_id); *string = strdup(temp); @@ -147,129 +136,80 @@ int privilege_info_get_string_by_string_id(const char *string_id, char **string) PI_API int privilege_info_get_display_name(const char *api_version, const char *privilege, char **display_name) { - int ret = 0; - char* string_id = NULL; - TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - ret = privilege_info_get_string_id(NULL, 1, api_version, privilege, &string_id); - - if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { - char* tempPrivilege = NULL; - char* token = NULL; - char* temp = NULL; - char* save = NULL; + int ret = 0; + char* string_id = NULL; - tempPrivilege = strdup(privilege); - TryReturn(tempPrivilege != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] tempPrivilege's strdup is failed."); + ret = privilege_info_get_string_id(NULL, 1, api_version, privilege, &string_id); - token = strtok_r(tempPrivilege, "/", &save); - while (token) { - temp = token; - token = strtok_r(NULL, "/", &save); - } - TryReturn(temp != NULL, free(tempPrivilege), PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid privilege <%s>", privilege); - *display_name = strdup(temp); - TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - free(tempPrivilege); - } else if (ret == PRVINFO_ERROR_NONE) { + if (ret == PRVINFO_ERROR_NONE) ret = privilege_info_get_string_by_string_id(string_id, display_name); + if (string_id != NULL) free(string_id); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else { - return PRVINFO_ERROR_INTERNAL_ERROR; - } - return PRVINFO_ERROR_NONE; + return ret; } PI_API int privilege_info_get_description(const char *api_version, const char *privilege, char **description) { - int ret = 0; - char* string_id = NULL; - TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + int ret = 0; + char* string_id = NULL; + ret = privilege_info_get_string_id(NULL, 0, api_version, privilege, &string_id); - if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { - ret = privilege_info_get_string_by_string_id("IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED", description); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else if (ret == PRVINFO_ERROR_NONE) { + if (ret == PRVINFO_ERROR_NONE) ret = privilege_info_get_string_by_string_id(string_id, description); + if (string_id != NULL) free(string_id); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else { - return PRVINFO_ERROR_INTERNAL_ERROR; - } - return PRVINFO_ERROR_NONE; + + return ret; } PI_API int privilege_info_get_display_name_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **display_name) { - int ret = 0; - char* string_id = NULL; - TryReturn(package_type != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL"); TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + int ret = 0; + char* string_id = NULL; + ret = privilege_info_get_string_id(package_type, 1, api_version, privilege, &string_id); TryReturn(ret != PRVINFO_ERROR_INVALID_PARAMETER, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid package_type : %s", package_type); - if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { - char* tempPrivilege = NULL; - char* token = NULL; - char* temp = NULL; - char* save = NULL; - tempPrivilege = strdup(privilege); - TryReturn(tempPrivilege != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] tempPrivilege's strdup is failed."); - token = strtok_r(tempPrivilege, "/", &save); - while (token) { - temp = token; - token = strtok_r(NULL, "/", &save); - } - TryReturn(temp != NULL, free(tempPrivilege), PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid privilege <%s>", privilege); - *display_name = strdup(temp); - TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - free(tempPrivilege); - } else if (ret == PRVINFO_ERROR_NONE) { + if (ret == PRVINFO_ERROR_NONE) ret = privilege_info_get_string_by_string_id(string_id, display_name); + if (string_id != NULL) free(string_id); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else { - return PRVINFO_ERROR_INTERNAL_ERROR; - } - return PRVINFO_ERROR_NONE; + + return ret; } PI_API int privilege_info_get_description_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **description) { - int ret = 0; - char* string_id = NULL; - TryReturn(package_type != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL"); TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + int ret = 0; + char* string_id = NULL; + ret = privilege_info_get_string_id(package_type, 0, api_version, privilege, &string_id); TryReturn(ret != PRVINFO_ERROR_INVALID_PARAMETER, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid package_type : %s", package_type); - if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { - ret = privilege_info_get_string_by_string_id("IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED", description); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else if (ret == PRVINFO_ERROR_NONE) { + if (ret == PRVINFO_ERROR_NONE) ret = privilege_info_get_string_by_string_id(string_id, description); + if (string_id != NULL) free(string_id); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else { - return PRVINFO_ERROR_INTERNAL_ERROR; - } - return PRVINFO_ERROR_NONE; + + return ret; } PI_API diff --git a/test/tc_privilege_info.c b/test/tc_privilege_info.c index ecc8b9f..c4f992b 100755 --- a/test/tc_privilege_info.c +++ b/test/tc_privilege_info.c @@ -43,13 +43,15 @@ static const char* __get_result_string(privilege_info_error_e ret) return "PRVINFO_ERROR_INTERNAL_ERROR"; else if (ret == PRVINFO_ERROR_NOT_SUPPORTED) return "PRVINFO_ERROR_NOT_SUPPORTED"; + else if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) + return "PRVINFO_ERROR_NO_MATCHING_PRIVILEGE"; return "PRVINFO_ERROR_NO_MATCHED_ERROR_MESSAGE"; } static void __check_get_privilege_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* display_name) { - printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -69,7 +71,7 @@ static void __check_get_privilege_display_name_result(privilege_info_error_e exp } else { printf("display_name = %s\n", display_name); } - } else { + } else if (result == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { if (display_name != NULL) { printf("display_name = %s\n", display_name); printf("display_name must be NULL\n"); @@ -90,7 +92,7 @@ static void __check_get_privilege_display_name_result(privilege_info_error_e exp static void __check_get_privilege_description_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* description) { - printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -110,7 +112,7 @@ static void __check_get_privilege_description_result(privilege_info_error_e expe } else { printf("description = %s\n", description); } - } else { + } else if (result == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { if (description != NULL) { printf("description = %s\n", description); printf("description must be NULL\n"); @@ -131,7 +133,7 @@ static void __check_get_privilege_description_result(privilege_info_error_e expe static void __check_get_privacy_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* privacy_display) { - printf("expectd result %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -159,14 +161,12 @@ static void __test_privilege_info_get_display_name() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/window.priority.set", &display_name); __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -178,19 +178,17 @@ static void __test_privilege_info_get_display_name() printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : NULL\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -200,6 +198,7 @@ static void __test_privilege_info_get_display_name() free(display_name); } + static void __test_privilege_info_get_display_name_by_pkgtype() { int ret; @@ -209,7 +208,6 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &display_name); __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); @@ -217,7 +215,6 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_WEB\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -230,32 +227,29 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -274,14 +268,12 @@ static void __test_privilege_info_get_description() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/window.priority.set", &description); __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -293,19 +285,17 @@ static void __test_privilege_info_get_description() printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -324,14 +314,12 @@ static void __test_privilege_info_get_description_by_pkgtype() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &description); __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -344,31 +332,28 @@ static void __test_privilege_info_get_description_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); printf("-----------------------------------------------------------\n"); printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : NULL\n"); - printf("expected result : PRVINFO_ERROR_INVALID_PARAMETER\n"); if (description != NULL) { free(description); description = NULL; @@ -428,15 +413,15 @@ static void __test_privilege_info_get_privacy_display_name() static void __check_privilege_info_get_privilege_info(privilege_info_error_e expected_result, privilege_info_error_e result, GList* privilege_info_list, int return_result) { - printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { __change_color_to_yellow(); - printf("not mached\n"); + printf("not matched\n"); __change_color_to_origin(); } else { __change_color_to_green(); - printf("mached\n"); + printf("matched\n"); __change_color_to_origin(); } @@ -468,7 +453,6 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/content.read\n"); printf("privilege name : http://tizen.org/privilege/filesystem.read\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/content.read"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/filesystem.read"); @@ -486,7 +470,6 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/systemsettings.admin\n"); printf("privilege name : http://tizen.org/privilege/bookmark.admin\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/systemsettings.admin"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/bookmark.admin"); @@ -504,7 +487,6 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/alarm.xxxx\n"); printf("privilege name : http://tizen.org/privilege/account.xxx\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/alarm.xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/account.xxx"); @@ -522,7 +504,6 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/content.read\n"); printf("privilege name : http://tizen.org/privilege/filesystem.read\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/content.read"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/filesystem.read"); @@ -540,7 +521,6 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/xxxx\n"); printf("privilege name : http://tizen.org/privilege/alarm.xxxx\n"); printf("privilege name : http://tizen.org/privilege/account.xxx\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/alarm.xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/account.xxx"); -- 2.7.4 From 6043db19a5f326dbf95eff78a112d0bffcc7a728 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Mon, 11 May 2020 17:14:23 +0900 Subject: [PATCH 08/16] Release version 0.0.5 - Return error if there's no matched privilege - Added changes file Change-Id: I38ef55f470a792fb18364b0486b24fb2621336b3 Signed-off-by: Yunjin Lee --- packaging/privilege-info.changes | 46 ++++++++++++++++++++++++++++++++++++++++ packaging/privilege-info.spec | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 packaging/privilege-info.changes diff --git a/packaging/privilege-info.changes b/packaging/privilege-info.changes new file mode 100644 index 0000000..b82b1e4 --- /dev/null +++ b/packaging/privilege-info.changes @@ -0,0 +1,46 @@ +Release version 0.0.5 +- Return error if there's no matched privilege + +Release version 0.0.4 +- Add null check before strdup() + +Release version 0.0.3 +- Fix build errors from toolchain upgrade (gcc6-> gcc9) +- Update API reference +- Update docs for wrong url +- Update doc +- Make gcov package when --define 'gcov ON' is given +- Add tizen-locale to requires +- Fix memory issue +- Add new API for getting privilege info as list + +Release version 0.0.2 +- Add privacy feature and deprecate redundant API + +Release version 0.0.1 +- Fix resource leak +- Adjust enum changes +- Merge "Fix not to launch privacy popup when getting privacy status" into tizen +- Fix not to launch privacy popup when getting privacy status +- Fix to use %license macro +- Update API reference +- Fix memory leak +- Update API documentation +- Merge "Remove rpmlint error and warning" into tizen +- Remove rpmlint error and warning +- Change test app process label on cyad command +- Add privacy related APIs +- Revise internal apis : Remove useless things +- Fix to handle invalid package type input parameter as an error +- Modify definition in header not to conflict +- Apply Tizen coding rule to headers +- Fix typo and add missing manifest to spec +- Apply "-Werror -Wall -Wextra" option +- Svace: Fix NO_RETURN_VALUE +- Revise dependency on privilege-manager +- Apply tizen coding rule +- Fix doxygen and apply secure coding +- Declare missing buildrequire to glib-2.0 +- Fix build macro for 64 bit +- Sync to latest code +- Initial empty repository diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index 6201068..f4f8973 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -1,6 +1,6 @@ Name: privilege-info Summary: Privilege Information -Version: 0.0.4 +Version: 0.0.5 Release: 1 Group: Security/API License: Apache-2.0 -- 2.7.4 From e2782e16e5fad479c096e006b2adc6259820715c Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Tue, 12 May 2020 09:47:36 +0000 Subject: [PATCH 09/16] Revert "Return error if there's no matched privilege" This reverts commit 53351337cfb127e2e536471e8fb1d6ed53a8fcc9. Change-Id: I35f8292f68325a9f2084bc2aaae11b2157c82943 --- doc/privilege-info_doc.h | 4 +- packaging/privilege-info.spec | 2 +- src/include/privilege_information.h | 17 +---- src/privilege_information.c | 146 +++++++++++++++++++++++++----------- test/tc_privilege_info.c | 54 ++++++++----- 5 files changed, 147 insertions(+), 76 deletions(-) diff --git a/doc/privilege-info_doc.h b/doc/privilege-info_doc.h index d47d785..b8119dd 100755 --- a/doc/privilege-info_doc.h +++ b/doc/privilege-info_doc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014 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. @@ -28,7 +28,7 @@ * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_OVERVIEW Overview * A library for reading privilege information of the given privilege and API issue version. * It provides the display name or description of privileges. - * If there's no matching privilege then it returns error. + * If there's no matching privilege then it shows last token of given privilege or description string for undefined privileges. * * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_FEATURE Related Features * This API is related with the following features:\n diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index 6201068..b4fc806 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -107,7 +107,7 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %post -n tc-privilege-info tpk-backend -y org.tizen.test-privilege-info --preload -cyad -s -k MANIFESTS_GLOBAL -c User::Pkg::org.tizen.test-privilege-info -u '*' -p http://tizen.org/privilege/contact.read -t DENY +cyad -s -k MANIFESTS -c User::Pkg::org.tizen.test-privilege-info -u '*' -p http://tizen.org/privilege/contact.read -t DENY %files -n privilege-info %{_libdir}/libprivilege-info.so* diff --git a/src/include/privilege_information.h b/src/include/privilege_information.h index 29e83f2..fa525da 100755 --- a/src/include/privilege_information.h +++ b/src/include/privilege_information.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014-2018 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. @@ -46,8 +46,7 @@ typedef enum { PRVINFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */ PRVINFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ PRVINFO_ERROR_INTERNAL_ERROR = TIZEN_ERROR_UNKNOWN, /**< Unknown error */ - PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported (Since 5.0) */ - PRVINFO_ERROR_NO_MATCHING_PRIVILEGE = TIZEN_ERROR_PRIVILEGE_INFORMATION | 0x01 /**< No matched privilege (Since 6.0) */ + PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not supported (Since 5.0) */ } privilege_info_error_e; @@ -55,14 +54,12 @@ typedef enum { * @brief Gets the display name of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege * @param[out] display_name The display name of the privilege * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful - * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -74,8 +71,7 @@ int privilege_info_get_display_name(const char *api_version, const char *privile * @brief Gets the display name of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). - * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. + * @remarks package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege @@ -83,7 +79,6 @@ int privilege_info_get_display_name(const char *api_version, const char *privile * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful - * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -95,14 +90,12 @@ int privilege_info_get_display_name_by_pkgtype(const char *package_type, const c * @brief Gets the description of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege * @param[out] description The description of the privilege * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful - * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -114,8 +107,7 @@ int privilege_info_get_description(const char *api_version, const char *privileg * @brief Gets the description of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). - * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. + * @remarks package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege @@ -123,7 +115,6 @@ int privilege_info_get_description(const char *api_version, const char *privileg * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful - * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error diff --git a/src/privilege_information.c b/src/privilege_information.c index 1c7687b..aa1cffa 100755 --- a/src/privilege_information.c +++ b/src/privilege_information.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014-2018 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. @@ -65,8 +65,15 @@ #define PI_API __attribute__((visibility("default"))) #endif +typedef enum { + PRVINFO_ERROR_NO_MATCHING_PRIVILEGE = TIZEN_ERROR_PRIVILEGE_INFORMATION | 0x01 +} privilege_info_internal_error_e; + int privilege_info_get_string_id(const char *package_type_string, int display, const char *api_version, const char *privilege, char **string_id) { + TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); + TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + char* temp = NULL; int ret; privilege_manager_package_type_e package_type; @@ -80,10 +87,10 @@ int privilege_info_get_string_id(const char *package_type_string, int display, c else ret = privilege_db_manager_get_privilege_description(PRVMGR_PACKAGE_TYPE_CORE, privilege, api_version, &temp); - if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && temp != NULL) - goto string_id_found; + if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE) + goto err_none; else if (ret != PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) - goto err; + goto err_internal_error; /* Check WEB */ @@ -100,31 +107,35 @@ get_string_id_with_package_type: else ret = privilege_db_manager_get_privilege_description(package_type, privilege, api_version, &temp); - if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && temp != NULL) - goto string_id_found; + + if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE) + goto err_none; + else if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) + goto err_no_matching_privilege; else - goto err; + goto err_internal_error; -string_id_found: +err_none: *string_id = strdup(temp); TryReturn(*string_id != NULL, free(temp), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed."); free(temp); return PRVINFO_ERROR_NONE; -err: +err_no_matching_privilege: *string_id = NULL; - if (temp != NULL) - free(temp); - if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) - return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE; - else - return PRVINFO_ERROR_INTERNAL_ERROR; + free(temp); + return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE; + +err_internal_error: + free(temp); + return PRVINFO_ERROR_INTERNAL_ERROR; } int privilege_info_get_string_by_string_id(const char *string_id, char **string) { + char *temp = NULL; TryReturn(string_id != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] string_id is NULL"); - char* temp = NULL; + temp = dgettext("privilege", string_id); *string = strdup(temp); @@ -136,80 +147,129 @@ int privilege_info_get_string_by_string_id(const char *string_id, char **string) PI_API int privilege_info_get_display_name(const char *api_version, const char *privilege, char **display_name) { - TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); - TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; char* string_id = NULL; + TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); + TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + ret = privilege_info_get_string_id(NULL, 1, api_version, privilege, &string_id); - if (ret == PRVINFO_ERROR_NONE) + if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + char* tempPrivilege = NULL; + char* token = NULL; + char* temp = NULL; + char* save = NULL; + + tempPrivilege = strdup(privilege); + TryReturn(tempPrivilege != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] tempPrivilege's strdup is failed."); + + token = strtok_r(tempPrivilege, "/", &save); + while (token) { + temp = token; + token = strtok_r(NULL, "/", &save); + } + TryReturn(temp != NULL, free(tempPrivilege), PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid privilege <%s>", privilege); + *display_name = strdup(temp); + TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + free(tempPrivilege); + } else if (ret == PRVINFO_ERROR_NONE) { ret = privilege_info_get_string_by_string_id(string_id, display_name); - if (string_id != NULL) free(string_id); - return ret; + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else { + return PRVINFO_ERROR_INTERNAL_ERROR; + } + return PRVINFO_ERROR_NONE; } PI_API int privilege_info_get_description(const char *api_version, const char *privilege, char **description) { - TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); - TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; char* string_id = NULL; + TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); + TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + ret = privilege_info_get_string_id(NULL, 0, api_version, privilege, &string_id); - if (ret == PRVINFO_ERROR_NONE) + if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + ret = privilege_info_get_string_by_string_id("IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED", description); + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else if (ret == PRVINFO_ERROR_NONE) { ret = privilege_info_get_string_by_string_id(string_id, description); - if (string_id != NULL) free(string_id); - - return ret; + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else { + return PRVINFO_ERROR_INTERNAL_ERROR; + } + return PRVINFO_ERROR_NONE; } PI_API int privilege_info_get_display_name_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **display_name) { + int ret = 0; + char* string_id = NULL; + TryReturn(package_type != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL"); TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; - char* string_id = NULL; - ret = privilege_info_get_string_id(package_type, 1, api_version, privilege, &string_id); TryReturn(ret != PRVINFO_ERROR_INVALID_PARAMETER, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid package_type : %s", package_type); - if (ret == PRVINFO_ERROR_NONE) + if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + char* tempPrivilege = NULL; + char* token = NULL; + char* temp = NULL; + char* save = NULL; + tempPrivilege = strdup(privilege); + TryReturn(tempPrivilege != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] tempPrivilege's strdup is failed."); + token = strtok_r(tempPrivilege, "/", &save); + while (token) { + temp = token; + token = strtok_r(NULL, "/", &save); + } + TryReturn(temp != NULL, free(tempPrivilege), PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid privilege <%s>", privilege); + *display_name = strdup(temp); + TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + free(tempPrivilege); + } else if (ret == PRVINFO_ERROR_NONE) { ret = privilege_info_get_string_by_string_id(string_id, display_name); - if (string_id != NULL) free(string_id); - - return ret; + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else { + return PRVINFO_ERROR_INTERNAL_ERROR; + } + return PRVINFO_ERROR_NONE; } PI_API int privilege_info_get_description_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **description) { + int ret = 0; + char* string_id = NULL; + TryReturn(package_type != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL"); TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; - char* string_id = NULL; - ret = privilege_info_get_string_id(package_type, 0, api_version, privilege, &string_id); TryReturn(ret != PRVINFO_ERROR_INVALID_PARAMETER, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid package_type : %s", package_type); - if (ret == PRVINFO_ERROR_NONE) + if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + ret = privilege_info_get_string_by_string_id("IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED", description); + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else if (ret == PRVINFO_ERROR_NONE) { ret = privilege_info_get_string_by_string_id(string_id, description); - if (string_id != NULL) free(string_id); - - return ret; + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else { + return PRVINFO_ERROR_INTERNAL_ERROR; + } + return PRVINFO_ERROR_NONE; } PI_API diff --git a/test/tc_privilege_info.c b/test/tc_privilege_info.c index c4f992b..ecc8b9f 100755 --- a/test/tc_privilege_info.c +++ b/test/tc_privilege_info.c @@ -43,15 +43,13 @@ static const char* __get_result_string(privilege_info_error_e ret) return "PRVINFO_ERROR_INTERNAL_ERROR"; else if (ret == PRVINFO_ERROR_NOT_SUPPORTED) return "PRVINFO_ERROR_NOT_SUPPORTED"; - else if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) - return "PRVINFO_ERROR_NO_MATCHING_PRIVILEGE"; return "PRVINFO_ERROR_NO_MATCHED_ERROR_MESSAGE"; } static void __check_get_privilege_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* display_name) { - printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -71,7 +69,7 @@ static void __check_get_privilege_display_name_result(privilege_info_error_e exp } else { printf("display_name = %s\n", display_name); } - } else if (result == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + } else { if (display_name != NULL) { printf("display_name = %s\n", display_name); printf("display_name must be NULL\n"); @@ -92,7 +90,7 @@ static void __check_get_privilege_display_name_result(privilege_info_error_e exp static void __check_get_privilege_description_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* description) { - printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -112,7 +110,7 @@ static void __check_get_privilege_description_result(privilege_info_error_e expe } else { printf("description = %s\n", description); } - } else if (result == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + } else { if (description != NULL) { printf("description = %s\n", description); printf("description must be NULL\n"); @@ -133,7 +131,7 @@ static void __check_get_privilege_description_result(privilege_info_error_e expe static void __check_get_privacy_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* privacy_display) { - printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expectd result %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -161,12 +159,14 @@ static void __test_privilege_info_get_display_name() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/window.priority.set", &display_name); __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -178,17 +178,19 @@ static void __test_privilege_info_get_display_name() printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : NULL\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -198,7 +200,6 @@ static void __test_privilege_info_get_display_name() free(display_name); } - static void __test_privilege_info_get_display_name_by_pkgtype() { int ret; @@ -208,6 +209,7 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &display_name); __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); @@ -215,6 +217,7 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_WEB\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -227,29 +230,32 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -268,12 +274,14 @@ static void __test_privilege_info_get_description() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/window.priority.set", &description); __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -285,17 +293,19 @@ static void __test_privilege_info_get_description() printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -314,12 +324,14 @@ static void __test_privilege_info_get_description_by_pkgtype() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &description); __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -332,28 +344,31 @@ static void __test_privilege_info_get_description_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : NULL\n"); + printf("expected result : PRVINFO_ERROR_INVALID_PARAMETER\n"); if (description != NULL) { free(description); description = NULL; @@ -413,15 +428,15 @@ static void __test_privilege_info_get_privacy_display_name() static void __check_privilege_info_get_privilege_info(privilege_info_error_e expected_result, privilege_info_error_e result, GList* privilege_info_list, int return_result) { - printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { __change_color_to_yellow(); - printf("not matched\n"); + printf("not mached\n"); __change_color_to_origin(); } else { __change_color_to_green(); - printf("matched\n"); + printf("mached\n"); __change_color_to_origin(); } @@ -453,6 +468,7 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/content.read\n"); printf("privilege name : http://tizen.org/privilege/filesystem.read\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/content.read"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/filesystem.read"); @@ -470,6 +486,7 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/systemsettings.admin\n"); printf("privilege name : http://tizen.org/privilege/bookmark.admin\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/systemsettings.admin"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/bookmark.admin"); @@ -487,6 +504,7 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/alarm.xxxx\n"); printf("privilege name : http://tizen.org/privilege/account.xxx\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/alarm.xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/account.xxx"); @@ -504,6 +522,7 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/content.read\n"); printf("privilege name : http://tizen.org/privilege/filesystem.read\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/content.read"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/filesystem.read"); @@ -521,6 +540,7 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/xxxx\n"); printf("privilege name : http://tizen.org/privilege/alarm.xxxx\n"); printf("privilege name : http://tizen.org/privilege/account.xxx\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/alarm.xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/account.xxx"); -- 2.7.4 From e77701090ad23b06841971538d22ecb565734fdf Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Tue, 12 May 2020 09:48:13 +0000 Subject: [PATCH 10/16] Revert "Release version 0.0.5" This reverts commit 6043db19a5f326dbf95eff78a112d0bffcc7a728. Change-Id: I4eec57c5b65400deadb13b73114d2b1c9c2bef2c --- packaging/privilege-info.changes | 46 ---------------------------------------- packaging/privilege-info.spec | 2 +- 2 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 packaging/privilege-info.changes diff --git a/packaging/privilege-info.changes b/packaging/privilege-info.changes deleted file mode 100644 index b82b1e4..0000000 --- a/packaging/privilege-info.changes +++ /dev/null @@ -1,46 +0,0 @@ -Release version 0.0.5 -- Return error if there's no matched privilege - -Release version 0.0.4 -- Add null check before strdup() - -Release version 0.0.3 -- Fix build errors from toolchain upgrade (gcc6-> gcc9) -- Update API reference -- Update docs for wrong url -- Update doc -- Make gcov package when --define 'gcov ON' is given -- Add tizen-locale to requires -- Fix memory issue -- Add new API for getting privilege info as list - -Release version 0.0.2 -- Add privacy feature and deprecate redundant API - -Release version 0.0.1 -- Fix resource leak -- Adjust enum changes -- Merge "Fix not to launch privacy popup when getting privacy status" into tizen -- Fix not to launch privacy popup when getting privacy status -- Fix to use %license macro -- Update API reference -- Fix memory leak -- Update API documentation -- Merge "Remove rpmlint error and warning" into tizen -- Remove rpmlint error and warning -- Change test app process label on cyad command -- Add privacy related APIs -- Revise internal apis : Remove useless things -- Fix to handle invalid package type input parameter as an error -- Modify definition in header not to conflict -- Apply Tizen coding rule to headers -- Fix typo and add missing manifest to spec -- Apply "-Werror -Wall -Wextra" option -- Svace: Fix NO_RETURN_VALUE -- Revise dependency on privilege-manager -- Apply tizen coding rule -- Fix doxygen and apply secure coding -- Declare missing buildrequire to glib-2.0 -- Fix build macro for 64 bit -- Sync to latest code -- Initial empty repository diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index f4f8973..6201068 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -1,6 +1,6 @@ Name: privilege-info Summary: Privilege Information -Version: 0.0.5 +Version: 0.0.4 Release: 1 Group: Security/API License: Apache-2.0 -- 2.7.4 From d0637768b69e4174f52ae5f1513fb8264102c191 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Fri, 15 May 2020 03:26:55 +0000 Subject: [PATCH 11/16] Revert "Revert "Return error if there's no matched privilege"" This reverts commit e2782e16e5fad479c096e006b2adc6259820715c. Change-Id: If29055cabd7601aa74e3fe14ffef7efd6576794c --- doc/privilege-info_doc.h | 4 +- packaging/privilege-info.spec | 2 +- src/include/privilege_information.h | 17 ++++- src/privilege_information.c | 146 +++++++++++------------------------- test/tc_privilege_info.c | 54 +++++-------- 5 files changed, 76 insertions(+), 147 deletions(-) diff --git a/doc/privilege-info_doc.h b/doc/privilege-info_doc.h index b8119dd..d47d785 100755 --- a/doc/privilege-info_doc.h +++ b/doc/privilege-info_doc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014-2020 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. @@ -28,7 +28,7 @@ * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_OVERVIEW Overview * A library for reading privilege information of the given privilege and API issue version. * It provides the display name or description of privileges. - * If there's no matching privilege then it shows last token of given privilege or description string for undefined privileges. + * If there's no matching privilege then it returns error. * * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_FEATURE Related Features * This API is related with the following features:\n diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index b4fc806..6201068 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -107,7 +107,7 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %post -n tc-privilege-info tpk-backend -y org.tizen.test-privilege-info --preload -cyad -s -k MANIFESTS -c User::Pkg::org.tizen.test-privilege-info -u '*' -p http://tizen.org/privilege/contact.read -t DENY +cyad -s -k MANIFESTS_GLOBAL -c User::Pkg::org.tizen.test-privilege-info -u '*' -p http://tizen.org/privilege/contact.read -t DENY %files -n privilege-info %{_libdir}/libprivilege-info.so* diff --git a/src/include/privilege_information.h b/src/include/privilege_information.h index fa525da..29e83f2 100755 --- a/src/include/privilege_information.h +++ b/src/include/privilege_information.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014-2020 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. @@ -46,7 +46,8 @@ typedef enum { PRVINFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */ PRVINFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ PRVINFO_ERROR_INTERNAL_ERROR = TIZEN_ERROR_UNKNOWN, /**< Unknown error */ - PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not supported (Since 5.0) */ + PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported (Since 5.0) */ + PRVINFO_ERROR_NO_MATCHING_PRIVILEGE = TIZEN_ERROR_PRIVILEGE_INFORMATION | 0x01 /**< No matched privilege (Since 6.0) */ } privilege_info_error_e; @@ -54,12 +55,14 @@ typedef enum { * @brief Gets the display name of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). + * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege * @param[out] display_name The display name of the privilege * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful + * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -71,7 +74,8 @@ int privilege_info_get_display_name(const char *api_version, const char *privile * @brief Gets the display name of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). - * @remarks package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" + * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" + * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege @@ -79,6 +83,7 @@ int privilege_info_get_display_name(const char *api_version, const char *privile * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful + * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -90,12 +95,14 @@ int privilege_info_get_display_name_by_pkgtype(const char *package_type, const c * @brief Gets the description of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). + * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege * @param[out] description The description of the privilege * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful + * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -107,7 +114,8 @@ int privilege_info_get_description(const char *api_version, const char *privileg * @brief Gets the description of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). - * @remarks package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" + * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" + * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege @@ -115,6 +123,7 @@ int privilege_info_get_description(const char *api_version, const char *privileg * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful + * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error diff --git a/src/privilege_information.c b/src/privilege_information.c index aa1cffa..1c7687b 100755 --- a/src/privilege_information.c +++ b/src/privilege_information.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014-2020 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. @@ -65,15 +65,8 @@ #define PI_API __attribute__((visibility("default"))) #endif -typedef enum { - PRVINFO_ERROR_NO_MATCHING_PRIVILEGE = TIZEN_ERROR_PRIVILEGE_INFORMATION | 0x01 -} privilege_info_internal_error_e; - int privilege_info_get_string_id(const char *package_type_string, int display, const char *api_version, const char *privilege, char **string_id) { - TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); - TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - char* temp = NULL; int ret; privilege_manager_package_type_e package_type; @@ -87,10 +80,10 @@ int privilege_info_get_string_id(const char *package_type_string, int display, c else ret = privilege_db_manager_get_privilege_description(PRVMGR_PACKAGE_TYPE_CORE, privilege, api_version, &temp); - if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE) - goto err_none; + if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && temp != NULL) + goto string_id_found; else if (ret != PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) - goto err_internal_error; + goto err; /* Check WEB */ @@ -107,35 +100,31 @@ get_string_id_with_package_type: else ret = privilege_db_manager_get_privilege_description(package_type, privilege, api_version, &temp); - - if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE) - goto err_none; - else if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) - goto err_no_matching_privilege; + if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && temp != NULL) + goto string_id_found; else - goto err_internal_error; + goto err; -err_none: +string_id_found: *string_id = strdup(temp); TryReturn(*string_id != NULL, free(temp), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed."); free(temp); return PRVINFO_ERROR_NONE; -err_no_matching_privilege: +err: *string_id = NULL; - free(temp); - return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE; - -err_internal_error: - free(temp); - return PRVINFO_ERROR_INTERNAL_ERROR; + if (temp != NULL) + free(temp); + if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) + return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE; + else + return PRVINFO_ERROR_INTERNAL_ERROR; } int privilege_info_get_string_by_string_id(const char *string_id, char **string) { - char *temp = NULL; TryReturn(string_id != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] string_id is NULL"); - + char* temp = NULL; temp = dgettext("privilege", string_id); *string = strdup(temp); @@ -147,129 +136,80 @@ int privilege_info_get_string_by_string_id(const char *string_id, char **string) PI_API int privilege_info_get_display_name(const char *api_version, const char *privilege, char **display_name) { - int ret = 0; - char* string_id = NULL; - TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - ret = privilege_info_get_string_id(NULL, 1, api_version, privilege, &string_id); - - if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { - char* tempPrivilege = NULL; - char* token = NULL; - char* temp = NULL; - char* save = NULL; + int ret = 0; + char* string_id = NULL; - tempPrivilege = strdup(privilege); - TryReturn(tempPrivilege != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] tempPrivilege's strdup is failed."); + ret = privilege_info_get_string_id(NULL, 1, api_version, privilege, &string_id); - token = strtok_r(tempPrivilege, "/", &save); - while (token) { - temp = token; - token = strtok_r(NULL, "/", &save); - } - TryReturn(temp != NULL, free(tempPrivilege), PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid privilege <%s>", privilege); - *display_name = strdup(temp); - TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - free(tempPrivilege); - } else if (ret == PRVINFO_ERROR_NONE) { + if (ret == PRVINFO_ERROR_NONE) ret = privilege_info_get_string_by_string_id(string_id, display_name); + if (string_id != NULL) free(string_id); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else { - return PRVINFO_ERROR_INTERNAL_ERROR; - } - return PRVINFO_ERROR_NONE; + return ret; } PI_API int privilege_info_get_description(const char *api_version, const char *privilege, char **description) { - int ret = 0; - char* string_id = NULL; - TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + int ret = 0; + char* string_id = NULL; + ret = privilege_info_get_string_id(NULL, 0, api_version, privilege, &string_id); - if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { - ret = privilege_info_get_string_by_string_id("IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED", description); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else if (ret == PRVINFO_ERROR_NONE) { + if (ret == PRVINFO_ERROR_NONE) ret = privilege_info_get_string_by_string_id(string_id, description); + if (string_id != NULL) free(string_id); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else { - return PRVINFO_ERROR_INTERNAL_ERROR; - } - return PRVINFO_ERROR_NONE; + + return ret; } PI_API int privilege_info_get_display_name_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **display_name) { - int ret = 0; - char* string_id = NULL; - TryReturn(package_type != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL"); TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + int ret = 0; + char* string_id = NULL; + ret = privilege_info_get_string_id(package_type, 1, api_version, privilege, &string_id); TryReturn(ret != PRVINFO_ERROR_INVALID_PARAMETER, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid package_type : %s", package_type); - if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { - char* tempPrivilege = NULL; - char* token = NULL; - char* temp = NULL; - char* save = NULL; - tempPrivilege = strdup(privilege); - TryReturn(tempPrivilege != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] tempPrivilege's strdup is failed."); - token = strtok_r(tempPrivilege, "/", &save); - while (token) { - temp = token; - token = strtok_r(NULL, "/", &save); - } - TryReturn(temp != NULL, free(tempPrivilege), PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid privilege <%s>", privilege); - *display_name = strdup(temp); - TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - free(tempPrivilege); - } else if (ret == PRVINFO_ERROR_NONE) { + if (ret == PRVINFO_ERROR_NONE) ret = privilege_info_get_string_by_string_id(string_id, display_name); + if (string_id != NULL) free(string_id); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else { - return PRVINFO_ERROR_INTERNAL_ERROR; - } - return PRVINFO_ERROR_NONE; + + return ret; } PI_API int privilege_info_get_description_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **description) { - int ret = 0; - char* string_id = NULL; - TryReturn(package_type != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL"); TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + int ret = 0; + char* string_id = NULL; + ret = privilege_info_get_string_id(package_type, 0, api_version, privilege, &string_id); TryReturn(ret != PRVINFO_ERROR_INVALID_PARAMETER, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid package_type : %s", package_type); - if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { - ret = privilege_info_get_string_by_string_id("IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED", description); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else if (ret == PRVINFO_ERROR_NONE) { + if (ret == PRVINFO_ERROR_NONE) ret = privilege_info_get_string_by_string_id(string_id, description); + if (string_id != NULL) free(string_id); - TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - } else { - return PRVINFO_ERROR_INTERNAL_ERROR; - } - return PRVINFO_ERROR_NONE; + + return ret; } PI_API diff --git a/test/tc_privilege_info.c b/test/tc_privilege_info.c index ecc8b9f..c4f992b 100755 --- a/test/tc_privilege_info.c +++ b/test/tc_privilege_info.c @@ -43,13 +43,15 @@ static const char* __get_result_string(privilege_info_error_e ret) return "PRVINFO_ERROR_INTERNAL_ERROR"; else if (ret == PRVINFO_ERROR_NOT_SUPPORTED) return "PRVINFO_ERROR_NOT_SUPPORTED"; + else if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) + return "PRVINFO_ERROR_NO_MATCHING_PRIVILEGE"; return "PRVINFO_ERROR_NO_MATCHED_ERROR_MESSAGE"; } static void __check_get_privilege_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* display_name) { - printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -69,7 +71,7 @@ static void __check_get_privilege_display_name_result(privilege_info_error_e exp } else { printf("display_name = %s\n", display_name); } - } else { + } else if (result == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { if (display_name != NULL) { printf("display_name = %s\n", display_name); printf("display_name must be NULL\n"); @@ -90,7 +92,7 @@ static void __check_get_privilege_display_name_result(privilege_info_error_e exp static void __check_get_privilege_description_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* description) { - printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -110,7 +112,7 @@ static void __check_get_privilege_description_result(privilege_info_error_e expe } else { printf("description = %s\n", description); } - } else { + } else if (result == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { if (description != NULL) { printf("description = %s\n", description); printf("description must be NULL\n"); @@ -131,7 +133,7 @@ static void __check_get_privilege_description_result(privilege_info_error_e expe static void __check_get_privacy_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* privacy_display) { - printf("expectd result %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -159,14 +161,12 @@ static void __test_privilege_info_get_display_name() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/window.priority.set", &display_name); __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -178,19 +178,17 @@ static void __test_privilege_info_get_display_name() printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : NULL\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -200,6 +198,7 @@ static void __test_privilege_info_get_display_name() free(display_name); } + static void __test_privilege_info_get_display_name_by_pkgtype() { int ret; @@ -209,7 +208,6 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &display_name); __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); @@ -217,7 +215,6 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_WEB\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -230,32 +227,29 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -274,14 +268,12 @@ static void __test_privilege_info_get_description() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/window.priority.set", &description); __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -293,19 +285,17 @@ static void __test_privilege_info_get_description() printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -324,14 +314,12 @@ static void __test_privilege_info_get_description_by_pkgtype() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &description); __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -344,31 +332,28 @@ static void __test_privilege_info_get_description_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); printf("-----------------------------------------------------------\n"); printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : NULL\n"); - printf("expected result : PRVINFO_ERROR_INVALID_PARAMETER\n"); if (description != NULL) { free(description); description = NULL; @@ -428,15 +413,15 @@ static void __test_privilege_info_get_privacy_display_name() static void __check_privilege_info_get_privilege_info(privilege_info_error_e expected_result, privilege_info_error_e result, GList* privilege_info_list, int return_result) { - printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { __change_color_to_yellow(); - printf("not mached\n"); + printf("not matched\n"); __change_color_to_origin(); } else { __change_color_to_green(); - printf("mached\n"); + printf("matched\n"); __change_color_to_origin(); } @@ -468,7 +453,6 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/content.read\n"); printf("privilege name : http://tizen.org/privilege/filesystem.read\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/content.read"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/filesystem.read"); @@ -486,7 +470,6 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/systemsettings.admin\n"); printf("privilege name : http://tizen.org/privilege/bookmark.admin\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/systemsettings.admin"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/bookmark.admin"); @@ -504,7 +487,6 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/alarm.xxxx\n"); printf("privilege name : http://tizen.org/privilege/account.xxx\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/alarm.xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/account.xxx"); @@ -522,7 +504,6 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/content.read\n"); printf("privilege name : http://tizen.org/privilege/filesystem.read\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/content.read"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/filesystem.read"); @@ -540,7 +521,6 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/xxxx\n"); printf("privilege name : http://tizen.org/privilege/alarm.xxxx\n"); printf("privilege name : http://tizen.org/privilege/account.xxx\n"); - printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/alarm.xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/account.xxx"); -- 2.7.4 From d60f47d91ee4faeabc514c15c0d7b0abefa35e1a Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Mon, 11 May 2020 17:52:20 +0900 Subject: [PATCH 12/16] Remove deprecated API - Remove 5.0 deprecated API and related local test cases Change-Id: I7e24ea3c41b45ada1358ac55508c3072c7f35728 Signed-off-by: Yunjin Lee --- packaging/privilege-info.spec | 10 ---- src/CMakeLists.txt | 2 +- src/include/privilege_information.h | 21 ------- src/privilege_information.c | 49 ---------------- test/CMakeLists.txt | 7 --- test/org.tizen.test-privilege-info.manifest | 6 -- test/org.tizen.test-privilege-info.xml | 12 ---- test/tc_privilege_info_app_privacy.c | 86 ----------------------------- 8 files changed, 1 insertion(+), 192 deletions(-) delete mode 100644 test/org.tizen.test-privilege-info.manifest delete mode 100644 test/org.tizen.test-privilege-info.xml delete mode 100644 test/tc_privilege_info_app_privacy.c diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index 6201068..ec1896c 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -13,9 +13,6 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(security-privilege-manager) -BuildRequires: pkgconfig(cynara-client) -BuildRequires: pkgconfig(cynara-session) -BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(capi-system-info) %if 0%{?gcov:1} @@ -105,10 +102,6 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %post -n privilege-info -p /sbin/ldconfig %postun -n privilege-info -p /sbin/ldconfig -%post -n tc-privilege-info -tpk-backend -y org.tizen.test-privilege-info --preload -cyad -s -k MANIFESTS_GLOBAL -c User::Pkg::org.tizen.test-privilege-info -u '*' -p http://tizen.org/privilege/contact.read -t DENY - %files -n privilege-info %{_libdir}/libprivilege-info.so* %license LICENSE.Apache-2.0 @@ -119,9 +112,6 @@ cyad -s -k MANIFESTS_GLOBAL -c User::Pkg::org.tizen.test-privilege-info -u '*' - %{_libdir}/pkgconfig/privilege-info.pc %files -n tc-privilege-info -%manifest test/org.tizen.test-privilege-info.manifest -%{TZ_SYS_RO_APP}/org.tizen.test-privilege-info/bin/tc-privilege-info-app-privacy -%{TZ_SYS_RO_PACKAGES}/org.tizen.test-privilege-info.xml %{_bindir}/tc-privilege-info %if 0%{?gcov:1} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0789ab..a0cf43c 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,7 @@ SET(PRIV_INFO_SOURCES INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include) -SET(requires glib-2.0 dlog security-privilege-manager cynara-client cynara-session libsmack capi-system-info) +SET(requires glib-2.0 dlog security-privilege-manager capi-system-info) INCLUDE(FindPkgConfig) pkg_check_modules(${PACKAGE_NAME} REQUIRED ${requires}) FOREACH(flag ${${PACKAGE_NAME}_CFLAGS}) diff --git a/src/include/privilege_information.h b/src/include/privilege_information.h index 29e83f2..f1eb304 100755 --- a/src/include/privilege_information.h +++ b/src/include/privilege_information.h @@ -150,25 +150,6 @@ int privilege_info_get_privacy_display_name(const char *privilege, char **privac /** - * @deprecated Deprecated since 5.0. Use ppm_check_permission() instead. You can refer to @ref CAPI_PRIVACY_PRIVILEGE_MANAGER_MODULE. - * @brief Gets the status of the given privacy related privilege. - * @since_tizen 3.0 - * @remarks @a privilege must be privacy related, otherwise #PRVINFO_ERROR_INVALID_PARAMETER is returned. - * In case of errors, @a status is set to @c true. - * @param[in] privilege The privilege - * @param[out] status @c true if the privilege is on, - * and @c false if the privilege is off - * @return @c 0 on success, - * otherwise a negative error value - * @retval #PRVINFO_ERROR_NONE Successful - * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter - * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error - * @retval #PRVINFO_ERROR_NOT_SUPPORTED Not supported - */ -int privilege_info_get_privacy_privilege_status(const char *privilege, bool *status) TIZEN_DEPRECATED_API; - - -/** * @brief The structure for privilege information. * @since_tizen 5.5 */ @@ -227,8 +208,6 @@ int privilege_info_get_privilege_info_list(const char* locale, GList* privilege_ int privilege_info_free_privilege_info_list(GList* privilege_info_list); - - /** * @} */ diff --git a/src/privilege_information.c b/src/privilege_information.c index 1c7687b..1f58050 100755 --- a/src/privilege_information.c +++ b/src/privilege_information.c @@ -18,8 +18,6 @@ #include #include #include -#include -#include #include #include #include @@ -27,9 +25,6 @@ #include #include -#include -#include - #include "privilege_information.h" #ifdef LOG_TAG @@ -52,8 +47,6 @@ } \ } while (0) -#define UIDMAXLEN 10 - #define TryReturn(condition, expr, returnValue, ...) \ if (!(condition)) { \ expr; \ @@ -234,48 +227,6 @@ int privilege_info_get_privacy_display_name(const char *privilege, char **privac } PI_API -int privilege_info_get_privacy_privilege_status(const char *privilege, bool *status) -{ - LOGW("DEPRECATION WARNING: privilege_info_get_privacy_privilege_status() is deprecated and will be removed from next release. Use ppm_check_permission() instead."); - CHECK_FEATURE_SUPPORTED(PRIVACY_FEATURE); - TryReturn(privilege != NULL, *status = true, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - TryReturn(privilege_db_manager_is('p', privilege) == 1, *status = true, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege does not exist or is not a privacy related"); - - char* smack_label = NULL; - TryReturn(smack_new_label_from_self(&smack_label) != -1, *status = true, PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] smack_new_label_from_self() failed."); - - cynara *cynara = NULL; - TryReturn(cynara_initialize(&cynara, NULL) == CYNARA_API_SUCCESS, *status = true; cynara = NULL; free(smack_label), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] cynara_initialize() failed."); - - char *session = NULL; - session = cynara_session_from_pid(getpid()); - TryReturn(session != NULL, *status = true; cynara_finish(cynara); free(smack_label), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] cynara_session_from_pid() failed"); - - char uid[UIDMAXLEN]; - int result = snprintf(uid, UIDMAXLEN, "%d", getuid()); - TryReturn(uid != NULL && result > 0, *status = true; free(session); cynara_finish(cynara); free(smack_label), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] snprintf() for uid failed."); - - result = cynara_simple_check(cynara, smack_label, session, uid, privilege); - int ret = PRVINFO_ERROR_NONE; - free(session); - cynara_finish(cynara); - - LOGD("result of cynara_check(cynara %s, session, %s, %s) result = %d", smack_label, uid, privilege, result); - free(smack_label); - if (result == CYNARA_API_ACCESS_DENIED) { - *status = false; - } else if (result == CYNARA_API_ACCESS_ALLOWED) { - *status = true; - } else { - *status = true; - LOGE("[PRVINFO_ERROR_INTERNAL_ERROR] cynara_check() failed. ret = %d", result); - ret = PRVINFO_ERROR_INTERNAL_ERROR; - } - - return ret; -} - -PI_API int privilege_info_get_privilege_info_list(const char* locale, GList* privilege_name_list, GList** privilege_info_list, privilege_consumer_return_code_e* return_result) { GList *l; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 18d6f42..8da99db 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,10 +3,8 @@ SET(PACKAGE_NAME tc-privilege-info) PROJECT(${PACKAGE_NAME}) SET(TC1_NAME tc-privilege-info) -SET(TC2_NAME tc-privilege-info-app-privacy) SET(TC1_SRCS ${PROJECT_SOURCE_DIR}/tc_privilege_info.c) -SET(TC2_SRCS ${PROJECT_SOURCE_DIR}/tc_privilege_info_app_privacy.c) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include) @@ -21,11 +19,6 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall -fvisibility=hidden -D_WITH_SYSTEM SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${PACKAGE_NAME_CFLAGS}") ADD_EXECUTABLE(${TC1_NAME} ${TC1_SRCS}) -ADD_EXECUTABLE(${TC2_NAME} ${TC2_SRCS}) TARGET_LINK_LIBRARIES(${TC1_NAME} "privilege-info") -TARGET_LINK_LIBRARIES(${TC2_NAME} "privilege-info") INSTALL(TARGETS ${TC1_NAME} DESTINATION /usr/bin) -INSTALL(TARGETS ${TC2_NAME} DESTINATION ${TZ_SYS_RO_APP}/org.tizen.test-privilege-info/bin/) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/test/org.tizen.test-privilege-info.xml DESTINATION ${TZ_SYS_RO_PACKAGES}) - diff --git a/test/org.tizen.test-privilege-info.manifest b/test/org.tizen.test-privilege-info.manifest deleted file mode 100644 index ccea6a9..0000000 --- a/test/org.tizen.test-privilege-info.manifest +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/test/org.tizen.test-privilege-info.xml b/test/org.tizen.test-privilege-info.xml deleted file mode 100644 index c9d7ab2..0000000 --- a/test/org.tizen.test-privilege-info.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - http://tizen.org/privilege/account.read - http://tizen.org/privilege/contact.read - - - - diff --git a/test/tc_privilege_info_app_privacy.c b/test/tc_privilege_info_app_privacy.c deleted file mode 100644 index 6df037c..0000000 --- a/test/tc_privilege_info_app_privacy.c +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#define LOG_TAG "PRIVILEGE_INFO_TEST_APP" -#endif - - -static int fail_cnt = 0; -static int success_cnt = 0; - -static const char *__get_result_string(privilege_info_error_e ret) -{ - if (ret == PRVINFO_ERROR_NONE) - return "PRVINFO_ERROR_NONE"; - else if (ret == PRVINFO_ERROR_INVALID_PARAMETER) - return "PRVINFO_ERROR_INVALID_PARAMETER"; - else if (ret == PRVINFO_ERROR_INTERNAL_ERROR) - return "PRVINFO_ERROR_INTERNAL_ERROR"; - else if (ret == PRVINFO_ERROR_OUT_OF_MEMORY) - return "PRVINFO_ERROR_UNDECLARED_PRIVILEGE"; - else - return "FAIL"; -} - -static void __check_result(privilege_info_error_e expected_result, privilege_info_error_e result, bool expected_status, bool status) -{ - LOGD("expected result = %s, result = %s", __get_result_string(expected_result), __get_result_string(result)); - LOGD("expected status = %s, status = %s", expected_status ? "true" : "false", status ? "true" : "false"); - - if (expected_result != result) { - LOGD("test fail"); - fail_cnt++; - } else { - if (expected_status != status) { - LOGD("test fail"); - fail_cnt++; - } else { - LOGD("test success"); - success_cnt++; - } - } -} - -static void __test_privilege_info_get_privacy_privilege_status() -{ - int ret = PRVINFO_ERROR_NONE; - bool status; - - LOGD("-----------------------------------------------------------"); - LOGD("privilege : http://tizen.org/privilege/account.read"); - LOGD("expected result : PRVINFO_ERROR_NONE"); - ret = privilege_info_get_privacy_privilege_status("http://tizen.org/privilege/account.read", &status); - __check_result(PRVINFO_ERROR_NONE, ret, true, status); - LOGD("-----------------------------------------------------------"); - - LOGD("privilege : http://tizen.org/privilege/contact.read"); - LOGD("expected result : PRVINFO_ERROR_NONE"); - ret = privilege_info_get_privacy_privilege_status("http://tizen.org/privilege/contact.read", &status); - __check_result(PRVINFO_ERROR_NONE, ret, false, status); - LOGD("-----------------------------------------------------------"); - - LOGD("privilege : http://tizen.org/privilege/aaaaa"); - LOGD("expected result : PRVINFO_ERROR_INVALID_PARAMETER"); - ret = privilege_info_get_privacy_privilege_status("http://tizen.org/privilege/aaaaa", &status); - __check_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, true, status); - LOGD("-----------------------------------------------------------"); - -} - -int main() -{ - LOGD("Test function : privilege_info_get_privacy_privilege_status"); - __test_privilege_info_get_privacy_privilege_status(); - - LOGD("===================================="); - LOGD("Test Complete"); - LOGD("success : %d, ", success_cnt); - LOGD("fail : %d", fail_cnt); - LOGD("===================================="); - - return 0; -} -- 2.7.4 From 2bf1262e0a34f35d525e1d5d956ee46ff59d7283 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Tue, 2 Jun 2020 16:40:46 +0900 Subject: [PATCH 13/16] Release version 0.0.5 - Remove deprecated API - Return error if there's no matched privilege - Added changes file Change-Id: I28a11e1bf7be5fbd1ff7cd8411e8b6c6336fdf9e Signed-off-by: Yunjin Lee --- packaging/privilege-info.changes | 48 ++++++++++++++++++++++++++++++++++++++++ packaging/privilege-info.spec | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 packaging/privilege-info.changes diff --git a/packaging/privilege-info.changes b/packaging/privilege-info.changes new file mode 100644 index 0000000..c9f6749 --- /dev/null +++ b/packaging/privilege-info.changes @@ -0,0 +1,48 @@ +Release version 0.0.5 +- Remove deprecated API +- Return error if there's no matched privilege + +Release version 0.0.4 +- Add null check before strdup() + +Release version 0.0.3 +- Fix build errors from toolchain upgrade (gcc6-> gcc9) +- Update API reference +- Update docs for wrong url +- Update doc +- Make gcov package when --define 'gcov ON' is given +- Add tizen-locale to requires +- Fix memory issue +- Add new API for getting privilege info as list + +Release version 0.0.2 +- Add privacy feature and deprecate redundant API + +Release version 0.0.1 +- Fix resource leak +- Adjust enum changes +- Merge "Fix not to launch privacy popup when getting privacy status" into tizen +- Fix not to launch privacy popup when getting privacy status +- Fix to use %license macro +- Update API reference +- Fix memory leak +- Update API documentation +- Merge "Remove rpmlint error and warning" into tizen +- Remove rpmlint error and warning +- Change test app process label on cyad command +- Add privacy related APIs +- Revise internal apis : Remove useless things +- Fix to handle invalid package type input parameter as an error +- Modify definition in header not to conflict +- Apply Tizen coding rule to headers +- Fix typo and add missing manifest to spec +- Apply "-Werror -Wall -Wextra" option +- Svace: Fix NO_RETURN_VALUE +- Revise dependency on privilege-manager +- Apply tizen coding rule +- Fix doxygen and apply secure coding +- Declare missing buildrequire to glib-2.0 +- Fix build macro for 64 bit +- Sync to latest code +- Initial empty repository + diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index ec1896c..84379a5 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -1,6 +1,6 @@ Name: privilege-info Summary: Privilege Information -Version: 0.0.4 +Version: 0.0.5 Release: 1 Group: Security/API License: Apache-2.0 -- 2.7.4 From 8b9417cb9ae3d90d0337ca5fe0e28714af03355d Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Mon, 20 Jul 2020 13:31:19 +0900 Subject: [PATCH 14/16] Update API reference and doc - Update doc as suggested at https://review.tizen.org/gerrit/#/c/platform/core/security/privilege-info/+/230663/ Change-Id: Ic88b19163506c495812724e180442d32269c917e Signed-off-by: Yunjin Lee --- doc/privilege-info_doc.h | 2 +- src/include/privilege_information.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/privilege-info_doc.h b/doc/privilege-info_doc.h index d47d785..7848865 100755 --- a/doc/privilege-info_doc.h +++ b/doc/privilege-info_doc.h @@ -28,7 +28,7 @@ * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_OVERVIEW Overview * A library for reading privilege information of the given privilege and API issue version. * It provides the display name or description of privileges. - * If there's no matching privilege then it returns error. + * If there's no matching privilege then it returns an error. * * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_FEATURE Related Features * This API is related with the following features:\n diff --git a/src/include/privilege_information.h b/src/include/privilege_information.h index f1eb304..9006dbc 100755 --- a/src/include/privilege_information.h +++ b/src/include/privilege_information.h @@ -55,7 +55,7 @@ typedef enum { * @brief Gets the display name of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. + * @remarks Since 6.0, this function returns #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege doesn't exist. * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege * @param[out] display_name The display name of the privilege @@ -75,7 +75,7 @@ int privilege_info_get_display_name(const char *api_version, const char *privile * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. + * @remarks Since 6.0, this function returns #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege doesn't exist. * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege @@ -95,7 +95,7 @@ int privilege_info_get_display_name_by_pkgtype(const char *package_type, const c * @brief Gets the description of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. + * @remarks Since 6.0, this function returns #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege doesn't exist. * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege * @param[out] description The description of the privilege @@ -115,7 +115,7 @@ int privilege_info_get_description(const char *api_version, const char *privileg * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. + * @remarks Since 6.0, this function returns #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege doesn't exist. * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege -- 2.7.4 From 7b3b8734612574b97a40d65c8918b0a3f13dfb05 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Wed, 26 Aug 2020 17:33:55 +0900 Subject: [PATCH 15/16] Remove duplicated logics - Remove duplicated code with privilege-checker and call privilege-checker APIs Change-Id: Ic01498578c9932da4d546025313e7cd027a85c12 Signed-off-by: Yunjin Lee --- src/privilege_information.c | 322 +++++++------------------------------------- 1 file changed, 51 insertions(+), 271 deletions(-) diff --git a/src/privilege_information.c b/src/privilege_information.c index 1f58050..095bdc8 100755 --- a/src/privilege_information.c +++ b/src/privilege_information.c @@ -54,76 +54,52 @@ return returnValue; \ } +#define SAFE_FREE(var) { if (var) { free(var); var = NULL; } } + #ifndef PI_API #define PI_API __attribute__((visibility("default"))) #endif -int privilege_info_get_string_id(const char *package_type_string, int display, const char *api_version, const char *privilege, char **string_id) +static int __convert_package_type(const char* package_type_string) { - char* temp = NULL; - int ret; - privilege_manager_package_type_e package_type; - - if (package_type_string != NULL) - goto get_string_id_with_package_type; - - /* Check NATIVE */ - if (display) - ret = privilege_db_manager_get_privilege_display(PRVMGR_PACKAGE_TYPE_CORE, privilege, api_version, &temp); - else - ret = privilege_db_manager_get_privilege_description(PRVMGR_PACKAGE_TYPE_CORE, privilege, api_version, &temp); - - if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && temp != NULL) - goto string_id_found; - else if (ret != PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) - goto err; + if (strcmp(package_type_string, "PRVINFO_PACKAGE_TYPE_WEB") == 0) + return PRVMGR_PACKAGE_TYPE_WRT; + if (strcmp(package_type_string, "PRVINFO_PACKAGE_TYPE_NATIVE") == 0) + return PRVMGR_PACKAGE_TYPE_CORE; - /* Check WEB */ + return PRVMGR_PACKAGE_TYPE_NONE; +} -get_string_id_with_package_type: - if (package_type_string == NULL || strcmp(package_type_string, "PRVINFO_PACKAGE_TYPE_WEB") == 0) - package_type = PRVMGR_PACKAGE_TYPE_WRT; - else if (strcmp(package_type_string, "PRVINFO_PACKAGE_TYPE_NATIVE") == 0) - package_type = PRVMGR_PACKAGE_TYPE_CORE; - else +static int __convert_return_value(int ret, const char* result) +{ + switch (ret) { + case PRVMGR_ERR_NONE: + if (result == NULL) + return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE; + return PRVINFO_ERROR_NONE; + case PRVMGR_ERR_INVALID_PARAMETER: return PRVINFO_ERROR_INVALID_PARAMETER; - - if (display) - ret = privilege_db_manager_get_privilege_display(package_type, privilege, api_version, &temp); - else - ret = privilege_db_manager_get_privilege_description(package_type, privilege, api_version, &temp); - - if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && temp != NULL) - goto string_id_found; - else - goto err; - -string_id_found: - *string_id = strdup(temp); - TryReturn(*string_id != NULL, free(temp), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed."); - free(temp); - return PRVINFO_ERROR_NONE; - -err: - *string_id = NULL; - if (temp != NULL) - free(temp); - if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) + case PRVMGR_ERR_OUT_OF_MEMORY: + return PRVINFO_ERROR_OUT_OF_MEMORY; + case PRVMGR_ERR_NO_EXIST_PRIVILEGE: return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE; - else + case PRVMGR_ERR_INTERNAL_ERROR: + default: return PRVINFO_ERROR_INTERNAL_ERROR; + } } -int privilege_info_get_string_by_string_id(const char *string_id, char **string) +static int __convert_result_code(int result) { - TryReturn(string_id != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] string_id is NULL"); - char* temp = NULL; - temp = dgettext("privilege", string_id); - - *string = strdup(temp); - TryReturn(*string != NULL, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] strdup of string failed."); - - return PRVINFO_ERROR_NONE; + switch (result) { + case PRIVILEGE_NOTI_INFO_RESULT_CODE_SUCCESS: + return PRIVILEGE_CONSUMER_RETURN_CODE_SUCCESS; + case PRIVILEGE_NOTI_INFO_RESULT_CODE_UNKNOWN_LOCALE_CODE: + return PRIVILEGE_CONSUMER_RETURN_CODE_UNKNOWN_LOCALE_CODE; + case PRIVILEGE_NOTI_INFO_RESULT_CODE_INVALID_PARAMETER: + default: + return PRIVILEGE_CONSUMER_RETURN_CODE_INVALID_PARAMETER; + } } PI_API @@ -132,16 +108,7 @@ int privilege_info_get_display_name(const char *api_version, const char *privile TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; - char* string_id = NULL; - - ret = privilege_info_get_string_id(NULL, 1, api_version, privilege, &string_id); - - if (ret == PRVINFO_ERROR_NONE) - ret = privilege_info_get_string_by_string_id(string_id, display_name); - if (string_id != NULL) - free(string_id); - return ret; + return __convert_return_value(privilege_info_get_privilege_display_name(privilege, display_name), *display_name); } PI_API @@ -150,17 +117,7 @@ int privilege_info_get_description(const char *api_version, const char *privileg TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; - char* string_id = NULL; - - ret = privilege_info_get_string_id(NULL, 0, api_version, privilege, &string_id); - - if (ret == PRVINFO_ERROR_NONE) - ret = privilege_info_get_string_by_string_id(string_id, description); - if (string_id != NULL) - free(string_id); - - return ret; + return __convert_return_value(privilege_info_get_privilege_description(privilege, description), *description); } PI_API @@ -170,18 +127,7 @@ int privilege_info_get_display_name_by_pkgtype(const char *package_type, const c TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; - char* string_id = NULL; - - ret = privilege_info_get_string_id(package_type, 1, api_version, privilege, &string_id); - TryReturn(ret != PRVINFO_ERROR_INVALID_PARAMETER, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid package_type : %s", package_type); - - if (ret == PRVINFO_ERROR_NONE) - ret = privilege_info_get_string_by_string_id(string_id, display_name); - if (string_id != NULL) - free(string_id); - - return ret; + return __convert_return_value(privilege_info_get_privilege_display_name_by_package_type(privilege, api_version, __convert_package_type(package_type), display_name), *display_name); } PI_API @@ -191,18 +137,7 @@ int privilege_info_get_description_by_pkgtype(const char *package_type, const ch TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; - char* string_id = NULL; - - ret = privilege_info_get_string_id(package_type, 0, api_version, privilege, &string_id); - TryReturn(ret != PRVINFO_ERROR_INVALID_PARAMETER, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid package_type : %s", package_type); - - if (ret == PRVINFO_ERROR_NONE) - ret = privilege_info_get_string_by_string_id(string_id, description); - if (string_id != NULL) - free(string_id); - - return ret; + return __convert_return_value(privilege_info_get_privilege_description_by_package_type(privilege, api_version, __convert_package_type(package_type), description), *description); } PI_API @@ -210,188 +145,33 @@ int privilege_info_get_privacy_display_name(const char *privilege, char **privac { CHECK_FEATURE_SUPPORTED(PRIVACY_FEATURE); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - TryReturn(privilege_db_manager_is('p', privilege) == 1, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege does not exist or is not a privacy related"); - - char* privacy_id = NULL; - char* privacy_display_string_id = NULL; + TryReturn(privilege_info_is_privacy(privilege) == 1, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege does not exist or is not a privacy related"); - TryReturn(privilege_db_manager_get_privacy_by_privilege(privilege, &privacy_id) == PRIVILEGE_DB_MANAGER_ERR_NONE && privacy_id != NULL, , PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] privilege_db_manager_get_privacy_by_privilege failed"); + char* privacy_name = NULL; + TryReturn(privilege_info_get_privacy_by_privilege(privilege, &privacy_name) == PRVMGR_ERR_NONE && privacy_name != NULL, SAFE_FREE(privacy_name), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] privilege_info_get_privacy_by_privilege() failed. privilege = %s", privilege); - TryReturn(privilege_db_manager_get_privacy_display(privacy_id, &privacy_display_string_id) == PRIVILEGE_DB_MANAGER_ERR_NONE && privacy_display_string_id != NULL, free(privacy_id), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] privilege_db_manager_get_privacy_display failed"); + int ret = privilege_info_get_privacy_display(privacy_name, privacy_display_name); + SAFE_FREE(privacy_name); - TryReturn(privilege_info_get_string_by_string_id(privacy_display_string_id, privacy_display_name) == PRVINFO_ERROR_NONE && *privacy_display_name != NULL, free(privacy_id); free(privacy_display_string_id), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - - free(privacy_id); - free(privacy_display_string_id); - return PRVINFO_ERROR_NONE; + return __convert_return_value(ret, *privacy_display_name); } PI_API int privilege_info_get_privilege_info_list(const char* locale, GList* privilege_name_list, GList** privilege_info_list, privilege_consumer_return_code_e* return_result) { - GList *l; - GList *temp_privilege_info_list = NULL; - char* privilege_display = NULL; - char* privilege_description = NULL; - int is_invaild_parameter_count = 0; - int privilege_name_list_size = 0; - privilege_consumer_return_code_e consumer_return_code = PRIVILEGE_CONSUMER_RETURN_CODE_SUCCESS; - int ret = PRVINFO_ERROR_NONE; - - if (privilege_name_list == NULL) { - LOGE("[PRVINFO_ERROR_INVALID_PARAMETER] privilege_list is NULL"); - return PRVINFO_ERROR_INVALID_PARAMETER; - } - char *orig_locale = NULL; - char *result = (char *)setlocale(LC_ALL, NULL); - if (!result) { - LOGE("failed to get original locale. errno = %d", errno); - } else { - orig_locale = strdup(result); - TryReturn(orig_locale != NULL, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] strdup of orig_locale failed"); - LOGD("orig_locale = %s", orig_locale); - } - result = (char *)setlocale(LC_ALL, locale); - if (result) { - LOGI("succeeded in setting locale = %s", result); - } else { - LOGE("failed to set locale. set locale to en_US.UTF8. errno = %d", errno); - setlocale(LC_ALL, "en_US.UTF8"); - - consumer_return_code = PRIVILEGE_CONSUMER_RETURN_CODE_UNKNOWN_LOCALE_CODE; - } - - for (l = privilege_name_list; l != NULL; l = l->next) { - char* privilege_name = (char*)l->data; - - LOGI("privilege_name = %s", privilege_name); - - ret = privilege_info_get_privilege_display_name(privilege_name, &privilege_display); - if (ret == PRVMGR_ERR_NONE) { - if (privilege_display != NULL) { - LOGI("display : %s", privilege_display); - } else { - privilege_display = strdup(""); - if (privilege_display == NULL) { - LOGE("[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - ret = PRVINFO_ERROR_OUT_OF_MEMORY; - goto FINISH; - } - is_invaild_parameter_count++; - } - } else { - LOGE("failed to call privilege_info_get_privilege_display_name."); - ret = PRVINFO_ERROR_INTERNAL_ERROR; - goto FINISH; - } - - LOGI("privilege_display = %s", privilege_display); + TryReturn(privilege_name_list != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege_name_list is NULL."); - ret = privilege_info_get_privilege_description(privilege_name, &privilege_description); - if (ret == PRVMGR_ERR_NONE) { - if (privilege_description != NULL) { - LOGI("description : %s", privilege_description); - } else { - privilege_description = strdup(""); - if (privilege_description == NULL) { - LOGE("[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - ret = PRVINFO_ERROR_OUT_OF_MEMORY; - goto FINISH; - } - } - } else { - LOGE("failed to call privilege_info_get_privilege_description."); - ret = PRVINFO_ERROR_INTERNAL_ERROR; - goto FINISH; - } + privilege_noti_info_result_e result; + int ret = privilege_info_get_privilege_noti_info_list(locale, privilege_name_list, privilege_info_list, &result); + *return_result = __convert_result_code(result); - LOGD("privilege_description = %s", privilege_description); - - privilege_info_s* privilege_info = (privilege_info_s*)malloc(sizeof(privilege_info_s)); - memset(privilege_info, 0, sizeof(privilege_info_s)); - - privilege_info->privilege_name = strdup(privilege_name); - if (privilege_info->privilege_name == NULL) { - LOGE("[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - ret = PRVINFO_ERROR_OUT_OF_MEMORY; - free(privilege_info); - goto FINISH; - } - privilege_info->display_name = strdup(privilege_display); - if (privilege_info->display_name == NULL) { - LOGE("[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - ret = PRVINFO_ERROR_OUT_OF_MEMORY; - free(privilege_info->privilege_name); - free(privilege_info); - goto FINISH; - } - privilege_info->description = strdup(privilege_description); - if (privilege_info->description == NULL) { - LOGE("[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); - ret = PRVINFO_ERROR_OUT_OF_MEMORY; - free(privilege_info->privilege_name); - free(privilege_info->display_name); - free(privilege_info); - goto FINISH; - } - LOGI("privilege_info->privilege_name = %s", privilege_info->privilege_name); - LOGI("privilege_info->display_name = %s", privilege_info->display_name); - LOGI("privilege_info->description = %s", privilege_info->description); - - temp_privilege_info_list = g_list_append(temp_privilege_info_list, privilege_info); - - privilege_name_list_size++; - - if (privilege_display != NULL) { - free(privilege_display); - privilege_display = NULL; - } - - if (privilege_description != NULL) { - free(privilege_description); - privilege_description = NULL; - } - } - - if (is_invaild_parameter_count == privilege_name_list_size) - consumer_return_code = PRIVILEGE_CONSUMER_RETURN_CODE_INVALID_PARAMETER; - -FINISH: - - *privilege_info_list = temp_privilege_info_list; - *return_result = consumer_return_code; - - if (privilege_display != NULL) { - free(privilege_display); - privilege_display = NULL; - } - - if (privilege_description != NULL) { - free(privilege_description); - privilege_description = NULL; - } - if (orig_locale != NULL) { - setlocale(LC_ALL, orig_locale); - free(orig_locale); - orig_locale = NULL; - } - - return ret; + return __convert_return_value(ret, ""); } PI_API int privilege_info_free_privilege_info_list(GList* privilege_info_list) { - if (privilege_info_list == NULL) - return PRVINFO_ERROR_INVALID_PARAMETER; - - GList* l = NULL; - for (l = privilege_info_list; l != NULL; l = l->next) { - privilege_info_s* privilege_info = (privilege_info_s*)l->data; - free(privilege_info->privilege_name); - free(privilege_info->display_name); - free(privilege_info->description); - } - g_list_free(privilege_info_list); - return PRVINFO_ERROR_NONE; + return __convert_return_value(privilege_info_free_privilege_noti_info_list(privilege_info_list), ""); } + + -- 2.7.4 From 4c8d7b0187785c9798faeab16b9b7b0a83899959 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Thu, 3 Sep 2020 17:31:57 +0900 Subject: [PATCH 16/16] Release version 0.0.6 - Remove duplicated logics - Update API reference and doc Change-Id: Ie36c805c57c3c130534ae7c31b6983ce9c19e96c Signed-off-by: Yunjin Lee --- packaging/privilege-info.changes | 4 ++++ packaging/privilege-info.spec | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packaging/privilege-info.changes b/packaging/privilege-info.changes index c9f6749..85fcf2e 100644 --- a/packaging/privilege-info.changes +++ b/packaging/privilege-info.changes @@ -1,3 +1,7 @@ +Release version 0.0.6 +- Remove duplicated logics +- Update API reference and doc + Release version 0.0.5 - Remove deprecated API - Return error if there's no matched privilege diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index 84379a5..a45e337 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -1,6 +1,6 @@ Name: privilege-info Summary: Privilege Information -Version: 0.0.5 +Version: 0.0.6 Release: 1 Group: Security/API License: Apache-2.0 -- 2.7.4