| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 if (!policy_) | 129 if (!policy_) |
| 130 return; | 130 return; |
| 131 | 131 |
| 132 policy_->SetJobLevel(job_level, 0); | 132 policy_->SetJobLevel(job_level, 0); |
| 133 policy_->SetTokenLevel(startup_token, main_token); | 133 policy_->SetTokenLevel(startup_token, main_token); |
| 134 | 134 |
| 135 is_init_ = true; | 135 is_init_ = true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 TargetPolicy* TestRunner::GetPolicy() { | 138 TargetPolicy* TestRunner::GetPolicy() { |
| 139 return policy_; | 139 return policy_.get(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 TestRunner::~TestRunner() { | 142 TestRunner::~TestRunner() { |
| 143 if (target_process_.IsValid() && kill_on_destruction_) | 143 if (target_process_.IsValid() && kill_on_destruction_) |
| 144 ::TerminateProcess(target_process_.Get(), 0); | 144 ::TerminateProcess(target_process_.Get(), 0); |
| 145 | |
| 146 if (policy_) | |
| 147 policy_->Release(); | |
| 148 } | 145 } |
| 149 | 146 |
| 150 bool TestRunner::AddRule(TargetPolicy::SubSystem subsystem, | 147 bool TestRunner::AddRule(TargetPolicy::SubSystem subsystem, |
| 151 TargetPolicy::Semantics semantics, | 148 TargetPolicy::Semantics semantics, |
| 152 const wchar_t* pattern) { | 149 const wchar_t* pattern) { |
| 153 if (!is_init_) | 150 if (!is_init_) |
| 154 return false; | 151 return false; |
| 155 | 152 |
| 156 return (SBOX_ALL_OK == policy_->AddRule(subsystem, semantics, pattern)); | 153 return (SBOX_ALL_OK == policy_->AddRule(subsystem, semantics, pattern)); |
| 157 } | 154 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 | 365 |
| 369 target->LowerToken(); | 366 target->LowerToken(); |
| 370 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { | 367 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { |
| 371 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; | 368 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; |
| 372 } | 369 } |
| 373 | 370 |
| 374 return command(argc - 4, argv + 4); | 371 return command(argc - 4, argv + 4); |
| 375 } | 372 } |
| 376 | 373 |
| 377 } // namespace sandbox | 374 } // namespace sandbox |
| OLD | NEW |