#include <string>
#include "base/command_line.h"
#include "base/logging.h"
#include "content/common/sandbox_linux.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/sandbox_init.h"
namespace content {
bool InitializeSandbox() {
bool seccomp_legacy_started = false;
bool seccomp_bpf_started = false;
LinuxSandbox* linux_sandbox = LinuxSandbox::GetInstance();
const std::string process_type =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessType);
if (!linux_sandbox->IsSingleThreaded()) {
std::string error_message = "InitializeSandbox() called with multiple "
"threads in process " + process_type;
LOG(ERROR) << error_message;
return false;
}
seccomp_bpf_started = linux_sandbox->StartSeccompBpf(process_type);
if (!seccomp_bpf_started) {
seccomp_legacy_started = linux_sandbox->StartSeccompLegacy(process_type);
}
return seccomp_legacy_started || seccomp_bpf_started;
}
}