| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 base::FilePath debug_message(long_path_buf); | 322 base::FilePath debug_message(long_path_buf); |
| 323 debug_message = debug_message.AppendASCII("debug_message.exe"); | 323 debug_message = debug_message.AppendASCII("debug_message.exe"); |
| 324 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_PROCESS, | 324 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_PROCESS, |
| 325 sandbox::TargetPolicy::PROCESS_MIN_EXEC, | 325 sandbox::TargetPolicy::PROCESS_MIN_EXEC, |
| 326 debug_message.value().c_str()); | 326 debug_message.value().c_str()); |
| 327 if (result != sandbox::SBOX_ALL_OK) | 327 if (result != sandbox::SBOX_ALL_OK) |
| 328 return false; | 328 return false; |
| 329 #endif // NDEBUG | 329 #endif // NDEBUG |
| 330 | 330 |
| 331 // Add the policy for read-only PDB file access for AddressSanitizer. | 331 // Add the policy for read-only PDB file access for stack traces. |
| 332 #if defined(ADDRESS_SANITIZER) | 332 #if !defined(OFFICIAL_BUILD) |
| 333 base::FilePath exe; | 333 base::FilePath exe; |
| 334 if (!PathService::Get(base::FILE_EXE, &exe)) | 334 if (!PathService::Get(base::FILE_EXE, &exe)) |
| 335 return false; | 335 return false; |
| 336 base::FilePath pdb_path = exe.DirName().Append(L"*.pdb"); | 336 base::FilePath pdb_path = exe.DirName().Append(L"*.pdb"); |
| 337 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, | 337 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, |
| 338 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | 338 sandbox::TargetPolicy::FILES_ALLOW_READONLY, |
| 339 pdb_path.value().c_str()); | 339 pdb_path.value().c_str()); |
| 340 if (result != sandbox::SBOX_ALL_OK) | 340 if (result != sandbox::SBOX_ALL_OK) |
| 341 return false; | 341 return false; |
| 342 #endif | 342 #endif |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 exposed_files.value().c_str()); | 734 exposed_files.value().c_str()); |
| 735 if (result != sandbox::SBOX_ALL_OK) | 735 if (result != sandbox::SBOX_ALL_OK) |
| 736 return base::Process(); | 736 return base::Process(); |
| 737 } | 737 } |
| 738 | 738 |
| 739 if (!AddGenericPolicy(policy)) { | 739 if (!AddGenericPolicy(policy)) { |
| 740 NOTREACHED(); | 740 NOTREACHED(); |
| 741 return base::Process(); | 741 return base::Process(); |
| 742 } | 742 } |
| 743 | 743 |
| 744 if (browser_command_line.HasSwitch(switches::kEnableLogging)) { | 744 #if !defined(OFFICIAL_BUILD) |
| 745 // If stdout/stderr point to a Windows console, these calls will | 745 // If stdout/stderr point to a Windows console, these calls will |
| 746 // have no effect. | 746 // have no effect. |
| 747 policy->SetStdoutHandle(GetStdHandle(STD_OUTPUT_HANDLE)); | 747 policy->SetStdoutHandle(GetStdHandle(STD_OUTPUT_HANDLE)); |
| 748 policy->SetStderrHandle(GetStdHandle(STD_ERROR_HANDLE)); | 748 policy->SetStderrHandle(GetStdHandle(STD_ERROR_HANDLE)); |
| 749 } | 749 #endif |
| 750 | 750 |
| 751 if (delegate) { | 751 if (delegate) { |
| 752 bool success = true; | 752 bool success = true; |
| 753 delegate->PreSpawnTarget(policy, &success); | 753 delegate->PreSpawnTarget(policy, &success); |
| 754 if (!success) | 754 if (!success) |
| 755 return base::Process(); | 755 return base::Process(); |
| 756 } | 756 } |
| 757 | 757 |
| 758 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); | 758 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); |
| 759 | 759 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 } | 827 } |
| 828 | 828 |
| 829 return false; | 829 return false; |
| 830 } | 830 } |
| 831 | 831 |
| 832 bool BrokerAddTargetPeer(HANDLE peer_process) { | 832 bool BrokerAddTargetPeer(HANDLE peer_process) { |
| 833 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 833 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
| 834 } | 834 } |
| 835 | 835 |
| 836 } // namespace content | 836 } // namespace content |
| OLD | NEW |