diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-15 13:35:06 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-15 13:35:06 +0000 |
commit | b0df57cf1f90cd46703023be0f6ab8c6175f7771 (patch) | |
tree | 7bd956e684159a29e115d56fafd1583a74c645f1 /sandbox/linux | |
parent | e387e46fd352bf8baa35c403f9c95905ade0feda (diff) | |
download | chromium_src-b0df57cf1f90cd46703023be0f6ab8c6175f7771.zip chromium_src-b0df57cf1f90cd46703023be0f6ab8c6175f7771.tar.gz chromium_src-b0df57cf1f90cd46703023be0f6ab8c6175f7771.tar.bz2 |
Revert of Implement ScopedFD in terms of ScopedGeneric. (https://codereview.chromium.org/191673003/)
Reason for revert:
Doesn't correctly link
/mnt/data/b/build/slave/Chromium_Linux_Codesearch/build/src/third_party/gold/gold64: warning: hidden symbol 'base::internal::ScopedFDCloseTraits::Free(int)' in obj/base/files/nacl_helper.scoped_file.o is referenced by DSO lib/libipc.so
Original issue's description:
> Implement ScopedFD in terms of ScopedGeneric.
>
> Move to a new file base/files/scoped_file.h. I will also add ScopedFILE to here (currently in file_util.h) later.
>
> I think there is a crash in the old code in content/browser/zygote_host/zygote_host_impl_linux.cc that this patch should fix. The old ScopedFD took the address of something in a vector that is being modified.
>
> I removed SafeScopedFD from content/common/sandbox_linux/sandbox_linux.cc since base's ScopedFD not CHECKs on close failure (this is a more recent addition).
>
> BUG=
> R=agl@chromium.org, viettrungluu@chromium.org
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=257001
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=257179
TBR=viettrungluu@chromium.org,agl@chromium.org,brettw@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=
Review URL: https://codereview.chromium.org/201203002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257323 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/linux')
-rw-r--r-- | sandbox/linux/services/broker_process_unittest.cc | 9 | ||||
-rw-r--r-- | sandbox/linux/services/credentials_unittest.cc | 9 | ||||
-rw-r--r-- | sandbox/linux/services/scoped_process_unittest.cc | 11 | ||||
-rw-r--r-- | sandbox/linux/services/yama.cc | 8 |
4 files changed, 19 insertions, 18 deletions
diff --git a/sandbox/linux/services/broker_process_unittest.cc b/sandbox/linux/services/broker_process_unittest.cc index 7f1a685..771790a 100644 --- a/sandbox/linux/services/broker_process_unittest.cc +++ b/sandbox/linux/services/broker_process_unittest.cc @@ -17,7 +17,6 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/file_util.h" -#include "base/files/scoped_file.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/posix/eintr_wrapper.h" @@ -25,6 +24,8 @@ #include "sandbox/linux/tests/unit_tests.h" #include "testing/gtest/include/gtest/gtest.h" +using file_util::ScopedFD; + namespace sandbox { namespace { @@ -268,7 +269,7 @@ void TestOpenCpuinfo(bool fast_check_in_client) { int fd = -1; fd = open_broker->Open(kFileCpuInfo, O_RDWR); - base::ScopedFD fd_closer(fd); + ScopedFD fd_closer(&fd); ASSERT_EQ(fd, -EPERM); // Check we can read /proc/cpuinfo. @@ -280,7 +281,7 @@ void TestOpenCpuinfo(bool fast_check_in_client) { // Open cpuinfo via the broker. int cpuinfo_fd = open_broker->Open(kFileCpuInfo, O_RDONLY); - base::ScopedFD cpuinfo_fd_closer(cpuinfo_fd); + ScopedFD cpuinfo_fd_closer(&cpuinfo_fd); ASSERT_GE(cpuinfo_fd, 0); char buf[3]; memset(buf, 0, sizeof(buf)); @@ -289,7 +290,7 @@ void TestOpenCpuinfo(bool fast_check_in_client) { // Open cpuinfo directly. int cpuinfo_fd2 = open(kFileCpuInfo, O_RDONLY); - base::ScopedFD cpuinfo_fd2_closer(cpuinfo_fd2); + ScopedFD cpuinfo_fd2_closer(&cpuinfo_fd2); ASSERT_GE(cpuinfo_fd2, 0); char buf2[3]; memset(buf2, 1, sizeof(buf2)); diff --git a/sandbox/linux/services/credentials_unittest.cc b/sandbox/linux/services/credentials_unittest.cc index a54ed04..9b792aa 100644 --- a/sandbox/linux/services/credentials_unittest.cc +++ b/sandbox/linux/services/credentials_unittest.cc @@ -12,12 +12,13 @@ #include <unistd.h> #include "base/file_util.h" -#include "base/files/scoped_file.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "sandbox/linux/tests/unit_tests.h" #include "testing/gtest/include/gtest/gtest.h" +using file_util::ScopedFD; + namespace sandbox { namespace { @@ -64,7 +65,7 @@ TEST(Credentials, HasOpenDirectory) { { // Have a "/dev" file descriptor around. int dev_fd = open("/dev", O_RDONLY | O_DIRECTORY); - base::ScopedFD dev_fd_closer(dev_fd); + ScopedFD dev_fd_closer(&dev_fd); EXPECT_TRUE(creds.HasOpenDirectory(-1)); } EXPECT_FALSE(creds.HasOpenDirectory(-1)); @@ -74,7 +75,7 @@ TEST(Credentials, HasOpenDirectoryWithFD) { Credentials creds; int proc_fd = open("/proc", O_RDONLY | O_DIRECTORY); - base::ScopedFD proc_fd_closer(proc_fd); + ScopedFD proc_fd_closer(&proc_fd); ASSERT_LE(0, proc_fd); // Don't pass |proc_fd|, an open directory (proc_fd) should @@ -86,7 +87,7 @@ TEST(Credentials, HasOpenDirectoryWithFD) { { // Have a "/dev" file descriptor around. int dev_fd = open("/dev", O_RDONLY | O_DIRECTORY); - base::ScopedFD dev_fd_closer(dev_fd); + ScopedFD dev_fd_closer(&dev_fd); EXPECT_TRUE(creds.HasOpenDirectory(proc_fd)); } diff --git a/sandbox/linux/services/scoped_process_unittest.cc b/sandbox/linux/services/scoped_process_unittest.cc index 2800bd7..7ae82bf8 100644 --- a/sandbox/linux/services/scoped_process_unittest.cc +++ b/sandbox/linux/services/scoped_process_unittest.cc @@ -13,7 +13,6 @@ #include "base/bind.h" #include "base/callback.h" #include "base/file_util.h" -#include "base/files/scoped_file.h" #include "base/logging.h" #include "base/posix/eintr_wrapper.h" #include "base/threading/platform_thread.h" @@ -74,13 +73,13 @@ TEST(ScopedProcess, ScopedProcessSignaled) { TEST(ScopedProcess, DiesForReal) { int pipe_fds[2]; ASSERT_EQ(0, pipe(pipe_fds)); - base::ScopedFD read_end_closer(pipe_fds[0]); - base::ScopedFD write_end_closer(pipe_fds[1]); + file_util::ScopedFDCloser read_end_closer(pipe_fds); + file_util::ScopedFDCloser write_end_closer(pipe_fds + 1); { ScopedProcess process(base::Bind(&DoExit)); } // Close writing end of the pipe. - write_end_closer.reset(); + ASSERT_EQ(0, IGNORE_EINTR(close(pipe_fds[1]))); pipe_fds[1] = -1; ASSERT_EQ(0, fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK)); @@ -109,8 +108,8 @@ void SleepInMsAndWriteOneByte(int time_to_sleep, int fd) { TEST(ScopedProcess, SynchronizationWorks) { int pipe_fds[2]; ASSERT_EQ(0, pipe(pipe_fds)); - base::ScopedFD read_end_closer(pipe_fds[0]); - base::ScopedFD write_end_closer(pipe_fds[1]); + file_util::ScopedFDCloser read_end_closer(pipe_fds); + file_util::ScopedFDCloser write_end_closer(pipe_fds + 1); // Start a process with a closure that takes a little bit to run. ScopedProcess process( diff --git a/sandbox/linux/services/yama.cc b/sandbox/linux/services/yama.cc index 39ac079..efb261c 100644 --- a/sandbox/linux/services/yama.cc +++ b/sandbox/linux/services/yama.cc @@ -12,7 +12,6 @@ #include "base/basictypes.h" #include "base/file_util.h" -#include "base/files/scoped_file.h" #include "base/logging.h" #include "base/posix/eintr_wrapper.h" @@ -79,17 +78,18 @@ int Yama::GetStatus() { static const char kPtraceScopePath[] = "/proc/sys/kernel/yama/ptrace_scope"; - base::ScopedFD yama_scope(open(kPtraceScopePath, O_RDONLY)); + int yama_scope = open(kPtraceScopePath, O_RDONLY); - if (!yama_scope.is_valid()) { + if (yama_scope < 0) { const int open_errno = errno; DCHECK(ENOENT == open_errno); // The status is known, yama is not present. return STATUS_KNOWN; } + file_util::ScopedFDCloser yama_scope_closer(&yama_scope); char yama_scope_value = 0; - ssize_t num_read = read(yama_scope.get(), &yama_scope_value, 1); + ssize_t num_read = read(yama_scope, &yama_scope_value, 1); PCHECK(1 == num_read); switch (yama_scope_value) { |