Add privilege checker for TIDL privileges 73/278973/1
authorsooyeon <sooyeon.kim@samsung.com>
Thu, 30 Jun 2022 09:33:26 +0000 (18:33 +0900)
committersooyeon <sooyeon.kim@samsung.com>
Fri, 29 Jul 2022 01:25:59 +0000 (10:25 +0900)
Change-Id: Iaf23e79bf61094688579297613f7e1ec3753d618
Signed-off-by: sooyeon <sooyeon.kim@samsung.com>
client/vc.c
client/vc_mgr.c
common/vc_command.c
common/vc_defs.h
server/vce.c

index 4fed631c1be10311d8c83d142d00a8c0e4bb2342..fecde6a4f7d30bfc1472ab4db8a68f7fed76ba2d 100644 (file)
@@ -167,15 +167,40 @@ static int __vc_check_privilege()
                char uid[32];
                snprintf(uid, 32, "%d", getuid());
                ret = true;
-               ret = __check_privilege(uid, VC_PRIVILEGE);
-               __check_privilege_deinitialize();
+               ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
                if (false == ret) {
                        //LCOV_EXCL_START
-                       SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied");
+                       SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
+                       __check_privilege_deinitialize();
+                       g_privilege_allowed = false;
                        pthread_mutex_unlock(&g_cynara_mutex);
                        return VC_ERROR_PERMISSION_DENIED;
                        //LCOV_EXCL_STOP
                }
+
+               ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING);
+               if (false == ret) {
+                       //LCOV_EXCL_START
+                       SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid);
+                       __check_privilege_deinitialize();
+                       g_privilege_allowed = false;
+                       pthread_mutex_unlock(&g_cynara_mutex);
+                       return VC_ERROR_PERMISSION_DENIED;
+                       //LCOV_EXCL_STOP
+               }
+
+               ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR);
+               if (false == ret) {
+                       //LCOV_EXCL_START
+                       SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid);
+                       __check_privilege_deinitialize();
+                       g_privilege_allowed = false;
+                       pthread_mutex_unlock(&g_cynara_mutex);
+                       return VC_ERROR_PERMISSION_DENIED;
+                       //LCOV_EXCL_STOP
+               }
+
+               __check_privilege_deinitialize();
        }
 
        g_privilege_allowed = true;
index 5019344d0203f774c64a4e094fadf69d91e8dc41..4fe673d6dd46859b9a724d3f2b029fb55fadb363 100644 (file)
@@ -229,16 +229,15 @@ static int __vc_mgr_check_privilege()
                char uid[32];
                snprintf(uid, 32, "%d", getuid());
                ret = true;
-               ret = __check_privilege(uid, VC_PRIVILEGE);
+               ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
                if (false == ret) {
-                       SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE, uid);
+                       SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
                        __check_privilege_deinitialize();
                        g_privilege_allowed = false;
                        pthread_mutex_unlock(&g_cynara_mutex);
                        return VC_ERROR_PERMISSION_DENIED;
                }
 
-               ret = true;
                ret = __check_privilege(uid, VC_MGR_PRIVILEGE);
                if (false == ret) {
                        SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_MGR_PRIVILEGE, uid);
@@ -248,6 +247,24 @@ static int __vc_mgr_check_privilege()
                        return VC_ERROR_PERMISSION_DENIED;
                }
 
+               ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING);
+               if (false == ret) {
+                       SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid);
+                       __check_privilege_deinitialize();
+                       g_privilege_allowed = false;
+                       pthread_mutex_unlock(&g_cynara_mutex);
+                       return VC_ERROR_PERMISSION_DENIED;
+               }
+
+               ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR);
+               if (false == ret) {
+                       SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid);
+                       __check_privilege_deinitialize();
+                       g_privilege_allowed = false;
+                       pthread_mutex_unlock(&g_cynara_mutex);
+                       return VC_ERROR_PERMISSION_DENIED;
+               }
+
                __check_privilege_deinitialize();
        }
 
index 3f1b32b042a37b6ec28f7d5be1a3d78221d4d1f4..34138f381f70c710b7820d05a32083bc3a5e38e0 100644 (file)
@@ -160,14 +160,40 @@ static int __vc_cmd_check_privilege()
                char uid[32];
                snprintf(uid, 32, "%d", getuid());
                ret = true;
