| 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 #ifndef SANDBOX_LINUX_SUID_SETUID_SANDBOX_HOST_H_ | 5 #ifndef SANDBOX_LINUX_SUID_CLIENT_SETUID_SANDBOX_HOST_H_ |
| 6 #define SANDBOX_LINUX_SUID_SETUID_SANDBOX_HOST_H_ | 6 #define SANDBOX_LINUX_SUID_CLIENT_SETUID_SANDBOX_HOST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/scoped_file.h" | 11 #include "base/files/scoped_file.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/process/launch.h" | 13 #include "base/process/launch.h" |
| 14 #include "sandbox/sandbox_export.h" | 14 #include "sandbox/sandbox_export.h" |
| 15 | 15 |
| 16 namespace sandbox { | 16 namespace sandbox { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 // (The remaining steps are described within setuid_sandbox_client.h.) | 31 // (The remaining steps are described within setuid_sandbox_client.h.) |
| 32 class SANDBOX_EXPORT SetuidSandboxHost { | 32 class SANDBOX_EXPORT SetuidSandboxHost { |
| 33 public: | 33 public: |
| 34 // All instantation should go through this factory method. | 34 // All instantation should go through this factory method. |
| 35 static SetuidSandboxHost* Create(); | 35 static SetuidSandboxHost* Create(); |
| 36 ~SetuidSandboxHost(); | 36 ~SetuidSandboxHost(); |
| 37 | 37 |
| 38 // The setuid sandbox may still be disabled via the environment. | 38 // The setuid sandbox may still be disabled via the environment. |
| 39 // This is tracked in crbug.com/245376. | 39 // This is tracked in crbug.com/245376. |
| 40 bool IsDisabledViaEnvironment(); | 40 bool IsDisabledViaEnvironment(); |
| 41 |
| 41 // Get the sandbox binary path. This method knows about the | 42 // Get the sandbox binary path. This method knows about the |
| 42 // CHROME_DEVEL_SANDBOX environment variable used for user-managed builds. If | 43 // CHROME_DEVEL_SANDBOX environment variable used for user-managed builds. If |
| 43 // the sandbox binary cannot be found, it will return an empty FilePath. | 44 // the sandbox binary cannot be found, it will return an empty FilePath. |
| 44 base::FilePath GetSandboxBinaryPath(); | 45 base::FilePath GetSandboxBinaryPath(); |
| 46 |
| 45 // Modify |cmd_line| to launch via the setuid sandbox. Crash if the setuid | 47 // Modify |cmd_line| to launch via the setuid sandbox. Crash if the setuid |
| 46 // sandbox binary cannot be found. |cmd_line| must not be NULL. | 48 // sandbox binary cannot be found. |cmd_line| must not be NULL. |
| 47 void PrependWrapper(base::CommandLine* cmd_line); | 49 void PrependWrapper(base::CommandLine* cmd_line); |
| 50 |
| 48 // Set-up the launch options for launching via the setuid sandbox. Caller is | 51 // Set-up the launch options for launching via the setuid sandbox. Caller is |
| 49 // responsible for keeping |dummy_fd| alive until LaunchProcess() completes. | 52 // responsible for keeping |dummy_fd| alive until LaunchProcess() completes. |
| 50 // |options| and |fds_to_remap| must not be NULL. | 53 // |options| and |fds_to_remap| must not be NULL. |
| 51 // (Keeping |dummy_fd| alive is an unfortunate historical artifact of the | 54 // (Keeping |dummy_fd| alive is an unfortunate historical artifact of the |
| 52 // chrome-sandbox ABI.) | 55 // chrome-sandbox ABI.) |
| 53 void SetupLaunchOptions(base::LaunchOptions* options, | 56 void SetupLaunchOptions(base::LaunchOptions* options, |
| 54 base::FileHandleMappingVector* fds_to_remap, | 57 base::FileHandleMappingVector* fds_to_remap, |
| 55 base::ScopedFD* dummy_fd); | 58 base::ScopedFD* dummy_fd); |
| 59 |
| 56 // Set-up the environment. This should be done prior to launching the setuid | 60 // Set-up the environment. This should be done prior to launching the setuid |
| 57 // helper. | 61 // helper. |
| 58 void SetupLaunchEnvironment(); | 62 void SetupLaunchEnvironment(); |
| 59 | 63 |
| 60 private: | 64 private: |
| 61 explicit SetuidSandboxHost(base::Environment* env); | 65 explicit SetuidSandboxHost(std::unique_ptr<base::Environment> env); |
| 62 | 66 |
| 63 // Holds the environment. Will never be NULL. | 67 // Holds the environment. Will never be NULL. |
| 64 std::unique_ptr<base::Environment> env_; | 68 std::unique_ptr<base::Environment> env_; |
| 65 | 69 |
| 66 DISALLOW_COPY_AND_ASSIGN(SetuidSandboxHost); | 70 DISALLOW_COPY_AND_ASSIGN(SetuidSandboxHost); |
| 67 }; | 71 }; |
| 68 | 72 |
| 69 } // namespace sandbox | 73 } // namespace sandbox |
| 70 | 74 |
| 71 #endif // SANDBOX_LINUX_SUID_SETUID_SANDBOX_HOST_H_ | 75 #endif // SANDBOX_LINUX_SUID_CLIENT_SETUID_SANDBOX_HOST_H_ |
| OLD | NEW |