Check privilege only once in same process 25/235825/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 10 Jun 2020 05:46:17 +0000 (14:46 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 10 Jun 2020 05:46:17 +0000 (14:46 +0900)
Change-Id: I7c898c154639dbe8bb0d60581af66e0deadfe1e7
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
inputmethod/src/inputmethod.cpp

index ddb28c5..1bbc151 100644 (file)
@@ -149,6 +149,9 @@ static bool g_running = false;
 static CCoreEventCallback g_core_event_callback;
 CSCLCore g_core(&g_core_event_callback);
 
+static bool g_checked_privilege = false;
+static bool g_permission_allowed = false;
+
 extern "C" {
     extern void ime_app_main(int argc, char **argv);
 }
@@ -510,7 +513,13 @@ ime_error_e _check_privilege()
     char uid[16];
     ime_error_e ret = IME_ERROR_NONE;
 
+    if (g_checked_privilege) {
+        return g_permission_allowed ? IME_ERROR_NONE : IME_ERROR_PERMISSION_DENIED;
+    }
+
     if (inputmethod_cynara_initialize() == false) {
+        g_permission_allowed = false;
+        g_checked_privilege = true;
         LOGE("inputmethod_cynara_initialize () == false");
         return IME_ERROR_PERMISSION_DENIED;
     }
@@ -521,6 +530,9 @@ ime_error_e _check_privilege()
         ret = IME_ERROR_PERMISSION_DENIED;
     }
 
+    g_permission_allowed = (ret == IME_ERROR_NONE);
+    g_checked_privilege = true;
+
     inputmethod_cynara_finish();
 
     return ret;