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 "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" |
| 11 #include "base/debug/profiler.h" | 11 #include "base/debug/profiler.h" |
| 12 #include "base/environment.h" | |
| 12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 13 #include "base/hash.h" | 14 #include "base/hash.h" |
| 14 #include "base/metrics/sparse_histogram.h" | 15 #include "base/metrics/sparse_histogram.h" |
| 15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 16 #include "base/process/launch.h" | 17 #include "base/process/launch.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "base/strings/utf_string_conversions.h" | |
| 19 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
| 20 #include "base/win/iat_patch_function.h" | 22 #include "base/win/iat_patch_function.h" |
| 21 #include "base/win/scoped_handle.h" | 23 #include "base/win/scoped_handle.h" |
| 22 #include "base/win/scoped_process_information.h" | 24 #include "base/win/scoped_process_information.h" |
| 23 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
| 24 #include "content/common/content_switches_internal.h" | 26 #include "content/common/content_switches_internal.h" |
| 25 #include "content/public/common/content_client.h" | 27 #include "content/public/common/content_client.h" |
| 26 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 27 #include "content/public/common/sandbox_init.h" | 29 #include "content/public/common/sandbox_init.h" |
| 28 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 30 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 if (!PathService::Get(base::FILE_EXE, &exe)) | 351 if (!PathService::Get(base::FILE_EXE, &exe)) |
| 350 return false; | 352 return false; |
| 351 base::FilePath pdb_path = exe.DirName().Append(L"*.pdb"); | 353 base::FilePath pdb_path = exe.DirName().Append(L"*.pdb"); |
| 352 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, | 354 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, |
| 353 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | 355 sandbox::TargetPolicy::FILES_ALLOW_READONLY, |
| 354 pdb_path.value().c_str()); | 356 pdb_path.value().c_str()); |
| 355 if (result != sandbox::SBOX_ALL_OK) | 357 if (result != sandbox::SBOX_ALL_OK) |
| 356 return false; | 358 return false; |
| 357 #endif | 359 #endif |
| 358 | 360 |
| 361 #if defined(SANITIZER_COVERAGE) | |
| 362 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
| 363 std::string coverage_dir; | |
| 364 if (!env->GetVar("SANITIZER_COVERAGE_DIR", &coverage_dir)) { | |
| 365 LOG(WARNING) << "SANITIZER_COVERAGE_DIR was not set, coverage won't work."; | |
| 366 } else { | |
| 367 base::FilePath sancov_path = | |
| 368 base::FilePath(base::UTF16ToWide(base::ASCIIToUTF16(coverage_dir))) | |
| 369 .Append(L"*.sancov"); | |
|
cpu_(ooo_6.6-7.5)
2015/05/01 17:18:58
use the native environment function so you don't h
| |
| 370 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, | |
| 371 sandbox::TargetPolicy::FILES_ALLOW_ANY, | |
| 372 sancov_path.value().c_str()); | |
| 373 if (result != sandbox::SBOX_ALL_OK) | |
| 374 return false; | |
| 375 } | |
| 376 #endif | |
| 377 | |
| 359 AddGenericDllEvictionPolicy(policy); | 378 AddGenericDllEvictionPolicy(policy); |
| 360 return true; | 379 return true; |
| 361 } | 380 } |
| 362 | 381 |
| 363 bool AddPolicyForSandboxedProcess(sandbox::TargetPolicy* policy) { | 382 bool AddPolicyForSandboxedProcess(sandbox::TargetPolicy* policy) { |
| 364 sandbox::ResultCode result; | 383 sandbox::ResultCode result; |
| 365 // Renderers need to share events with plugins. | 384 // Renderers need to share events with plugins. |
| 366 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, | 385 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, |
| 367 sandbox::TargetPolicy::HANDLES_DUP_ANY, | 386 sandbox::TargetPolicy::HANDLES_DUP_ANY, |
| 368 L"Event"); | 387 L"Event"); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 793 } | 812 } |
| 794 | 813 |
| 795 return false; | 814 return false; |
| 796 } | 815 } |
| 797 | 816 |
| 798 bool BrokerAddTargetPeer(HANDLE peer_process) { | 817 bool BrokerAddTargetPeer(HANDLE peer_process) { |
| 799 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 818 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
| 800 } | 819 } |
| 801 | 820 |
| 802 } // namespace content | 821 } // namespace content |
| OLD | NEW |