| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 &temp_handle)) { | 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(temp_handle); | 51 base::win::ScopedHandle token(temp_handle); |
| 52 | 52 |
| 53 TypedBuffer<TOKEN_MANDATORY_LABEL> mandatory_label; | 53 TypedBuffer<TOKEN_MANDATORY_LABEL> mandatory_label; |
| 54 DWORD length = 0; | 54 DWORD length = 0; |
| 55 | 55 |
| 56 // Get the size of the buffer needed to hold the mandatory label. | 56 // Get the size of the buffer needed to hold the mandatory label. |
| 57 BOOL result = GetTokenInformation(token, TokenIntegrityLevel, | 57 BOOL result = GetTokenInformation(token.Get(), TokenIntegrityLevel, |
| 58 mandatory_label.get(), length, &length); | 58 mandatory_label.get(), length, &length); |
| 59 if (!result && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { | 59 if (!result && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { |
| 60 // Allocate a buffer that is large enough. | 60 // Allocate a buffer that is large enough. |
| 61 TypedBuffer<TOKEN_MANDATORY_LABEL> buffer(length); | 61 TypedBuffer<TOKEN_MANDATORY_LABEL> buffer(length); |
| 62 mandatory_label.Swap(buffer); | 62 mandatory_label.Swap(buffer); |
| 63 | 63 |
| 64 // Get the the mandatory label. | 64 // Get the the mandatory label. |
| 65 result = GetTokenInformation(token, TokenIntegrityLevel, | 65 result = GetTokenInformation(token.Get(), TokenIntegrityLevel, |
| 66 mandatory_label.get(), length, &length); | 66 mandatory_label.get(), length, &length); |
| 67 } | 67 } |
| 68 if (!result) { | 68 if (!result) { |
| 69 PLOG(ERROR) << "Failed to get the mandatory label"; | 69 PLOG(ERROR) << "Failed to get the mandatory label"; |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Read the current integrity level. | 73 // Read the current integrity level. |
| 74 DWORD sub_authority_count = | 74 DWORD sub_authority_count = |
| 75 *GetSidSubAuthorityCount(mandatory_label->Label.Sid); | 75 *GetSidSubAuthorityCount(mandatory_label->Label.Sid); |
| 76 DWORD* current_level = GetSidSubAuthority(mandatory_label->Label.Sid, | 76 DWORD* current_level = GetSidSubAuthority(mandatory_label->Label.Sid, |
| 77 sub_authority_count - 1); | 77 sub_authority_count - 1); |
| 78 | 78 |
| 79 // Set the integrity level to |max_level| if needed. | 79 // Set the integrity level to |max_level| if needed. |
| 80 if (*current_level > max_level) { | 80 if (*current_level > max_level) { |
| 81 *current_level = max_level; | 81 *current_level = max_level; |
| 82 if (!SetTokenInformation(token, TokenIntegrityLevel, mandatory_label.get(), | 82 if (!SetTokenInformation(token.Get(), TokenIntegrityLevel, |
| 83 length)) { | 83 mandatory_label.get(), length)) { |
| 84 PLOG(ERROR) << "Failed to set the mandatory label"; | 84 PLOG(ERROR) << "Failed to set the mandatory label"; |
| 85 return false; | 85 return false; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 return true; | 89 return true; |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace | 92 } // namespace |
| 93 | 93 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 224 |
| 225 ATL::_ATL_OBJMAP_ENTRY rdp_client_entry[] = { | 225 ATL::_ATL_OBJMAP_ENTRY rdp_client_entry[] = { |
| 226 OBJECT_ENTRY(__uuidof(RdpDesktopSession), RdpDesktopSession) | 226 OBJECT_ENTRY(__uuidof(RdpDesktopSession), RdpDesktopSession) |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 ChromotingModule module(rdp_client_entry, rdp_client_entry + 1); | 229 ChromotingModule module(rdp_client_entry, rdp_client_entry + 1); |
| 230 return module.Run() ? kSuccessExitCode : kInitializationFailed; | 230 return module.Run() ? kSuccessExitCode : kInitializationFailed; |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace remoting | 233 } // namespace remoting |
| OLD | NEW |