* 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.
+ *
+ * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/security.privacy_privilege\n
+ * 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 <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>Feature Element</b>.</a>
*/
Name: privilege-info
Summary: Privilege Information
-Version: 0.0.1
+Version: 0.0.2
Release: 1
Group: Security/API
License: Apache-2.0
BuildRequires: pkgconfig(cynara-session)
BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(capi-system-info)
%description
Provides Privilege Information(Privilege Info) API
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
-SET(requires glib-2.0 dlog security-privilege-manager cynara-client cynara-session libsmack)
+SET(requires glib-2.0 dlog security-privilege-manager cynara-client cynara-session libsmack capi-system-info)
INCLUDE(FindPkgConfig)
pkg_check_modules(${PACKAGE_NAME} REQUIRED ${requires})
FOREACH(flag ${${PACKAGE_NAME}_CFLAGS})
/*
- * Copyright (c) 2013 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.
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) */
} privilege_info_error_e;
* @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
* @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_display_name(const char *privilege, char **privacy_name);
/**
+ * @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.
* @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);
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <libintl.h>
#include <cynara-client.h>
#include <unistd.h>
#include <sys/smack.h>
+#include <system_info.h>
#include "privilege_information.h"
#ifdef LOG_TAG
#undef LOG_TAG
#define LOG_TAG "PRIVILEGE_INFO"
#endif
+#define PRIVACY_FEATURE "http://tizen.org/feature/security.privacy_privilege"
+#define CHECK_FEATURE_SUPPORTED(feature_name) \
+ do { \
+ bool is_supported = false; \
+ int ret = system_info_get_platform_bool(feature_name, &is_supported); \
+ if (ret != SYSTEM_INFO_ERROR_NONE) { \
+ LOGE("system_info_get_platform_bool failed. ret = %d", ret); \
+ return PRVINFO_ERROR_INTERNAL_ERROR; \
+ } \
+ if (!is_supported) { \
+ LOGE("%s is disabled", feature_name); \
+ return PRVINFO_ERROR_NOT_SUPPORTED; \
+ } \
+ } while (0)
+
#define UIDMAXLEN 10
#define TryReturn(condition, expr, returnValue, ...) \
PI_API
int privilege_info_get_privacy_display_name(const char *privilege, char **privacy_display_name)
{
+ 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");
PI_API
int privilege_info_get_privacy_privilege_status(const char *privilege, bool *status)
{
+ 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");
return ret;
}
-
return "PRVINFO_ERROR_OUT_OF_MEMORY";
else if (ret == PRVINFO_ERROR_INTERNAL_ERROR)
return "PRVINFO_ERROR_INTERNAL_ERROR";
+ else if (ret == PRVINFO_ERROR_NOT_SUPPORTED)
+ return "PRVINFO_ERROR_NOT_SUPPORTED";
return "PRVINFO_ERROR_NO_MATCHED_ERROR_MESSAGE";
}