| 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 "content/zygote/zygote_main.h" | 5 #include "content/zygote/zygote_main.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <signal.h> | 10 #include <signal.h> |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, | 93 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, |
| 94 char* timezone_out, | 94 char* timezone_out, |
| 95 size_t timezone_out_len) { | 95 size_t timezone_out_len) { |
| 96 Pickle request; | 96 Pickle request; |
| 97 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); | 97 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); |
| 98 request.WriteString( | 98 request.WriteString( |
| 99 std::string(reinterpret_cast<char*>(&input), sizeof(input))); | 99 std::string(reinterpret_cast<char*>(&input), sizeof(input))); |
| 100 | 100 |
| 101 uint8_t reply_buf[512]; | 101 uint8_t reply_buf[512]; |
| 102 const ssize_t r = UnixDomainSocket::SendRecvMsg( | 102 const ssize_t r = base::UnixDomainSocket::SendRecvMsg( |
| 103 GetSandboxFD(), reply_buf, sizeof(reply_buf), NULL, | 103 GetSandboxFD(), reply_buf, sizeof(reply_buf), NULL, request); |
| 104 request); | |
| 105 if (r == -1) { | 104 if (r == -1) { |
| 106 memset(output, 0, sizeof(struct tm)); | 105 memset(output, 0, sizeof(struct tm)); |
| 107 return; | 106 return; |
| 108 } | 107 } |
| 109 | 108 |
| 110 Pickle reply(reinterpret_cast<char*>(reply_buf), r); | 109 Pickle reply(reinterpret_cast<char*>(reply_buf), r); |
| 111 PickleIterator iter(reply); | 110 PickleIterator iter(reply); |
| 112 std::string result, timezone; | 111 std::string result, timezone; |
| 113 if (!iter.ReadString(&result) || | 112 if (!iter.ReadString(&result) || |
| 114 !iter.ReadString(&timezone) || | 113 !iter.ReadString(&timezone) || |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 sandbox::NamespaceSandbox::InNewUserNamespace(); | 549 sandbox::NamespaceSandbox::InNewUserNamespace(); |
| 551 const bool using_layer1_sandbox = | 550 const bool using_layer1_sandbox = |
| 552 using_setuid_sandbox || using_namespace_sandbox; | 551 using_setuid_sandbox || using_namespace_sandbox; |
| 553 | 552 |
| 554 if (using_setuid_sandbox) { | 553 if (using_setuid_sandbox) { |
| 555 linux_sandbox->setuid_sandbox_client()->CloseDummyFile(); | 554 linux_sandbox->setuid_sandbox_client()->CloseDummyFile(); |
| 556 } | 555 } |
| 557 | 556 |
| 558 if (using_layer1_sandbox) { | 557 if (using_layer1_sandbox) { |
| 559 // Let the ZygoteHost know we're booting up. | 558 // Let the ZygoteHost know we're booting up. |
| 560 CHECK(UnixDomainSocket::SendMsg(kZygoteSocketPairFd, | 559 CHECK(base::UnixDomainSocket::SendMsg(kZygoteSocketPairFd, |
| 561 kZygoteBootMessage, | 560 kZygoteBootMessage, |
| 562 sizeof(kZygoteBootMessage), | 561 sizeof(kZygoteBootMessage), |
| 563 std::vector<int>())); | 562 std::vector<int>())); |
| 564 } | 563 } |
| 565 | 564 |
| 566 VLOG(1) << "ZygoteMain: initializing " << fork_delegates.size() | 565 VLOG(1) << "ZygoteMain: initializing " << fork_delegates.size() |
| 567 << " fork delegates"; | 566 << " fork delegates"; |
| 568 for (ZygoteForkDelegate* fork_delegate : fork_delegates) { | 567 for (ZygoteForkDelegate* fork_delegate : fork_delegates) { |
| 569 fork_delegate->Init(GetSandboxFD(), using_layer1_sandbox); | 568 fork_delegate->Init(GetSandboxFD(), using_layer1_sandbox); |
| 570 } | 569 } |
| 571 | 570 |
| 572 const std::vector<int> sandbox_fds_to_close_post_fork = | 571 const std::vector<int> sandbox_fds_to_close_post_fork = |
| 573 linux_sandbox->GetFileDescriptorsToClose(); | 572 linux_sandbox->GetFileDescriptorsToClose(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; | 609 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; |
| 611 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); | 610 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); |
| 612 | 611 |
| 613 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, | 612 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, |
| 614 extra_fds); | 613 extra_fds); |
| 615 // This function call can return multiple times, once per fork(). | 614 // This function call can return multiple times, once per fork(). |
| 616 return zygote.ProcessRequests(); | 615 return zygote.ProcessRequests(); |
| 617 } | 616 } |
| 618 | 617 |
| 619 } // namespace content | 618 } // namespace content |
| OLD | NEW |