struct pass_resource_monitor_client *client;
struct sockaddr_un server_addr;
int ret = TIZEN_ERROR_NO_DATA;
+ bool privilege_supported = false;
- if (!is_privilege_supported(PRIVILEGE_SYSTEMMONITOR))
+ ret = privilege_get_privilege_supported(PRIVILEGE_SYSTEMMONITOR, &privilege_supported);
+ if (ret != 0 || !privilege_supported)
return TIZEN_ERROR_PERMISSION_DENIED;
client = malloc(sizeof(struct pass_resource_monitor_client));
extern char *program_invocation_name;
-bool is_privilege_supported(const char *privilege_name)
+int privilege_get_privilege_supported(const char *privilege_name, bool *privilege_supported)
{
cynara *cynara = NULL;
FILE *fp = NULL;
char smack_label[BUFF_MAX] = {0, };
int ret;
+ if (!privilege_supported)
+ return -EINVAL;
+
if (cynara_initialize(&cynara, NULL) != CYNARA_API_SUCCESS) {
_E("failed to initialize cynara");
- return false;
+ *privilege_supported = false;
+ return -EPERM;
}
fp = fopen("/proc/self/attr/current", "r");
if (cynara)
cynara_finish(cynara);
if (ret != CYNARA_API_ACCESS_ALLOWED) {
- _E("'%s' privilege is not supported on %s",
+ _W("'%s' privilege is not supported on %s",
privilege_name, program_invocation_name);
- return false;
+
+ *privilege_supported = false;
+ } else {
+ *privilege_supported = true;
}
- return true;
+ return 0;
}