Chromium Code Reviews| Index: sandbox/linux/services/credentials_unittest.cc |
| diff --git a/sandbox/linux/services/credentials_unittest.cc b/sandbox/linux/services/credentials_unittest.cc |
| index 4fc902323683b7dcdcfa9ede67a49b376c2aff2a..a000aa0d1a0abf3db35e2f8bd098467bd89a083c 100644 |
| --- a/sandbox/linux/services/credentials_unittest.cc |
| +++ b/sandbox/linux/services/credentials_unittest.cc |
| @@ -6,6 +6,7 @@ |
| #include <errno.h> |
| #include <fcntl.h> |
| +#include <sched.h> |
| #include <stdio.h> |
| #include <sys/stat.h> |
| #include <sys/types.h> |
| @@ -16,6 +17,7 @@ |
| #include "base/files/scoped_file.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/process/launch.h" |
| #include "sandbox/linux/tests/unit_tests.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -71,13 +73,6 @@ SANDBOX_TEST(Credentials, MoveToNewUserNS) { |
| CHECK(!Credentials::HasAnyCapability()); |
| } |
| -SANDBOX_TEST(Credentials, SupportsUserNS) { |
| - CHECK(Credentials::DropAllCapabilities()); |
| - bool user_ns_supported = Credentials::SupportsNewUserNS(); |
| - bool moved_to_new_ns = Credentials::MoveToNewUserNS(); |
| - CHECK_EQ(user_ns_supported, moved_to_new_ns); |
| -} |
| - |
| SANDBOX_TEST(Credentials, UidIsPreserved) { |
| CHECK(Credentials::DropAllCapabilities()); |
| uid_t old_ruid, old_euid, old_suid; |
| @@ -153,7 +148,14 @@ SANDBOX_TEST(Credentials, DISABLE_ON_LSAN(CannotRegainPrivileges)) { |
| // The kernel should now prevent us from regaining capabilities because we |
| // are in a chroot. |
| - CHECK(!Credentials::SupportsNewUserNS()); |
| + errno = 0; |
| + CHECK_EQ(-1, unshare(CLONE_NEWUSER)); |
|
jln (very slow on Chromium)
2015/01/23 02:48:23
If we decide to not keep SupportsNewUserNS() under
rickyz (no longer on Chrome)
2015/01/23 23:59:37
Ended up keeping the function
|
| + CHECK_EQ(EPERM, errno); |
| + |
| + errno = 0; |
| + CHECK_EQ(-1, base::ForkWithFlags(CLONE_NEWUSER | SIGCHLD, nullptr, nullptr)); |
| + CHECK_EQ(EPERM, errno); |
| + |
| CHECK(!Credentials::MoveToNewUserNS()); |
| } |