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 #ifndef CONTENT_COMMON_SECCOMP_SANDBOX_H_ | 5 #ifndef CONTENT_COMMON_SECCOMP_SANDBOX_H_ |
6 #define CONTENT_COMMON_SECCOMP_SANDBOX_H_ | 6 #define CONTENT_COMMON_SECCOMP_SANDBOX_H_ |
7 | 7 |
8 // Seccomp enable/disable logic is centralized here. | 8 // Seccomp enable/disable logic is centralized here. |
9 // - We define SECCOMP_SANDBOX if seccomp is compiled in at all: currently, | 9 // - We define SECCOMP_SANDBOX if seccomp is compiled in at all: currently, |
10 // on non-views (non-ChromeOS) non-ARM non-Clang Linux only. | 10 // on non-views (non-ChromeOS) non-ARM non-Clang Linux only. |
11 // - If we have SECCOMP_SANDBOX, we provide SeccompSandboxEnabled() as | |
12 // a run-time test to determine whether to turn on seccomp: | |
13 // currently, on by default in debug builds and off by default in | |
14 // release. | |
15 | 11 |
16 #include "base/command_line.h" | |
17 #include "build/build_config.h" | 12 #include "build/build_config.h" |
18 #include "content/public/common/content_switches.h" | |
19 | 13 |
20 #if defined(ARCH_CPU_X86_FAMILY) && !defined(CHROMIUM_SELINUX) && \ | 14 #if defined(ARCH_CPU_X86_FAMILY) && !defined(CHROMIUM_SELINUX) && \ |
21 !defined(OS_CHROMEOS) && !defined(TOOLKIT_VIEWS) && !defined(OS_OPENBSD) | 15 !defined(OS_CHROMEOS) && !defined(TOOLKIT_VIEWS) && !defined(OS_OPENBSD) |
22 #define SECCOMP_SANDBOX | 16 #define SECCOMP_SANDBOX |
23 #include "sandbox/linux/seccomp-legacy/sandbox.h" | 17 #include "sandbox/linux/seccomp-legacy/sandbox.h" |
24 #endif | 18 #endif |
25 | 19 |
26 #if defined(SECCOMP_SANDBOX) | |
27 // Return true if seccomp is enabled. | |
28 static bool SeccompSandboxEnabled() { | |
29 // TODO(evan): turn on for release too once we've flushed out all the bugs, | |
30 // allowing us to delete this file entirely and just rely on the "disabled" | |
31 // switch. | |
32 #ifdef NDEBUG | |
33 // Off by default; allow turning on with a switch. | |
34 return CommandLine::ForCurrentProcess()->HasSwitch( | |
35 switches::kEnableSeccompSandbox); | |
36 #else | |
37 // On by default; allow turning off with a switch. | |
38 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
39 switches::kDisableSeccompSandbox); | |
40 #endif // NDEBUG | |
41 } | |
42 #endif // SECCOMP_SANDBOX | |
43 | |
44 #endif // CONTENT_COMMON_SECCOMP_SANDBOX_H_ | 20 #endif // CONTENT_COMMON_SECCOMP_SANDBOX_H_ |
OLD | NEW |