Removed permission elevation for qemu process on windows. 81/276781/1
authorVarinder Pratap <varinder.p@samsung.com>
Thu, 23 Jun 2022 07:40:00 +0000 (13:10 +0530)
committerVarinder Pratap <varinder.p@samsung.com>
Fri, 24 Jun 2022 11:07:04 +0000 (16:37 +0530)
Change-Id: I0f8df8bc603d4d498c72dc76d93f96dc1bf9c151
Signed-off-by: Varinder Pratap <varinder.p@samsung.com>
tizen/src/emulator.c
tizen/src/util/osutil-win32.c
tizen/src/util/osutil.h

index 9a5d89610d7eb4d412c46f760ef21f58dbcd6bd1..ba2edac65b27970e3b07b69cb4ef2e146427cadb 100644 (file)
@@ -356,16 +356,6 @@ int main(int argc, char *argv[], char **envp)
     init_error_handler();
     return emulator_main(argc, argv, envp);
 }
-#elif defined (CONFIG_WIN32)
-int main(int argc, char *argv[])
-{
-    if (!check_integrity_level_and_respawn()) {
-        LOG_INFO("check_integrity_level_and_respawn Success!\n");
-        init_error_handler();
-        return emulator_main(argc, argv, NULL);
-    }
-    return 0;
-}
 #else
 int main(int argc, char *argv[])
 {
index 4cf61e3ec611cf30f68f1dc934723b055f7e4a32..248faf24e53d4b4b53fb16480c2620d3245b4f06 100644 (file)
@@ -155,11 +155,11 @@ int get_number_of_processors(void)
     return num_processors;
 }
 
-// FIXME
-OSVERSIONINFO osvi;
+
 
 void print_system_info_os(void)
 {
+    OSVERSIONINFO osvi;
     LOG_INFO("* Windows\n");
     LOG_INFO("* LibPNG Version : %s\n", PNG_LIBPNG_VER_STRING);
 
@@ -341,117 +341,3 @@ javahome_not_found:
     *java_path = current_java_path;
 }
 
