| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "mandoline/app/desktop/launcher_process.h" | 9 #include "mandoline/app/desktop/launcher_process.h" |
| 10 #include "mojo/runner/child_process.h" | 10 #include "mojo/runner/child_process.h" |
| 11 #include "mojo/runner/init.h" | 11 #include "mojo/runner/init.h" |
| 12 #include "mojo/runner/native_application_support.h" | |
| 13 #include "mojo/runner/switches.h" | 12 #include "mojo/runner/switches.h" |
| 14 #include "mojo/shell/native_runner.h" | 13 #include "mojo/shell/native_runner.h" |
| 15 | 14 |
| 16 #if defined(OS_LINUX) && !defined(OS_ANDROID) | |
| 17 #include "mandoline/app/desktop/linux_sandbox.h" | |
| 18 #endif | |
| 19 | |
| 20 int main(int argc, char** argv) { | 15 int main(int argc, char** argv) { |
| 21 base::CommandLine::Init(argc, argv); | 16 base::CommandLine::Init(argc, argv); |
| 22 const base::CommandLine& command_line = | 17 const base::CommandLine& command_line = |
| 23 *base::CommandLine::ForCurrentProcess(); | 18 *base::CommandLine::ForCurrentProcess(); |
| 24 | 19 |
| 25 #if defined(OS_LINUX) && !defined(OS_ANDROID) | |
| 26 using sandbox::syscall_broker::BrokerFilePermission; | |
| 27 scoped_ptr<mandoline::LinuxSandbox> sandbox; | |
| 28 if (command_line.HasSwitch(switches::kChildProcess) && | |
| 29 command_line.HasSwitch(switches::kEnableSandbox)) { | |
| 30 std::vector<BrokerFilePermission> permissions = | |
| 31 mandoline::LinuxSandbox::GetPermissions(); | |
| 32 permissions.push_back(BrokerFilePermission::ReadOnly( | |
| 33 command_line.GetSwitchValueNative(switches::kChildProcess))); | |
| 34 | |
| 35 sandbox.reset(new mandoline::LinuxSandbox(permissions)); | |
| 36 sandbox->Warmup(); | |
| 37 sandbox->EngageNamespaceSandbox(); | |
| 38 sandbox->EngageSeccompSandbox(); | |
| 39 sandbox->Seal(); | |
| 40 } | |
| 41 #endif | |
| 42 | |
| 43 base::AtExitManager at_exit; | 20 base::AtExitManager at_exit; |
| 44 mojo::runner::InitializeLogging(); | 21 mojo::runner::InitializeLogging(); |
| 45 mojo::runner::WaitForDebuggerIfNecessary(); | 22 mojo::runner::WaitForDebuggerIfNecessary(); |
| 46 | 23 |
| 47 if (command_line.HasSwitch(switches::kChildProcess)) | 24 if (command_line.HasSwitch(switches::kChildProcess)) |
| 48 return mojo::runner::ChildProcessMain(); | 25 return mojo::runner::ChildProcessMain(); |
| 49 | 26 |
| 50 return mandoline::LauncherProcessMain(argc, argv); | 27 return mandoline::LauncherProcessMain(argc, argv); |
| 51 } | 28 } |
| OLD | NEW |