static int g_feature_enabled = -1;
-static int g_privilege_allowed = -1;
-static int g_privilege_applaunch_allowed = -1;
+static pthread_mutex_t g_cynara_mutex = PTHREAD_MUTEX_INITIALIZER;
static cynara *p_cynara = NULL;
static int __stt_check_privilege()
{
- char uid[16];
+ pthread_mutex_lock(&g_cynara_mutex);
+
+ bool ret = true;
+ ret = __check_privilege_initialize();
+ if (false == ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] privilege initialize is failed"); //LCOV_EXCL_LINE
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return STT_ERROR_PERMISSION_DENIED;
+ }
- if (0 == g_privilege_allowed) {
+ char uid[16];
+ snprintf(uid, 16, "%d", getuid());
+ ret = true;
+ ret = __check_privilege(uid, STT_PRIVILEGE_RECORDER);
+ __check_privilege_deinitialize();
+ if (false == ret) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Permission is denied"); //LCOV_EXCL_LINE
+ pthread_mutex_unlock(&g_cynara_mutex);
return STT_ERROR_PERMISSION_DENIED;
- } else if (-1 == g_privilege_allowed) {
- if (false == __check_privilege_initialize()) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] privilege initialize is failed"); //LCOV_EXCL_LINE
- return STT_ERROR_PERMISSION_DENIED;
- }
- snprintf(uid, 16, "%d", getuid());
- if (false == __check_privilege(uid, STT_PRIVILEGE_RECORDER)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Permission is denied"); //LCOV_EXCL_LINE
- g_privilege_allowed = 0;
- __check_privilege_deinitialize();
- return STT_ERROR_PERMISSION_DENIED;
- }
- __check_privilege_deinitialize();
}
- g_privilege_allowed = 1;
+ pthread_mutex_unlock(&g_cynara_mutex);
return STT_ERROR_NONE;
}
static int __stt_check_privilege_for_applaunch()
{
- char uid[16];
+ pthread_mutex_lock(&g_cynara_mutex);
- if (0 == g_privilege_applaunch_allowed) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Permission for applaunch is denied"); //LCOV_EXCL_LINE
+ bool ret = true;
+ ret = __check_privilege_initialize();
+ if (false == ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] privilege initialize is failed (applaunch)"); //LCOV_EXCL_LINE
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return STT_ERROR_PERMISSION_DENIED;
+ }
+
+ char uid[16];
+ snprintf(uid, 16, "%d", getuid());
+ ret = true;
+ ret = __check_privilege(uid, STT_PRIVILEGE_APPLAUNCH);
+ __check_privilege_deinitialize();
+ if (false == ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Permission is denied : appmanager.launch"); //LCOV_EXCL_LINE
+ pthread_mutex_unlock(&g_cynara_mutex);
return STT_ERROR_PERMISSION_DENIED;
- } else if (-1 == g_privilege_applaunch_allowed) {
- if (false == __check_privilege_initialize()) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] privilege initialize is failed (applaunch)"); //LCOV_EXCL_LINE
- return STT_ERROR_PERMISSION_DENIED;
- }
- snprintf(uid, 16, "%d", getuid());
- if (false == __check_privilege(uid, STT_PRIVILEGE_APPLAUNCH)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Permission is denied : appmanager.launch"); //LCOV_EXCL_LINE
- g_privilege_applaunch_allowed = 0;
- __check_privilege_deinitialize();
- return STT_ERROR_PERMISSION_DENIED;
- }
- __check_privilege_deinitialize();
}
- g_privilege_applaunch_allowed = 1;
+ pthread_mutex_unlock(&g_cynara_mutex);
return STT_ERROR_NONE;
}
}
/* Check and Set vconfkey of custom engine before sending hello */
- if (1 == g_privilege_applaunch_allowed && NULL != client->current_engine_id) {
+ if (NULL != client->current_engine_id && 0 == __stt_check_privilege_for_applaunch()) {
/* Set vconfkey */
ret = __stt_set_buxtonkey(client->current_engine_id);
//LCOV_EXCL_START