OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "sandbox/linux/syscall_broker/broker_process.h" | 5 #include "sandbox/linux/syscall_broker/broker_process.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <poll.h> | 9 #include <poll.h> |
10 #include <sys/resource.h> | 10 #include <sys/resource.h> |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 SANDBOX_ASSERT(ipc_fd >= 0); | 534 SANDBOX_ASSERT(ipc_fd >= 0); |
535 | 535 |
536 static const char kBogus[] = "not a pickle"; | 536 static const char kBogus[] = "not a pickle"; |
537 std::vector<int> fds; | 537 std::vector<int> fds; |
538 fds.push_back(message_fd.get()); | 538 fds.push_back(message_fd.get()); |
539 | 539 |
540 // The broker process should only have a couple spare file descriptors | 540 // The broker process should only have a couple spare file descriptors |
541 // available, but for good measure we send it fd_limit bogus IPCs anyway. | 541 // available, but for good measure we send it fd_limit bogus IPCs anyway. |
542 for (rlim_t i = 0; i < fd_limit; ++i) { | 542 for (rlim_t i = 0; i < fd_limit; ++i) { |
543 SANDBOX_ASSERT( | 543 SANDBOX_ASSERT( |
544 UnixDomainSocket::SendMsg(ipc_fd, kBogus, sizeof(kBogus), fds)); | 544 base::UnixDomainSocket::SendMsg(ipc_fd, kBogus, sizeof(kBogus), fds)); |
545 } | 545 } |
546 | 546 |
547 const int fd = open_broker.Open(kCpuInfo, O_RDONLY); | 547 const int fd = open_broker.Open(kCpuInfo, O_RDONLY); |
548 SANDBOX_ASSERT(fd >= 0); | 548 SANDBOX_ASSERT(fd >= 0); |
549 SANDBOX_ASSERT(0 == IGNORE_EINTR(close(fd))); | 549 SANDBOX_ASSERT(0 == IGNORE_EINTR(close(fd))); |
550 } | 550 } |
551 | 551 |
552 bool CloseFD(int fd) { | 552 bool CloseFD(int fd) { |
553 PCHECK(0 == IGNORE_EINTR(close(fd))); | 553 PCHECK(0 == IGNORE_EINTR(close(fd))); |
554 return true; | 554 return true; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 ssize_t len = HANDLE_EINTR(read(fd_check, buf, sizeof(buf))); | 647 ssize_t len = HANDLE_EINTR(read(fd_check, buf, sizeof(buf))); |
648 | 648 |
649 ASSERT_EQ(len, static_cast<ssize_t>(sizeof(kTestText))); | 649 ASSERT_EQ(len, static_cast<ssize_t>(sizeof(kTestText))); |
650 ASSERT_EQ(memcmp(kTestText, buf, sizeof(kTestText)), 0); | 650 ASSERT_EQ(memcmp(kTestText, buf, sizeof(kTestText)), 0); |
651 } | 651 } |
652 } | 652 } |
653 | 653 |
654 } // namespace syscall_broker | 654 } // namespace syscall_broker |
655 | 655 |
656 } // namespace sandbox | 656 } // namespace sandbox |
OLD | NEW |