+/*
+ * 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;
}
-