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 "content/common/sandbox_win.h" | 5 #include "content/common/sandbox_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 if (!PathService::Get(base::FILE_EXE, &exe)) | 352 if (!PathService::Get(base::FILE_EXE, &exe)) |
353 return false; | 353 return false; |
354 base::FilePath pdb_path = exe.DirName().Append(L"*.pdb"); | 354 base::FilePath pdb_path = exe.DirName().Append(L"*.pdb"); |
355 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, | 355 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, |
356 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | 356 sandbox::TargetPolicy::FILES_ALLOW_READONLY, |
357 pdb_path.value().c_str()); | 357 pdb_path.value().c_str()); |
358 if (result != sandbox::SBOX_ALL_OK) | 358 if (result != sandbox::SBOX_ALL_OK) |
359 return false; | 359 return false; |
360 #endif | 360 #endif |
361 | 361 |
| 362 #if defined(SANITIZER_COVERAGE) |
| 363 DWORD coverage_dir_size = |
| 364 ::GetEnvironmentVariable(L"SANITIZER_COVERAGE_DIR", NULL, 0); |
| 365 if (coverage_dir_size == 0) { |
| 366 LOG(WARNING) << "SANITIZER_COVERAGE_DIR was not set, coverage won't work."; |
| 367 } else { |
| 368 std::wstring coverage_dir; |
| 369 wchar_t* coverage_dir_str = WriteInto(&coverage_dir, coverage_dir_size); |
| 370 coverage_dir_size = ::GetEnvironmentVariable( |
| 371 L"SANITIZER_COVERAGE_DIR", coverage_dir_str, coverage_dir_size); |
| 372 CHECK(coverage_dir.size() == coverage_dir_size); |
| 373 base::FilePath sancov_path = |
| 374 base::FilePath(coverage_dir).Append(L"*.sancov"); |
| 375 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, |
| 376 sandbox::TargetPolicy::FILES_ALLOW_ANY, |
| 377 sancov_path.value().c_str()); |
| 378 if (result != sandbox::SBOX_ALL_OK) |
| 379 return false; |
| 380 } |
| 381 #endif |
| 382 |
362 AddGenericDllEvictionPolicy(policy); | 383 AddGenericDllEvictionPolicy(policy); |
363 return true; | 384 return true; |
364 } | 385 } |
365 | 386 |
366 bool AddPolicyForSandboxedProcess(sandbox::TargetPolicy* policy) { | 387 bool AddPolicyForSandboxedProcess(sandbox::TargetPolicy* policy) { |
367 sandbox::ResultCode result; | 388 sandbox::ResultCode result; |
368 // Renderers need to share events with plugins. | 389 // Renderers need to share events with plugins. |
369 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, | 390 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, |
370 sandbox::TargetPolicy::HANDLES_DUP_ANY, | 391 sandbox::TargetPolicy::HANDLES_DUP_ANY, |
371 L"Event"); | 392 L"Event"); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 } | 833 } |
813 | 834 |
814 return false; | 835 return false; |
815 } | 836 } |
816 | 837 |
817 bool BrokerAddTargetPeer(HANDLE peer_process) { | 838 bool BrokerAddTargetPeer(HANDLE peer_process) { |
818 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 839 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
819 } | 840 } |
820 | 841 |
821 } // namespace content | 842 } // namespace content |
OLD | NEW |