| 930 | } |
| 931 | |
| 932 | bool BrowserFactory::CreateLowIntegrityLevelToken(HANDLE* process_token_handle, |
| 933 | HANDLE* mic_token_handle, |
| 934 | PSID* sid) { |
| 935 | LOG(TRACE) << "Entering BrowserFactory::CreateLowIntegrityLevelToken"; |
| 936 | BOOL result = TRUE; |
| 937 | TOKEN_MANDATORY_LABEL tml = {0}; |
| 938 | |
| 939 | HANDLE process_handle = ::GetCurrentProcess(); |
| 940 | result = ::OpenProcessToken(process_handle, |
| 941 | MAXIMUM_ALLOWED, |
| 942 | process_token_handle); |
| 943 | |
| 944 | if (result) { |
| 945 | result = ::DuplicateTokenEx(*process_token_handle, |
| 946 | MAXIMUM_ALLOWED, |
| 947 | NULL, |
| 948 | SecurityImpersonation, |
| 949 | TokenPrimary, |
| 950 | mic_token_handle); |
| 951 | if (!result) { |
| 952 | LOGERR(WARN) << "CreateLowIntegrityLevelToken: Could not duplicate token"; |
| 953 | ::CloseHandle(*process_token_handle); |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | if (result) { |
| 958 | result = ::ConvertStringSidToSid(SDDL_ML_LOW, sid); |
| 959 | if (result) { |
| 960 | tml.Label.Attributes = SE_GROUP_INTEGRITY; |
| 961 | tml.Label.Sid = *sid; |
| 962 | } else { |
| 963 | LOGERR(WARN) << "CreateLowIntegrityLevelToken: Could not convert string SID to SID"; |
| 964 | ::CloseHandle(*process_token_handle); |
| 965 | ::CloseHandle(*mic_token_handle); |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | if(result) { |
| 970 | result = ::SetTokenInformation(*mic_token_handle, |
| 971 | TokenIntegrityLevel, |
| 972 | &tml, |
| 973 | sizeof(tml) + ::GetLengthSid(*sid)); |
| 974 | if (!result) { |
| 975 | LOGERR(WARN) << "CreateLowIntegrityLevelToken: Could not set token information to low level"; |
| 976 | ::CloseHandle(*process_token_handle); |
| 977 | ::CloseHandle(*mic_token_handle); |
| 978 | ::LocalFree(*sid); |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | ::CloseHandle(process_handle); |
| 983 | return result == TRUE; |
| 984 | } |
| 985 | |
| 986 | void BrowserFactory::InvokeClearCacheUtility(bool use_low_integrity_level) { |
| 987 | LOG(TRACE) << "Entering BrowserFactory::InvokeClearCacheUtility"; |
no test coverage detected