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/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/hash.h" | 13 #include "base/hash.h" |
| 14 #include "base/logging.h" |
14 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
15 #include "base/metrics/sparse_histogram.h" | 16 #include "base/metrics/sparse_histogram.h" |
16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
17 #include "base/process/launch.h" | 18 #include "base/process/launch.h" |
18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
20 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
21 #include "base/trace_event/trace_event.h" | 22 #include "base/trace_event/trace_event.h" |
22 #include "base/win/iat_patch_function.h" | 23 #include "base/win/iat_patch_function.h" |
23 #include "base/win/scoped_handle.h" | 24 #include "base/win/scoped_handle.h" |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 exposed_files.value().c_str()); | 735 exposed_files.value().c_str()); |
735 if (result != sandbox::SBOX_ALL_OK) | 736 if (result != sandbox::SBOX_ALL_OK) |
736 return base::Process(); | 737 return base::Process(); |
737 } | 738 } |
738 | 739 |
739 if (!AddGenericPolicy(policy)) { | 740 if (!AddGenericPolicy(policy)) { |
740 NOTREACHED(); | 741 NOTREACHED(); |
741 return base::Process(); | 742 return base::Process(); |
742 } | 743 } |
743 | 744 |
| 745 // Allow the renderer and gpu processes to access the log file. |
| 746 if (type_str == switches::kRendererProcess || |
| 747 type_str == switches::kGpuProcess) { |
| 748 if (logging::IsLoggingToFileEnabled()) { |
| 749 DCHECK(base::FilePath(logging::GetLogFileFullPath()).IsAbsolute()); |
| 750 policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, |
| 751 sandbox::TargetPolicy::FILES_ALLOW_ANY, |
| 752 logging::GetLogFileFullPath().c_str()); |
| 753 } |
| 754 } |
| 755 |
744 #if !defined(OFFICIAL_BUILD) | 756 #if !defined(OFFICIAL_BUILD) |
745 // If stdout/stderr point to a Windows console, these calls will | 757 // If stdout/stderr point to a Windows console, these calls will |
746 // have no effect. | 758 // have no effect. |
747 policy->SetStdoutHandle(GetStdHandle(STD_OUTPUT_HANDLE)); | 759 policy->SetStdoutHandle(GetStdHandle(STD_OUTPUT_HANDLE)); |
748 policy->SetStderrHandle(GetStdHandle(STD_ERROR_HANDLE)); | 760 policy->SetStderrHandle(GetStdHandle(STD_ERROR_HANDLE)); |
749 #endif | 761 #endif |
750 | 762 |
751 if (delegate) { | 763 if (delegate) { |
752 bool success = true; | 764 bool success = true; |
753 delegate->PreSpawnTarget(policy, &success); | 765 delegate->PreSpawnTarget(policy, &success); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 } | 839 } |
828 | 840 |
829 return false; | 841 return false; |
830 } | 842 } |
831 | 843 |
832 bool BrokerAddTargetPeer(HANDLE peer_process) { | 844 bool BrokerAddTargetPeer(HANDLE peer_process) { |
833 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 845 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
834 } | 846 } |
835 | 847 |
836 } // namespace content | 848 } // namespace content |
OLD | NEW |