Disable ContentSettingBubbleModelTest.RPHAllow which is flaky.
[chromium-blink-merge.git] / content / renderer / renderer_main_platform_delegate_linux.cc
blobdd8281dd5dba57b6304b0d267d4aef94ca2ff2ec
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 #include "content/renderer/renderer_main_platform_delegate.h"
7 #include <errno.h>
8 #include <sys/stat.h>
10 #include "base/command_line.h"
11 #include "base/file_util.h"
12 #include "base/logging.h"
13 #include "content/common/sandbox_linux.h"
14 #include "content/public/common/content_switches.h"
15 #include "content/public/common/sandbox_init.h"
17 namespace content {
19 RendererMainPlatformDelegate::RendererMainPlatformDelegate(
20 const MainFunctionParams& parameters)
21 : parameters_(parameters) {
24 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() {
27 void RendererMainPlatformDelegate::PlatformInitialize() {
30 void RendererMainPlatformDelegate::PlatformUninitialize() {
33 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) {
34 // The sandbox is started in the zygote process: zygote_main_linux.cc
35 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandbox
36 return true;
39 bool RendererMainPlatformDelegate::EnableSandbox() {
40 // The setuid sandbox is started in the zygote process: zygote_main_linux.cc
41 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandbox
43 // Anything else is started in InitializeSandbox().
44 LinuxSandbox::InitializeSandbox();
45 return true;
48 void RendererMainPlatformDelegate::RunSandboxTests(bool no_sandbox) {
49 // The LinuxSandbox class requires going through initialization before
50 // GetStatus() and others can be used. When we are not launched through the
51 // Zygote, this initialization will only happen in the renderer process if
52 // EnableSandbox() above is called, which it won't necesserily be.
53 // This only happens with flags such as --renderer-cmd-prefix which are
54 // for debugging.
55 if (no_sandbox)
56 return;
58 // about:sandbox uses a value returned from LinuxSandbox::GetStatus() before
59 // any renderer has been started.
60 // Here, we test that the status of SeccompBpf in the renderer is consistent
61 // with what LinuxSandbox::GetStatus() said we would do.
62 class LinuxSandbox* linux_sandbox = LinuxSandbox::GetInstance();
63 if (linux_sandbox->GetStatus() & kSandboxLinuxSeccompBpf) {
64 CHECK(linux_sandbox->seccomp_bpf_started());
67 // Under the setuid sandbox, we should not be able to open any file via the
68 // filesystem.
69 if (linux_sandbox->GetStatus() & kSandboxLinuxSUID) {
70 CHECK(!file_util::PathExists(base::FilePath("/proc/cpuinfo")));
73 #if defined(__x86_64__)
74 // Limit this test to architectures where seccomp BPF is active in renderers.
75 if (linux_sandbox->seccomp_bpf_started()) {
76 errno = 0;
77 // This should normally return EBADF since the first argument is bogus,
78 // but we know that under the seccomp-bpf sandbox, this should return EPERM.
79 CHECK_EQ(fchmod(-1, 07777), -1);
80 CHECK_EQ(errno, EPERM);
82 #endif // __x86_64__
85 } // namespace content