Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: sandbox/linux/services/namespace_sandbox.cc

Issue 1161933003: Demo: Build NamespaceSandbox::ForkInNewPidNamespace. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/linux/services/namespace_sandbox.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/services/namespace_sandbox.cc
diff --git a/sandbox/linux/services/namespace_sandbox.cc b/sandbox/linux/services/namespace_sandbox.cc
index 23796446f3044e88a6ddcb5d6e38fb41156e8456..ce8ecf1c0d2e71e42293e297ba116ead48ab6ed2 100644
--- a/sandbox/linux/services/namespace_sandbox.cc
+++ b/sandbox/linux/services/namespace_sandbox.cc
@@ -24,6 +24,7 @@
#include "base/process/process.h"
#include "sandbox/linux/services/credentials.h"
#include "sandbox/linux/services/namespace_utils.h"
+#include "sandbox/linux/system_headers/linux_signal.h"
namespace sandbox {
@@ -131,26 +132,6 @@ base::Process NamespaceSandbox::LaunchProcess(
}
// static
-pid_t NamespaceSandbox::ForkInNewPidNamespace(bool drop_capabilities_in_child) {
- const pid_t pid =
- base::ForkWithFlags(CLONE_NEWPID | SIGCHLD, nullptr, nullptr);
- if (pid < 0) {
- return pid;
- }
-
- if (pid == 0) {
- DCHECK_EQ(1, getpid());
- if (drop_capabilities_in_child) {
- // Since we just forked, we are single-threaded, so this should be safe.
- CHECK(Credentials::DropAllCapabilitiesOnCurrentThread());
- }
- return 0;
- }
-
- return pid;
-}
-
-// static
void NamespaceSandbox::InstallDefaultTerminationSignalHandlers() {
static const int kDefaultTermSignals[] = {
SIGHUP, SIGINT, SIGABRT, SIGQUIT, SIGPIPE, SIGTERM, SIGUSR1, SIGUSR2,
@@ -191,6 +172,26 @@ bool NamespaceSandbox::InstallTerminationSignalHandler(
#endif // !defined(OS_NACL_NONSFI)
// static
+pid_t NamespaceSandbox::ForkInNewPidNamespace(bool drop_capabilities_in_child) {
+ const pid_t pid =
+ base::ForkWithFlags(CLONE_NEWPID | LINUX_SIGCHLD, nullptr, nullptr);
+ if (pid < 0) {
+ return pid;
+ }
+
+ if (pid == 0) {
+ DCHECK_EQ(1, getpid());
+ if (drop_capabilities_in_child) {
+ // Since we just forked, we are single-threaded, so this should be safe.
+ CHECK(Credentials::DropAllCapabilitiesOnCurrentThread());
+ }
+ return 0;
+ }
+
+ return pid;
+}
+
+// static
bool NamespaceSandbox::InNewUserNamespace() {
return getenv(kSandboxUSERNSEnvironmentVarName) != nullptr;
}
« no previous file with comments | « sandbox/linux/services/namespace_sandbox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698