| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <sys/socket.h> | 7 #include <sys/socket.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 using_suid_sandbox_(false), | 59 using_suid_sandbox_(false), |
| 60 have_read_sandbox_status_word_(false), | 60 have_read_sandbox_status_word_(false), |
| 61 sandbox_status_(0) { | 61 sandbox_status_(0) { |
| 62 } | 62 } |
| 63 | 63 |
| 64 ZygoteHost::~ZygoteHost() { | 64 ZygoteHost::~ZygoteHost() { |
| 65 if (init_) | 65 if (init_) |
| 66 close(control_fd_); | 66 close(control_fd_); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // static |
| 70 ZygoteHost* ZygoteHost::GetInstance() { |
| 71 return Singleton<ZygoteHost>::get(); |
| 72 } |
| 73 |
| 69 void ZygoteHost::Init(const std::string& sandbox_cmd) { | 74 void ZygoteHost::Init(const std::string& sandbox_cmd) { |
| 70 DCHECK(!init_); | 75 DCHECK(!init_); |
| 71 init_ = true; | 76 init_ = true; |
| 72 | 77 |
| 73 FilePath chrome_path; | 78 FilePath chrome_path; |
| 74 CHECK(PathService::Get(base::FILE_EXE, &chrome_path)); | 79 CHECK(PathService::Get(base::FILE_EXE, &chrome_path)); |
| 75 CommandLine cmd_line(chrome_path); | 80 CommandLine cmd_line(chrome_path); |
| 76 | 81 |
| 77 cmd_line.AppendSwitchASCII(switches::kProcessType, switches::kZygoteProcess); | 82 cmd_line.AppendSwitchASCII(switches::kProcessType, switches::kZygoteProcess); |
| 78 | 83 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } else { | 127 } else { |
| 123 LOG(FATAL) << "The SUID sandbox helper binary was found, but is not " | 128 LOG(FATAL) << "The SUID sandbox helper binary was found, but is not " |
| 124 "configured correctly. Rather than run without sandboxing " | 129 "configured correctly. Rather than run without sandboxing " |
| 125 "I'm aborting now. You need to make sure that " | 130 "I'm aborting now. You need to make sure that " |
| 126 << sandbox_binary_ << " is mode 4755 and owned by root."; | 131 << sandbox_binary_ << " is mode 4755 and owned by root."; |
| 127 } | 132 } |
| 128 } | 133 } |
| 129 | 134 |
| 130 // Start up the sandbox host process and get the file descriptor for the | 135 // Start up the sandbox host process and get the file descriptor for the |
| 131 // renderers to talk to it. | 136 // renderers to talk to it. |
| 132 const int sfd = Singleton<RenderSandboxHostLinux>()->GetRendererSocket(); | 137 const int sfd = RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); |
| 133 fds_to_map.push_back(std::make_pair(sfd, 5)); | 138 fds_to_map.push_back(std::make_pair(sfd, 5)); |
| 134 | 139 |
| 135 int dummy_fd = -1; | 140 int dummy_fd = -1; |
| 136 if (using_suid_sandbox_) { | 141 if (using_suid_sandbox_) { |
| 137 dummy_fd = socket(PF_UNIX, SOCK_DGRAM, 0); | 142 dummy_fd = socket(PF_UNIX, SOCK_DGRAM, 0); |
| 138 CHECK(dummy_fd >= 0); | 143 CHECK(dummy_fd >= 0); |
| 139 fds_to_map.push_back(std::make_pair(dummy_fd, 7)); | 144 fds_to_map.push_back(std::make_pair(dummy_fd, 7)); |
| 140 } | 145 } |
| 141 | 146 |
| 142 base::ProcessHandle process; | 147 base::ProcessHandle process; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 !read_pickle.ReadBool(&iter, &tmp_child_exited)) { | 349 !read_pickle.ReadBool(&iter, &tmp_child_exited)) { |
| 345 LOG(WARNING) << "Error parsing DidProcessCrash response from zygote."; | 350 LOG(WARNING) << "Error parsing DidProcessCrash response from zygote."; |
| 346 return false; | 351 return false; |
| 347 } | 352 } |
| 348 | 353 |
| 349 if (child_exited) | 354 if (child_exited) |
| 350 *child_exited = tmp_child_exited; | 355 *child_exited = tmp_child_exited; |
| 351 | 356 |
| 352 return did_crash; | 357 return did_crash; |
| 353 } | 358 } |
| OLD | NEW |