From 734e47e0cec14908d6aea3f16c6deab7a3b0f4fe Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 23 May 2016 20:28:17 +0900 Subject: [PATCH] Add checking privilege Change-Id: I8bc50ddbed2b548f4fa63c23bf8ffa2de293ac69 Signed-off-by: Wonnam Jang --- CMakeLists.txt | 4 +- client/vc.c | 140 ++++++++++++++++++++++++++++++++++ common/vc_command.c | 174 +++++++++++++++++++++++++++++++++++++++++-- common/vc_defs.h | 2 + packaging/voice-control.spec | 2 + 5 files changed, 315 insertions(+), 7 deletions(-) mode change 100755 => 100644 client/vc.c diff --git a/CMakeLists.txt b/CMakeLists.txt index ab6f0bd..ffe62f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,12 +42,12 @@ INCLUDE(FindPkgConfig) IF("${_TV_PRODUCT}" STREQUAL "TRUE") pkg_check_modules(pkgs REQUIRED aul capi-base-common capi-media-audio-io capi-media-sound-manager capi-network-bluetooth capi-system-info - dbus-1 dlog ecore glib-2.0 libtzplatform-config libxml-2.0 vconf #msfapi + cynara-client cynara-session dbus-1 dlog ecore glib-2.0 libtzplatform-config libxml-2.0 vconf #msfapi ) ELSE() pkg_check_modules(pkgs REQUIRED aul capi-base-common capi-media-audio-io capi-media-sound-manager capi-network-bluetooth capi-system-info - dbus-1 dlog ecore glib-2.0 libtzplatform-config libxml-2.0 vconf + cynara-client cynara-session dbus-1 dlog ecore glib-2.0 libtzplatform-config libxml-2.0 vconf ) ENDIF() diff --git a/client/vc.c b/client/vc.c old mode 100755 new mode 100644 index 1ee1350..611352e --- a/client/vc.c +++ b/client/vc.c @@ -15,6 +15,9 @@ */ #include +#include +#include +#include #include #include "vc_client.h" @@ -36,6 +39,9 @@ static vc_h g_vc = NULL; static int g_feature_enabled = -1; +static int g_privilege_allowed = -1; +static cynara *p_cynara = NULL; + #if 0 static Ecore_Event_Handler* g_focus_in_hander = NULL; static Ecore_Event_Handler* g_focus_out_hander = NULL; @@ -74,6 +80,77 @@ static int __vc_get_feature_enabled() return 0; } +static int __check_privilege_initialize() +{ + int ret = cynara_initialize(&p_cynara, NULL); + if (CYNARA_API_SUCCESS != ret) + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] fail to initialize"); + + return ret == CYNARA_API_SUCCESS; +} + +static int __check_privilege(const char* uid, const char * privilege) +{ + FILE *fp = NULL; + char smack_label[1024] = "/proc/self/attr/current"; + + if (!p_cynara) { + return false; + } + + fp = fopen(smack_label, "r"); + if (fp != NULL) { + if (fread(smack_label, 1, sizeof(smack_label), fp) <= 0) + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] fail to fread"); + + fclose(fp); + } + + pid_t pid = getpid(); + char *session = cynara_session_from_pid(pid); + int ret = cynara_check(p_cynara, smack_label, session, uid, privilege); + SLOG(LOG_DEBUG, TAG_VCC, "[Client]cynara_check returned %d(%s)", ret, (CYNARA_API_ACCESS_ALLOWED == ret) ? "Allowed" : "Denied"); + if (session) + free(session); + + if (ret != CYNARA_API_ACCESS_ALLOWED) + return false; + return true; +} + +static void __check_privilege_deinitialize() +{ + if (p_cynara) + cynara_finish(p_cynara); + p_cynara = NULL; +} + +static int __vc_check_privilege() +{ + char uid[16]; + + if (0 == g_privilege_allowed) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied"); + return VC_ERROR_PERMISSION_DENIED; + } else if (-1 == g_privilege_allowed) { + if (false == __check_privilege_initialize()){ + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed"); + return VC_ERROR_PERMISSION_DENIED; + } + snprintf(uid, 16, "%d", getuid()); + if (false == __check_privilege(uid, VC_PRIVILEGE)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied"); + g_privilege_allowed = 0; + __check_privilege_deinitialize(); + return VC_ERROR_PERMISSION_DENIED; + } + __check_privilege_deinitialize(); + } + + g_privilege_allowed = 1; + return VC_ERROR_NONE; +} + static const char* __vc_get_error_code(vc_error_e err) { switch (err) { @@ -218,6 +295,9 @@ int vc_initialize(void) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Initialize"); @@ -302,6 +382,9 @@ int vc_deinitialize(void) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Deinitialize"); @@ -489,6 +572,9 @@ int vc_prepare(void) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Prepare"); @@ -521,6 +607,9 @@ int vc_unprepare(void) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Unprepare"); @@ -556,6 +645,9 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Foreach Supported Language"); @@ -593,6 +685,9 @@ int vc_get_current_language(char** language) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Get Current Language"); @@ -629,6 +724,9 @@ int vc_get_state(vc_state_e* state) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Get State"); @@ -665,6 +763,9 @@ int vc_get_service_state(vc_service_state_e* state) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Get Service State"); @@ -859,6 +960,9 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Set Command list"); @@ -930,6 +1034,9 @@ int vc_unset_command_list(int type) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Unset Command list"); @@ -1021,6 +1128,9 @@ int vc_set_exclusive_command_option(bool value) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Set exclusive command"); @@ -1371,6 +1481,9 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1397,6 +1510,9 @@ int vc_unset_result_cb(void) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1452,6 +1568,9 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1478,6 +1597,9 @@ int vc_unset_service_state_changed_cb(void) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1501,6 +1623,9 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (callback == NULL) return VC_ERROR_INVALID_PARAMETER; @@ -1527,6 +1652,9 @@ int vc_unset_state_changed_cb(void) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1550,6 +1678,9 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1576,6 +1707,9 @@ int vc_unset_current_language_changed_cb(void) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1599,6 +1733,9 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1625,6 +1762,9 @@ int vc_unset_error_cb(void) if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { diff --git a/common/vc_command.c b/common/vc_command.c index 293efdb..e93a1e8 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -14,7 +14,9 @@ * limitations under the License. */ - +#include +#include +#include #include #include #include @@ -28,10 +30,13 @@ static int g_feature_enabled = -1; +static int g_privilege_allowed = -1; +static cynara *p_cynara = NULL; + static int __vc_cmd_get_feature_enabled() { if (0 == g_feature_enabled) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported"); + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Voice control feature NOT supported"); return VC_ERROR_NOT_SUPPORTED; } else if (-1 == g_feature_enabled) { bool vc_supported = false; @@ -39,18 +44,18 @@ static int __vc_cmd_get_feature_enabled() if (0 == system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) { if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) { if (false == vc_supported || false == mic_supported) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported"); + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Voice control feature NOT supported"); g_feature_enabled = 0; return VC_ERROR_NOT_SUPPORTED; } g_feature_enabled = 1; } else { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Fail to get feature value"); return VC_ERROR_NOT_SUPPORTED; } } else { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Fail to get feature value"); return VC_ERROR_NOT_SUPPORTED; } } @@ -58,11 +63,86 @@ static int __vc_cmd_get_feature_enabled() return 0; } +static int __check_privilege_initialize() +{ + int ret = cynara_initialize(&p_cynara, NULL); + if (CYNARA_API_SUCCESS != ret) + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] fail to initialize"); + + return ret == CYNARA_API_SUCCESS; +} + +static int __check_privilege(const char* uid, const char * privilege) +{ + FILE *fp = NULL; + char smack_label[1024] = "/proc/self/attr/current"; + + if (!p_cynara) { + return false; + } + + fp = fopen(smack_label, "r"); + if (fp != NULL) { + if (fread(smack_label, 1, sizeof(smack_label), fp) <= 0) + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] fail to fread"); + + fclose(fp); + } + + pid_t pid = getpid(); + char *session = cynara_session_from_pid(pid); + int ret = cynara_check(p_cynara, smack_label, session, uid, privilege); + SLOG(LOG_DEBUG, TAG_VCCMD, "[Client]cynara_check returned %d(%s)", ret, (CYNARA_API_ACCESS_ALLOWED == ret) ? "Allowed" : "Denied"); + if (session) + free(session); + + if (ret != CYNARA_API_ACCESS_ALLOWED) + return false; + return true; +} + +static void __check_privilege_deinitialize() +{ + if (p_cynara) + cynara_finish(p_cynara); + p_cynara = NULL; +} + +static int __vc_cmd_check_privilege() +{ + char uid[16]; + int ret = -1; + + if (0 == g_privilege_allowed) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied"); + return VC_ERROR_PERMISSION_DENIED; + } else if (-1 == g_privilege_allowed) { + if (false == __check_privilege_initialize()){ + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] privilege initialize is failed"); + return VC_ERROR_PERMISSION_DENIED; + } + snprintf(uid, 16, "%d", getuid()); + if (false == __check_privilege(uid, VC_PRIVILEGE)) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied"); + g_privilege_allowed = 0; + __check_privilege_deinitialize(); + return VC_ERROR_PERMISSION_DENIED; + } + __check_privilege_deinitialize(); + } + + g_privilege_allowed = 1; + return VC_ERROR_NONE; +} + int vc_cmd_list_create(vc_cmd_list_h* vc_cmd_list) { if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -91,6 +171,9 @@ int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool release_command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -117,6 +200,9 @@ int vc_cmd_list_get_count(vc_cmd_list_h vc_cmd_list, int* count) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list || NULL == count) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Get command count : Input parameter is NULL"); @@ -138,6 +224,9 @@ int vc_cmd_list_add(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list || NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -166,6 +255,9 @@ int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list || NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -220,6 +312,9 @@ int vc_cmd_list_remove_all(vc_cmd_list_h vc_cmd_list, bool release_command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } SLOG(LOG_DEBUG, TAG_VCCMD, "===== Destroy all command"); @@ -268,6 +363,9 @@ int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callb if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -309,6 +407,9 @@ int vc_cmd_list_filter_by_type(vc_cmd_list_h original, int type, vc_cmd_list_h* if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == original) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -393,6 +494,9 @@ int vc_cmd_list_first(vc_cmd_list_h vc_cmd_list) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -417,6 +521,9 @@ int vc_cmd_list_last(vc_cmd_list_h vc_cmd_list) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -444,6 +551,9 @@ int vc_cmd_list_next(vc_cmd_list_h vc_cmd_list) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -471,6 +581,9 @@ int vc_cmd_list_prev(vc_cmd_list_h vc_cmd_list) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -496,6 +609,9 @@ int vc_cmd_list_get_current(vc_cmd_list_h vc_cmd_list, vc_cmd_h* vc_command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_cmd_list || NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -529,6 +645,9 @@ int vc_cmd_create(vc_cmd_h* vc_command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -565,6 +684,9 @@ int vc_cmd_destroy(vc_cmd_h vc_command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); @@ -591,6 +713,9 @@ int vc_cmd_set_id(vc_cmd_h vc_command, int id) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -613,6 +738,9 @@ int vc_cmd_get_id(vc_cmd_h vc_command, int* id) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command || NULL == id) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle "); @@ -635,6 +763,9 @@ int vc_cmd_set_command(vc_cmd_h vc_command, const char* command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -664,6 +795,9 @@ int vc_cmd_get_command(vc_cmd_h vc_command, char** command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command || NULL == command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle "); @@ -687,6 +821,9 @@ int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -715,6 +852,9 @@ int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command || NULL == command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle "); @@ -737,6 +877,9 @@ int vc_cmd_set_type(vc_cmd_h vc_command, int type) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -758,6 +901,9 @@ int vc_cmd_get_type(vc_cmd_h vc_command, int* type) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command || NULL == type) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -779,6 +925,9 @@ int vc_cmd_set_format(vc_cmd_h vc_command, vc_cmd_format_e format) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -800,6 +949,9 @@ int vc_cmd_get_format(vc_cmd_h vc_command, vc_cmd_format_e* format) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command || NULL == format) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -821,6 +973,9 @@ int vc_cmd_set_pid(vc_cmd_h vc_command, int pid) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -842,6 +997,9 @@ int vc_cmd_get_pid(vc_cmd_h vc_command, int* pid) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command || NULL == pid) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -863,6 +1021,9 @@ int vc_cmd_set_domain(vc_cmd_h vc_command, int domain) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); @@ -884,6 +1045,9 @@ int vc_cmd_get_domain(vc_cmd_h vc_command, int* domain) if (0 != __vc_cmd_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; } + if (0 != __vc_cmd_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; + } if (NULL == vc_command || NULL == domain) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter "); diff --git a/common/vc_defs.h b/common/vc_defs.h index 786b891..1194fed 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -180,6 +180,8 @@ extern "C" { #define VC_FEATURE_PATH "tizen.org/feature/speech.control" #define VC_MIC_FEATURE_PATH "tizen.org/feature/microphone" +#define VC_PRIVILEGE "http://tizen.org/privilege/recorder" + /****************************************************************************************** * Defines for common enum *******************************************************************************************/ diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index ed54462..8b38128 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -16,6 +16,8 @@ BuildRequires: pkgconfig(capi-media-audio-io) BuildRequires: pkgconfig(capi-media-sound-manager) BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(cynara-client) +BuildRequires: pkgconfig(cynara-session) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ecore) -- 2.7.4