Fix privilege check of rpc-port module 90/258190/3
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 12 May 2021 04:29:24 +0000 (13:29 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 12 May 2021 06:28:29 +0000 (15:28 +0900)
Currently, AMD does not check the permission of the application that is
a default tts engine.
There are 4 modes of TTS(default, notification, screen reader, interrupt).
The following table is an examle application ID of each tts mode.
+---------------+----------------------------------------+
| Mode          | application ID                         |
+---------------+----------------------------------------+
| default       | org.tizen.tts-engine-default           |
| notification  | org.tizen.tts-engine-default-noti      |
| screen reader | org.tizen.tts-engine-default-sr        |
| interrupt     | org.tizen.tts-engine-default-interrupt |
+---------------+----------------------------------------+

After this patch is applied, AMD uses '-noti', '-sr' and '-interrupt' suffixes
to checks whether the application is the default tts engine or not.

Change-Id: I42d69c007102cdfeb778d0d284607476b56330c8
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/modules/rpc-port/src/amd_rpc_port.c

index eaa8f5f093c9f3366ef4e72d5aca68d9fdfe1c2b..1bca366a4d320f69fc0b7a312921b7b80b7593da 100644 (file)
@@ -322,6 +322,31 @@ static int __foreach_metadata_cb(const char *value, void *user_data)
        return 0;
 }
 
+static bool __is_default_tts_engine(const char* appid)
+{
+       char buf[256];
+
+       if (!__tts_engine_default)
+               return false;
+
+       if (!strcmp(__tts_engine_default, appid))
+               return true;
+
+       snprintf(buf, sizeof(buf), "%s-noti", __tts_engine_default);
+       if (!strcmp(buf, appid))
+               return true;
+
+       snprintf(buf, sizeof(buf), "%s-sr", __tts_engine_default);
+       if (!strcmp(buf, appid))
+               return true;
+
+       snprintf(buf, sizeof(buf), "%s-interrupt", __tts_engine_default);
+       if (!strcmp(buf, appid))
+               return true;
+
+       return false;
+}
+
 static int __verify_privilege_check_bypass(amd_request_h req)
 {
        int r;
@@ -343,7 +368,7 @@ static int __verify_privilege_check_bypass(amd_request_h req)
                return AMD_CYNARA_RET_ERROR;
        }
 
-       if (__tts_engine_default && !strcmp(__tts_engine_default, appid)) {
+       if (__is_default_tts_engine(appid)) {
                SECURE_LOGD("Bypass privilege check");
                return AMD_CYNARA_RET_ALLOWED;
        }