Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: content/browser/zygote_main_linux.cc

Issue 9463029: Add an API around zygoteHost so that chrome doesn't reach into the internal content implementation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix clang Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/zygote_host_linux.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/zygote_host_linux.h" 5 #include "content/browser/zygote_host_impl_linux.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 <sys/socket.h> 10 #include <sys/socket.h>
11 #include <sys/stat.h> 11 #include <sys/stat.h>
12 #include <sys/types.h> 12 #include <sys/types.h>
13 #include <sys/wait.h> 13 #include <sys/wait.h>
14 #include <unistd.h> 14 #include <unistd.h>
15 15
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 PLOG(ERROR) << "Error reading message from browser"; 167 PLOG(ERROR) << "Error reading message from browser";
168 return false; 168 return false;
169 } 169 }
170 170
171 Pickle pickle(buf, len); 171 Pickle pickle(buf, len);
172 void* iter = NULL; 172 void* iter = NULL;
173 173
174 int kind; 174 int kind;
175 if (pickle.ReadInt(&iter, &kind)) { 175 if (pickle.ReadInt(&iter, &kind)) {
176 switch (kind) { 176 switch (kind) {
177 case ZygoteHost::kCmdFork: 177 case ZygoteHostImpl::kCmdFork:
178 // This function call can return multiple times, once per fork(). 178 // This function call can return multiple times, once per fork().
179 return HandleForkRequest(fd, pickle, iter, fds); 179 return HandleForkRequest(fd, pickle, iter, fds);
180 180
181 case ZygoteHost::kCmdReap: 181 case ZygoteHostImpl::kCmdReap:
182 if (!fds.empty()) 182 if (!fds.empty())
183 break; 183 break;
184 HandleReapRequest(fd, pickle, iter); 184 HandleReapRequest(fd, pickle, iter);
185 return false; 185 return false;
186 case ZygoteHost::kCmdGetTerminationStatus: 186 case ZygoteHostImpl::kCmdGetTerminationStatus:
187 if (!fds.empty()) 187 if (!fds.empty())
188 break; 188 break;
189 HandleGetTerminationStatus(fd, pickle, iter); 189 HandleGetTerminationStatus(fd, pickle, iter);
190 return false; 190 return false;
191 case ZygoteHost::kCmdGetSandboxStatus: 191 case ZygoteHostImpl::kCmdGetSandboxStatus:
192 HandleGetSandboxStatus(fd, pickle, iter); 192 HandleGetSandboxStatus(fd, pickle, iter);
193 return false; 193 return false;
194 default: 194 default:
195 NOTREACHED(); 195 NOTREACHED();
196 break; 196 break;
197 } 197 }
198 } 198 }
199 199
200 LOG(WARNING) << "Error parsing message from browser"; 200 LOG(WARNING) << "Error parsing message from browser";
201 for (std::vector<int>::const_iterator 201 for (std::vector<int>::const_iterator
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 839
840 // Turn on the SELinux or SUID sandbox 840 // Turn on the SELinux or SUID sandbox
841 if (!EnterSandbox()) { 841 if (!EnterSandbox()) {
842 LOG(FATAL) << "Failed to enter sandbox. Fail safe abort. (errno: " 842 LOG(FATAL) << "Failed to enter sandbox. Fail safe abort. (errno: "
843 << errno << ")"; 843 << errno << ")";
844 return false; 844 return false;
845 } 845 }
846 846
847 int sandbox_flags = 0; 847 int sandbox_flags = 0;
848 if (getenv("SBX_D")) 848 if (getenv("SBX_D"))
849 sandbox_flags |= ZygoteHost::kSandboxSUID; 849 sandbox_flags |= ZygoteHostImpl::kSandboxSUID;
850 if (getenv("SBX_PID_NS")) 850 if (getenv("SBX_PID_NS"))
851 sandbox_flags |= ZygoteHost::kSandboxPIDNS; 851 sandbox_flags |= ZygoteHostImpl::kSandboxPIDNS;
852 if (getenv("SBX_NET_NS")) 852 if (getenv("SBX_NET_NS"))
853 sandbox_flags |= ZygoteHost::kSandboxNetNS; 853 sandbox_flags |= ZygoteHostImpl::kSandboxNetNS;
854 854
855 #if defined(SECCOMP_SANDBOX) 855 #if defined(SECCOMP_SANDBOX)
856 // The seccomp sandbox will be turned on when the renderers start. But we can 856 // The seccomp sandbox will be turned on when the renderers start. But we can
857 // already check if sufficient support is available so that we only need to 857 // already check if sufficient support is available so that we only need to
858 // print one error message for the entire browser session. 858 // print one error message for the entire browser session.
859 if (g_proc_fd >= 0 && SeccompSandboxEnabled()) { 859 if (g_proc_fd >= 0 && SeccompSandboxEnabled()) {
860 if (!SupportsSeccompSandbox(g_proc_fd)) { 860 if (!SupportsSeccompSandbox(g_proc_fd)) {
861 // There are a good number of users who cannot use the seccomp sandbox 861 // There are a good number of users who cannot use the seccomp sandbox
862 // (e.g. because their distribution does not enable seccomp mode by 862 // (e.g. because their distribution does not enable seccomp mode by
863 // default). While we would prefer to deny execution in this case, it 863 // default). While we would prefer to deny execution in this case, it
864 // seems more realistic to continue in degraded mode. 864 // seems more realistic to continue in degraded mode.
865 LOG(ERROR) << "WARNING! This machine lacks support needed for the " 865 LOG(ERROR) << "WARNING! This machine lacks support needed for the "
866 "Seccomp sandbox. Running renderers with Seccomp " 866 "Seccomp sandbox. Running renderers with Seccomp "
867 "sandboxing disabled."; 867 "sandboxing disabled.";
868 } else { 868 } else {
869 VLOG(1) << "Enabling experimental Seccomp sandbox."; 869 VLOG(1) << "Enabling experimental Seccomp sandbox.";
870 sandbox_flags |= ZygoteHost::kSandboxSeccomp; 870 sandbox_flags |= ZygoteHostImpl::kSandboxSeccomp;
871 } 871 }
872 } 872 }
873 #endif // SECCOMP_SANDBOX 873 #endif // SECCOMP_SANDBOX
874 874
875 Zygote zygote(sandbox_flags, forkdelegate); 875 Zygote zygote(sandbox_flags, forkdelegate);
876 // This function call can return multiple times, once per fork(). 876 // This function call can return multiple times, once per fork().
877 return zygote.ProcessRequests(); 877 return zygote.ProcessRequests();
878 } 878 }
OLDNEW
« no previous file with comments | « content/browser/zygote_host_linux.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698