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}
%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
%{_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}
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})
/**
- * @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
*/
int privilege_info_free_privilege_info_list(GList* privilege_info_list);
-
-
/**
* @}
*/
#include <stdlib.h>
#include <libintl.h>
#include <dlog.h>
-#include <unistd.h>
-#include <sys/smack.h>
#include <system_info.h>
#include <locale.h>
#include <glib.h>
#include <privilege_db_manager.h>
#include <privilege_info.h>
-#include <cynara-session.h>
-#include <cynara-client.h>
-
#include "privilege_information.h"
#ifdef LOG_TAG
} \
} while (0)
-#define UIDMAXLEN 10
-
#define TryReturn(condition, expr, returnValue, ...) \
if (!(condition)) { \
expr; \
}
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;
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)
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})
-
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.tizen.test-privilege-info" version="1.0.1" install-location="internal-only">
- <ui-application appid="org.tizen.test-privilege-info" exec="tc-privilege-info-app-privacy" nodisplay="true" multiple="false" type ="capp" taskmanage="false" component-type="svcapp">
- <label>org.tizen.test-privilege-info</label>
- </ui-application>
- <privileges>
- <privilege>http://tizen.org/privilege/account.read</privilege>
- <privilege>http://tizen.org/privilege/contact.read</privilege>
- </privileges>
-</manifest>
-
-
+++ /dev/null
-#include <stdio.h>
-#include <dlog.h>
-#include <stdbool.h>
-#include <privilege_information.h>
-
-#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;
-}