Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: remoting/host/win/chromoting_module.cc

Issue 92173002: Merge 237541 "Revert of https://codereview.chromium.org/71013004/" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1721/src/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 HANDLE temp_handle; 45 base::win::ScopedHandle token;
46 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_WRITE, 46 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_WRITE,
47 &temp_handle)) { 47 token.Receive())) {
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);
52 51
53 TypedBuffer<TOKEN_MANDATORY_LABEL> mandatory_label; 52 TypedBuffer<TOKEN_MANDATORY_LABEL> mandatory_label;
54 DWORD length = 0; 53 DWORD length = 0;
55 54
56 // Get the size of the buffer needed to hold the mandatory label. 55 // Get the size of the buffer needed to hold the mandatory label.
57 BOOL result = GetTokenInformation(token, TokenIntegrityLevel, 56 BOOL result = GetTokenInformation(token, TokenIntegrityLevel,
58 mandatory_label.get(), length, &length); 57 mandatory_label.get(), length, &length);
59 if (!result && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { 58 if (!result && GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
60 // Allocate a buffer that is large enough. 59 // Allocate a buffer that is large enough.
61 TypedBuffer<TOKEN_MANDATORY_LABEL> buffer(length); 60 TypedBuffer<TOKEN_MANDATORY_LABEL> buffer(length);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 223
225 ATL::_ATL_OBJMAP_ENTRY rdp_client_entry[] = { 224 ATL::_ATL_OBJMAP_ENTRY rdp_client_entry[] = {
226 OBJECT_ENTRY(__uuidof(RdpDesktopSession), RdpDesktopSession) 225 OBJECT_ENTRY(__uuidof(RdpDesktopSession), RdpDesktopSession)
227 }; 226 };
228 227
229 ChromotingModule module(rdp_client_entry, rdp_client_entry + 1); 228 ChromotingModule module(rdp_client_entry, rdp_client_entry + 1);
230 return module.Run() ? kSuccessExitCode : kInitializationFailed; 229 return module.Run() ? kSuccessExitCode : kInitializationFailed;
231 } 230 }
232 231
233 } // namespace remoting 232 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/setup/daemon_installer_win.cc ('k') | remoting/host/win/launch_process_with_token.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698