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
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_SANDBOX_SECCOMP_BPF_LINUX_H_
6 #define CONTENT_COMMON_SANDBOX_SECCOMP_BPF_LINUX_H_
10 #include "base/basictypes.h"
11 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy_forward.h"
15 // This class has two main sets of APIs. One can be used to start the sandbox
16 // for internal content process types, the other is indirectly exposed as
17 // a public content/ API and uses a supplied policy.
18 class SandboxSeccompBpf
{
20 // This is the API to enable a seccomp-bpf sandbox for content/
22 // Is the sandbox globally enabled, can anything use it at all ?
23 // This looks at global command line flags to see if the sandbox
24 // should be enabled at all.
25 static bool IsSeccompBpfDesired();
26 // Should the sandbox be enabled for process_type ?
27 static bool ShouldEnableSeccompBpf(const std::string
& process_type
);
28 // Check if the kernel supports this sandbox. It's useful to "prewarm"
29 // this, part of the result will be cached.
30 static bool SupportsSandbox();
31 // Start the sandbox and apply the policy for process_type, depending on
32 // command line switches.
33 static bool StartSandbox(const std::string
& process_type
);
35 // This is the API to enable a seccomp-bpf sandbox by using an
37 static bool StartSandboxWithExternalPolicy(
38 playground2::BpfSandboxPolicy policy
);
39 // The "baseline" policy can be a useful base to build a sandbox policy.
40 static playground2::BpfSandboxPolicyCallback
GetBaselinePolicy();
43 DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxSeccompBpf
);
46 } // namespace content
48 #endif // CONTENT_COMMON_SANDBOX_SECCOMP_BPF_LINUX_H_