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