Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sandbox/win/tests/common/controller.h" | 5 #include "sandbox/win/tests/common/controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 is_initialized = true; | 87 is_initialized = true; |
| 88 } | 88 } |
| 89 | 89 |
| 90 return broker; | 90 return broker; |
| 91 } | 91 } |
| 92 | 92 |
| 93 TestRunner::TestRunner(JobLevel job_level, TokenLevel startup_token, | 93 TestRunner::TestRunner(JobLevel job_level, TokenLevel startup_token, |
| 94 TokenLevel main_token) | 94 TokenLevel main_token) |
| 95 : is_init_(false), is_async_(false), no_sandbox_(false), | 95 : is_init_(false), is_async_(false), no_sandbox_(false), |
| 96 target_process_id_(0) { | 96 target_process_id_(0) { |
| 97 Init(job_level, startup_token, main_token); | 97 Init(job_level, startup_token, main_token, false); |
| 98 } | |
| 99 | |
| 100 TestRunner::TestRunner(bool enable_create_process) | |
| 101 : is_init_(false), | |
| 102 is_async_(false), | |
| 103 no_sandbox_(false), | |
| 104 target_process_id_(0) { | |
| 105 Init(JOB_LOCKDOWN, USER_RESTRICTED_SAME_ACCESS, USER_LOCKDOWN, | |
| 106 enable_create_process); | |
| 98 } | 107 } |
| 99 | 108 |
| 100 TestRunner::TestRunner() | 109 TestRunner::TestRunner() |
| 101 : is_init_(false), is_async_(false), no_sandbox_(false), | 110 : is_init_(false), is_async_(false), no_sandbox_(false), |
| 102 target_process_id_(0) { | 111 target_process_id_(0) { |
| 103 Init(JOB_LOCKDOWN, USER_RESTRICTED_SAME_ACCESS, USER_LOCKDOWN); | 112 Init(JOB_LOCKDOWN, USER_RESTRICTED_SAME_ACCESS, USER_LOCKDOWN, false); |
| 104 } | 113 } |
| 105 | 114 |
| 106 void TestRunner::Init(JobLevel job_level, TokenLevel startup_token, | 115 void TestRunner::Init(JobLevel job_level, |
| 107 TokenLevel main_token) { | 116 TokenLevel startup_token, |
| 117 TokenLevel main_token, | |
| 118 bool enable_create_process) { | |
| 108 broker_ = NULL; | 119 broker_ = NULL; |
| 109 policy_ = NULL; | 120 policy_ = NULL; |
| 110 timeout_ = kDefaultTimeout; | 121 timeout_ = kDefaultTimeout; |
| 111 state_ = AFTER_REVERT; | 122 state_ = AFTER_REVERT; |
| 112 is_async_= false; | 123 is_async_= false; |
| 113 kill_on_destruction_ = true; | 124 kill_on_destruction_ = true; |
| 114 target_process_id_ = 0; | 125 target_process_id_ = 0; |
| 115 | 126 |
| 116 broker_ = GetBroker(); | 127 broker_ = GetBroker(); |
| 117 if (!broker_) | 128 if (!broker_) |
| 118 return; | 129 return; |
| 119 | 130 |
| 120 policy_ = broker_->CreatePolicy(); | 131 policy_ = broker_->CreatePolicy(); |
| 121 if (!policy_) | 132 if (!policy_) |
| 122 return; | 133 return; |
| 123 | 134 |
| 124 policy_->SetJobLevel(job_level, 0); | 135 policy_->SetJobLevel(job_level, 0); |
| 125 policy_->SetTokenLevel(startup_token, main_token); | 136 policy_->SetTokenLevel(startup_token, main_token); |
| 126 | 137 |
| 127 // Close all ALPC ports. | 138 if (!enable_create_process) { |
|
Will Harris
2016/01/25 19:32:36
Can this not be moved to InternalRunTest and a new
penny
2016/01/26 22:37:10
Done. Excellent idea. For some reason I didn't c
| |
| 128 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 139 // Close all ALPC ports. |
| 129 policy_->AddKernelObjectToClose(L"ALPC Port", NULL); | 140 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 141 policy_->AddKernelObjectToClose(L"ALPC Port", NULL); | |
| 142 } | |
| 130 } | 143 } |
| 131 | 144 |
| 132 is_init_ = true; | 145 is_init_ = true; |
| 133 } | 146 } |
| 134 | 147 |
| 135 TargetPolicy* TestRunner::GetPolicy() { | 148 TargetPolicy* TestRunner::GetPolicy() { |
| 136 return policy_; | 149 return policy_; |
| 137 } | 150 } |
| 138 | 151 |
| 139 TestRunner::~TestRunner() { | 152 TestRunner::~TestRunner() { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 | 374 |
| 362 target->LowerToken(); | 375 target->LowerToken(); |
| 363 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { | 376 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { |
| 364 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; | 377 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; |
| 365 } | 378 } |
| 366 | 379 |
| 367 return command(argc - 4, argv + 4); | 380 return command(argc - 4, argv + 4); |
| 368 } | 381 } |
| 369 | 382 |
| 370 } // namespace sandbox | 383 } // namespace sandbox |
| OLD | NEW |