| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/zygote_host_linux.h" | 5 #include "chrome/browser/zygote_host_linux.h" |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 ZygoteHost::ZygoteHost() { | 48 ZygoteHost::ZygoteHost() { |
| 49 std::wstring chrome_path; | 49 std::wstring chrome_path; |
| 50 CHECK(PathService::Get(base::FILE_EXE, &chrome_path)); | 50 CHECK(PathService::Get(base::FILE_EXE, &chrome_path)); |
| 51 CommandLine cmd_line(chrome_path); | 51 CommandLine cmd_line(chrome_path); |
| 52 | 52 |
| 53 cmd_line.AppendSwitchWithValue(switches::kProcessType, | 53 cmd_line.AppendSwitchWithValue(switches::kProcessType, |
| 54 switches::kZygoteProcess); | 54 switches::kZygoteProcess); |
| 55 | 55 |
| 56 int fds[2]; | 56 int fds[2]; |
| 57 |
| 58 // SOCK_SEQPACKET is used rather than SOCK_DGRAM because SOCK_DGRAM |
| 59 // allows sendto()/sendmsg() to send to arbitrary addresses, and the |
| 60 // SUID sandbox cannot prevent that. Apart from this security |
| 61 // problem, SOCK_DGRAM also has the correct semantics for this |
| 62 // socket pair. |
| 57 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); | 63 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); |
| 64 |
| 58 base::file_handle_mapping_vector fds_to_map; | 65 base::file_handle_mapping_vector fds_to_map; |
| 59 fds_to_map.push_back(std::make_pair(fds[1], 3)); | 66 fds_to_map.push_back(std::make_pair(fds[1], 3)); |
| 60 | 67 |
| 61 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 68 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 62 if (browser_command_line.HasSwitch(switches::kZygoteCmdPrefix)) { | 69 if (browser_command_line.HasSwitch(switches::kZygoteCmdPrefix)) { |
| 63 const std::wstring prefix = | 70 const std::wstring prefix = |
| 64 browser_command_line.GetSwitchValue(switches::kZygoteCmdPrefix); | 71 browser_command_line.GetSwitchValue(switches::kZygoteCmdPrefix); |
| 65 cmd_line.PrependWrapper(prefix); | 72 cmd_line.PrependWrapper(prefix); |
| 66 } | 73 } |
| 67 // Append any switches from the browser process that need to be forwarded on | 74 // Append any switches from the browser process that need to be forwarded on |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 !read_pickle.ReadBool(&iter, &tmp_child_exited)) { | 204 !read_pickle.ReadBool(&iter, &tmp_child_exited)) { |
| 198 LOG(WARNING) << "Error parsing DidProcessCrash response from zygote."; | 205 LOG(WARNING) << "Error parsing DidProcessCrash response from zygote."; |
| 199 return false; | 206 return false; |
| 200 } | 207 } |
| 201 | 208 |
| 202 if (child_exited) | 209 if (child_exited) |
| 203 *child_exited = tmp_child_exited; | 210 *child_exited = tmp_child_exited; |
| 204 | 211 |
| 205 return did_crash; | 212 return did_crash; |
| 206 } | 213 } |
| OLD | NEW |