-               ret = __check_privilege(uid, VC_PRIVILEGE);
-               __check_privilege_deinitialize();
+               ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
+               if (false == ret) {
+                       //LCOV_EXCL_START
+                       SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
+                       __check_privilege_deinitialize();
+                       g_privilege_allowed = false;
+                       pthread_mutex_unlock(&g_cynara_mutex);
+                       return VC_ERROR_PERMISSION_DENIED;
+                       //LCOV_EXCL_STOP
+               }
+
+               ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING);
                if (false == ret) {
-                       SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied");
+                       //LCOV_EXCL_START
+                       SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid);
+                       __check_privilege_deinitialize();
                        g_privilege_allowed = false;
                        pthread_mutex_unlock(&g_cynara_mutex);
                        return VC_ERROR_PERMISSION_DENIED;
+                       //LCOV_EXCL_STOP
                }
+
+               ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR);
+               if (false == ret) {
+                       //LCOV_EXCL_START
+                       SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid);
+                       __check_privilege_deinitialize();
+                       g_privilege_allowed = false;
+                       pthread_mutex_unlock(&g_cynara_mutex);
+                       return VC_ERROR_PERMISSION_DENIED;
+                       //LCOV_EXCL_STOP
+               }
+
+               __check_privilege_deinitialize();
        }
 
        g_privilege_allowed = true;
index d2170521d07727bffa9578e71e5465c1a91c9d4c..d9a07b53e7a56e67812a8392c1bb49bb0f39baea 100644 (file)
@@ -276,8 +276,10 @@ extern "C" {
 #define VC_MGR_FEATURE_PATH            "tizen.org/feature/speech.control_manager"
 #define VC_MIC_FEATURE_PATH            "tizen.org/feature/microphone"
 
-#define VC_PRIVILEGE                   "http://tizen.org/privilege/recorder"
-#define VC_MGR_PRIVILEGE               "http://tizen.org/privilege/voicecontrol.manager"
+#define VC_PRIVILEGE_RECORDER          "http://tizen.org/privilege/recorder"
+#define VC_MGR_PRIVILEGE                       "http://tizen.org/privilege/voicecontrol.manager"
+#define VC_PRIVILEGE_DATASHARING       "http://tizen.org/privilege/datasharing"
+#define VC_PRIVILEGE_APPMGR                    "http://tizen.org/privilege/appmanager.launch"
 
 /******************************************************************************************
 * Definitions for common enum
index be70147b831991ece2f89108e7cb85f7aefc35d3..7ea23274c31ec7d866edb31e400900a2eca73721 100644 (file)
@@ -130,13 +130,41 @@ static int __vce_check_privilege()
                char uid[32];
                snprintf(uid, 32, "%d", getuid());
                ret = true;
-               ret = __check_privilege(uid, VC_PRIVILEGE);
-               __check_privilege_deinitialize();
+               ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
+               if (false == ret) {
+                       //LCOV_EXCL_START
+                       SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
+                       __check_privilege_deinitialize();
+                       g_privilege_allowed = false;
+                       pthread_mutex_unlock(&g_cynara_mutex);
+                       return VCE_ERROR_PERMISSION_DENIED;
+                       //LCOV_EXCL_STOP
+               }
+
+               ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING);
+               if (false == ret) {
+                       //LCOV_EXCL_START
+                       SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid);
+                       __check_privilege_deinitialize();
+                       g_privilege_allowed = false;
+                       pthread_mutex_unlock(&g_cynara_mutex);
+                       return VCE_ERROR_PERMISSION_DENIED;
+                       //LCOV_EXCL_STOP
+               }
+
+               ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR);
                if (false == ret) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied");
+                       //LCOV_EXCL_START
+                       SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid);
+                       __check_privilege_deinitialize();
+                       g_privilege_allowed = false;
                        pthread_mutex_unlock(&g_cynara_mutex);
                        return VCE_ERROR_PERMISSION_DENIED;
+                       //LCOV_EXCL_STOP
                }
+
+               __check_privilege_deinitialize();
+
        }
 
        g_privilege_allowed = true;