| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/win/chromoting_module.h" | 5 #include "remoting/host/win/chromoting_module.h" |
| 6 | 6 |
| 7 #include <sddl.h> | 7 #include <sddl.h> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 SDDL_BUILTIN_ADMINISTRATORS) | 35 SDDL_BUILTIN_ADMINISTRATORS) |
| 36 SDDL_ACE(SDDL_ACCESS_ALLOWED, SDDL_COM_EXECUTE_LOCAL, SDDL_INTERACTIVE); | 36 SDDL_ACE(SDDL_ACCESS_ALLOWED, SDDL_COM_EXECUTE_LOCAL, SDDL_INTERACTIVE); |
| 37 | 37 |
| 38 // Holds a reference to the task runner used by the module. | 38 // Holds a reference to the task runner used by the module. |
| 39 base::LazyInstance<scoped_refptr<AutoThreadTaskRunner> > g_module_task_runner = | 39 base::LazyInstance<scoped_refptr<AutoThreadTaskRunner> > g_module_task_runner = |
| 40 LAZY_INSTANCE_INITIALIZER; | 40 LAZY_INSTANCE_INITIALIZER; |
| 41 | 41 |
| 42 // Lowers the process integrity level such that it does not exceed |max_level|. | 42 // Lowers the process integrity level such that it does not exceed |max_level|. |
| 43 // |max_level| is expected to be one of SECURITY_MANDATORY_XXX constants. | 43 // |max_level| is expected to be one of SECURITY_MANDATORY_XXX constants. |
| 44 bool LowerProcessIntegrityLevel(DWORD max_level) { | 44 bool LowerProcessIntegrityLevel(DWORD max_level) { |
| 45 base::win::ScopedHandle token; | 45 HANDLE temp_handle; |
| 46 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_WRITE, | 46 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_WRITE, |
| 47 token.Receive())) { | 47 &temp_handle)) { |
| 48 PLOG(ERROR) << "OpenProcessToken() failed"; | 48 PLOG(ERROR) << "OpenProcessToken() failed"; |
| 49 return false; | 49 return false; |
| 50 } | 50 } |
| 51 base::win::ScopedHandle token; |
| 52 token.Set(temp_handle); |
| 51 | 53 |
| 52 TypedBuffer<TOKEN_MANDATORY_LABEL> mandatory_label; | 54 TypedBuffer<TOKEN_MANDATORY_LABEL> mandatory_label; |
| 53 DWORD length = 0; | 55 DWORD length = 0; |
| 54 | 56 |
| 55 // Get the size of the buffer needed to hold the mandatory label. | 57 // Get the size of the buffer needed to hold the mandatory label. |
| 56 BOOL result = GetTokenInformation(token, TokenIntegrityLevel, | 58 BOOL result = GetTokenInformation(token, TokenIntegrityLevel, |
| 57 mandatory_label.get(), length, &length); | 59 mandatory_label.get(), length, &length); |
| 58 if (!result && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { | 60 if (!result && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { |
| 59 // Allocate a buffer that is large enough. | 61 // Allocate a buffer that is large enough. |
| 60 TypedBuffer<TOKEN_MANDATORY_LABEL> buffer(length); | 62 TypedBuffer<TOKEN_MANDATORY_LABEL> buffer(length); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 225 |
| 224 ATL::_ATL_OBJMAP_ENTRY rdp_client_entry[] = { | 226 ATL::_ATL_OBJMAP_ENTRY rdp_client_entry[] = { |
| 225 OBJECT_ENTRY(__uuidof(RdpDesktopSession), RdpDesktopSession) | 227 OBJECT_ENTRY(__uuidof(RdpDesktopSession), RdpDesktopSession) |
| 226 }; | 228 }; |
| 227 | 229 |
| 228 ChromotingModule module(rdp_client_entry, rdp_client_entry + 1); | 230 ChromotingModule module(rdp_client_entry, rdp_client_entry + 1); |
| 229 return module.Run() ? kSuccessExitCode : kInitializationFailed; | 231 return module.Run() ? kSuccessExitCode : kInitializationFailed; |
| 230 } | 232 } |
| 231 | 233 |
| 232 } // namespace remoting | 234 } // namespace remoting |
| OLD | NEW |