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 <fcntl.h> | 5 #include <fcntl.h> |
6 #include <sys/stat.h> | 6 #include <sys/stat.h> |
7 #include <sys/types.h> | 7 #include <sys/types.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/eintr_wrapper.h" | 10 #include "base/eintr_wrapper.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 process_type + "."; | 30 process_type + "."; |
31 #if defined(OS_CHROMEOS) | 31 #if defined(OS_CHROMEOS) |
32 LOG(WARNING) << activated_sandbox; | 32 LOG(WARNING) << activated_sandbox; |
33 #else | 33 #else |
34 VLOG(1) << activated_sandbox; | 34 VLOG(1) << activated_sandbox; |
35 #endif | 35 #endif |
36 } | 36 } |
37 | 37 |
38 // Implement the command line enabling logic for seccomp-legacy. | 38 // Implement the command line enabling logic for seccomp-legacy. |
39 bool IsSeccompLegacyDesired() { | 39 bool IsSeccompLegacyDesired() { |
| 40 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 41 if (command_line->HasSwitch(switches::kNoSandbox)) { |
| 42 return false; |
| 43 } |
40 #if defined(SECCOMP_SANDBOX) | 44 #if defined(SECCOMP_SANDBOX) |
41 #if defined(NDEBUG) | 45 #if defined(NDEBUG) |
42 // Off by default. Allow turning on with a switch. | 46 // Off by default. Allow turning on with a switch. |
43 return CommandLine::ForCurrentProcess()->HasSwitch( | 47 return command_line->HasSwitch(switches::kEnableSeccompSandbox); |
44 switches::kEnableSeccompSandbox); | |
45 #else | 48 #else |
46 // On by default. Allow turning off with a switch. | 49 // On by default. Allow turning off with a switch. |
47 return !CommandLine::ForCurrentProcess()->HasSwitch( | 50 return !command_line->HasSwitch(switches::kDisableSeccompSandbox); |
48 switches::kDisableSeccompSandbox); | |
49 #endif // NDEBUG | 51 #endif // NDEBUG |
50 #endif // SECCOMP_SANDBOX | 52 #endif // SECCOMP_SANDBOX |
51 return false; | 53 return false; |
52 } | 54 } |
53 | 55 |
54 // Our "policy" on whether or not to enable seccomp-legacy. Only renderers are | 56 // Our "policy" on whether or not to enable seccomp-legacy. Only renderers are |
55 // supported. | 57 // supported. |
56 bool ShouldEnableSeccompLegacy(const std::string& process_type) { | 58 bool ShouldEnableSeccompLegacy(const std::string& process_type) { |
57 if (IsSeccompLegacyDesired() && | 59 if (IsSeccompLegacyDesired() && |
58 process_type == switches::kRendererProcess) { | 60 process_type == switches::kRendererProcess) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 return seccomp_legacy_supported_; | 228 return seccomp_legacy_supported_; |
227 } | 229 } |
228 | 230 |
229 bool LinuxSandbox::seccomp_bpf_supported() const { | 231 bool LinuxSandbox::seccomp_bpf_supported() const { |
230 CHECK(pre_initialized_); | 232 CHECK(pre_initialized_); |
231 return seccomp_bpf_supported_; | 233 return seccomp_bpf_supported_; |
232 } | 234 } |
233 | 235 |
234 } // namespace content | 236 } // namespace content |
235 | 237 |
OLD | NEW |