-bool check_integrity_level_and_respawn(void)
-{
-    BOOL                    bResult = false;
-    HANDLE                  hToken = NULL;
-    HANDLE                  hNewToken = NULL;
-    PSID                    pIntegritySid = NULL;
-    TOKEN_MANDATORY_LABEL   TIL = { { 0, }, };
-    PTOKEN_MANDATORY_LABEL  pTIL = NULL;
-    PROCESS_INFORMATION     ProcInfo = { 0, };
-    STARTUPINFO             StartupInfo = { 0, };
-    SID_IDENTIFIER_AUTHORITY
-                            MLAuthority = { SECURITY_MANDATORY_LABEL_AUTHORITY };
-    DWORD                   dwIntegrityLevel, dwSize = 0;
-
-    if(!OpenProcessToken(GetCurrentProcess(),
-                TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_QUERY |
-                TOKEN_ASSIGN_PRIMARY, &hToken)) {
-        LOG_WARNING("OpenProcessToken Error %lu\n", GetLastError());
-        goto CleanExit;
-    }
-
-    if (!GetTokenInformation(hToken, TokenGroups, NULL, 0, &dwSize)) {
-        DWORD dwResult = GetLastError();
-        if (dwResult != ERROR_INSUFFICIENT_BUFFER) {
-            LOG_WARNING("GetTokenInformation Error %lu\n", dwResult);
-            goto CleanExit;
-        }
-    }
-
-    pTIL = (PTOKEN_MANDATORY_LABEL)LocalAlloc(0, dwSize);
-    if (!pTIL) {
-        LOG_WARNING("LocalAlloc Error %lu\n", GetLastError());
-        goto CleanExit;
-    }
-
-    if (!GetTokenInformation(hToken, TokenIntegrityLevel, pTIL,
-                dwSize, &dwSize)) {
-        LOG_WARNING("GetTokenInformation Error %lu\n", GetLastError());
-        goto CleanExit;
-    }
-
-    dwIntegrityLevel = *GetSidSubAuthority(pTIL->Label.Sid,
-            (DWORD)(UCHAR)(*GetSidSubAuthorityCount(pTIL->Label.Sid) - 1));
-
-    if (dwIntegrityLevel >= SECURITY_MANDATORY_MEDIUM_RID &&
-            dwIntegrityLevel < SECURITY_MANDATORY_HIGH_RID) {
-        // We have medium integrity level. So keep going on.
-        goto CleanExit;
-    }
-
-    LOG_INFO("Running with elevated integrity level. Try to respawn.\n");
-
-    if (!DuplicateTokenEx(hToken, 0, NULL, SecurityImpersonation,
-            TokenPrimary, &hNewToken)) {
-        LOG_WARNING("DuplicateTokenEx Error %lu\n", GetLastError());
-        goto CleanExit;
-    }
-
-    if (!AllocateAndInitializeSid(&MLAuthority, 1, SECURITY_MANDATORY_MEDIUM_RID,
-                0, 0, 0, 0, 0, 0, 0, &pIntegritySid)) {
-        LOG_WARNING("AllocateAndInitializeSid Error %lu\n", GetLastError());
-        goto CleanExit;
-    }
-
-    TIL.Label.Attributes = SE_GROUP_INTEGRITY;
-    TIL.Label.Sid = pIntegritySid;
-
-    if (!SetTokenInformation(hNewToken,
-            TokenIntegrityLevel,
-            &TIL,
-            sizeof(TOKEN_MANDATORY_LABEL) + GetLengthSid(pIntegritySid))) {
-        LOG_WARNING("SetTokenInformation Error %lu\n", GetLastError());
-        goto CleanExit;
-    }
-
-    if (!CreateProcessAsUser(hNewToken, 0, GetCommandLine(),
-            NULL, NULL, FALSE, 0, NULL, NULL, &StartupInfo, &ProcInfo)) {
-        LOG_WARNING( "CreateProcessAsUser Error %lu\n", GetLastError());
-        goto CleanExit;
-    }
-
-    LOG_INFO("Respawning success. Waiting for child process.\n");
-    bResult = true;
-    WaitForSingleObject(ProcInfo.hProcess, INFINITE);
-    LOG_INFO("Respawn successfull. Elevated Process.\n");
-
-CleanExit:
-    if (ProcInfo.hProcess != NULL) {
-        CloseHandle(ProcInfo.hProcess);
-    }
-
-    if (ProcInfo.hThread != NULL) {
-        CloseHandle(ProcInfo.hThread);
-    }
-
-    if (pIntegritySid != NULL) {
-        LocalFree(pIntegritySid);
-    }
-
-    if (hNewToken != NULL) {
-        CloseHandle(hNewToken);
-    }
-
-    if (hToken != NULL) {
-        CloseHandle(hToken);
-    }
-
-    if (pTIL != NULL) {
-        LocalFree(pTIL);
-    }
-
-    return bResult;
-}
-
index 84347b9751d1e9aaf68cb7e3433723d5f06adddc..346b051ee9a6e18ea9b018296d8c834d0c08eb73 100644 (file)
@@ -41,8 +41,6 @@
 extern "C" {
 #endif
 
-extern const char *pac_tempfile;
-
 void make_vm_lock_os(gchar *vms_path);
 bool make_sdcard_lock_os(char *sdcard);
 int remove_sdcard_lock_os(char *sdcard);
@@ -54,7 +52,6 @@ bool make_sdcard_lock_posix(char *sdcard);
 int remove_sdcard_lock_posix(char *sdcard);
 #else
 void get_java_path_win32(const char **java_path);
-bool check_integrity_level_and_respawn(void);
 #endif
 
 void set_bin_path_os(char const *const);