From: Varinder Pratap Date: Thu, 23 Jun 2022 07:40:00 +0000 (+0530) Subject: Removed permission elevation for qemu process on windows. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fbb62cf81c23c303ef6456fb3e1ffa7193613626;p=sdk%2Femulator%2Fqemu.git Removed permission elevation for qemu process on windows. Change-Id: I0f8df8bc603d4d498c72dc76d93f96dc1bf9c151 Signed-off-by: Varinder Pratap --- diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 9a5d89610d..ba2edac65b 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -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[]) { diff --git a/tizen/src/util/osutil-win32.c b/tizen/src/util/osutil-win32.c index 4cf61e3ec6..248faf24e5 100644 --- a/tizen/src/util/osutil-win32.c +++ b/tizen/src/util/osutil-win32.c @@ -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; -} - diff --git a/tizen/src/util/osutil.h b/tizen/src/util/osutil.h index 84347b9751..346b051ee9 100644 --- a/tizen/src/util/osutil.h +++ b/tizen/src/util/osutil.h @@ -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);