Chromium Code Reviews| Index: sandbox/linux/services/namespace_sandbox.h |
| diff --git a/sandbox/linux/services/namespace_sandbox.h b/sandbox/linux/services/namespace_sandbox.h |
| index b92f5818f1bee1b4afb3cc32e260113dd6caa48b..0ee2922cdf3cd04852cb065342ae29097d3989ed 100644 |
| --- a/sandbox/linux/services/namespace_sandbox.h |
| +++ b/sandbox/linux/services/namespace_sandbox.h |
| @@ -5,6 +5,8 @@ |
| #ifndef SANDBOX_LINUX_SERVICES_NAMESPACE_SANDBOX_H_ |
| #define SANDBOX_LINUX_SERVICES_NAMESPACE_SANDBOX_H_ |
| +#include <sys/types.h> |
| + |
| #include <string> |
| #include <vector> |
| @@ -47,6 +49,30 @@ class SANDBOX_EXPORT NamespaceSandbox { |
| static base::Process LaunchProcess(const std::vector<std::string>& argv, |
| const base::LaunchOptions& options); |
| + // Forks a process in its own PID namespace. The child process is the init |
| + // process inside of the PID namespace, so if the child needs to fork further, |
| + // it should call CreateInitProcessReaper, which turns the init process into a |
| + // reaper process. |
| + // |
| + // If the child does not call CreateInitProcessReaper, then there are some |
| + // special considerations to be made for the fact that it is an init process |
| + // in a PID namespace. |
| + // |
| + // Aside from SIGKILL and SIGSTOP, the init process in a PID namespace ignores |
| + // signals for which it does not have an explicit signal handler. The child |
| + // may call InstallTerminationSignalHandler to setup handlers for these |
| + // signals that exit with a specific exit code. For most purposes, handlers |
| + // should be installed for at least these signals: |
| + // |
| + // SIGHUP, SIGINT, SIGABRT, SIGQUIT, SIGPIPE, SIGTERM, SIGUSR1, SIGUSR2 |
| + // |
| + // This function requries CAP_SYS_ADMIN. Callers are responsible for dropping |
| + // capabilities in the child if desired. |
| + static pid_t ForkInNewPidNamespace(); |
| + |
| + // Installs a signal handler for |sig| which exits with |exit_code|. |
| + static void InstallTerminationSignalHandler(int sig, int exit_code); |
|
jln (very slow on Chromium)
2015/03/24 22:03:34
I would like to make this API really easy to use f
jln (very slow on Chromium)
2015/03/24 22:57:40
Meh: we still need to support a separate InstallTe
rickyz (no longer on Chrome)
2015/03/25 22:47:46
Any opinions on whether this should take a map or
jln (very slow on Chromium)
2015/03/25 23:47:50
I was thinking this should take two arguments: a d
|
| + |
| // Returns whether the namespace sandbox created a new user, PID, and network |
| // namespace. In particular, InNewUserNamespace should return true iff the |
| // process was started via this class. |