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

Unified Diff: content/browser/renderer_host/sandbox_ipc_linux.cc

Issue 240463005: Stop using chrome-sandbox to determine real pids (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix an embarassing number of compile errors Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/sandbox_ipc_linux.cc
diff --git a/content/browser/renderer_host/sandbox_ipc_linux.cc b/content/browser/renderer_host/sandbox_ipc_linux.cc
index ad1747e01736ec41d009c825a9562f8b3b8708d0..aec32c0e9c6a290f606b00503ec43c331d0afa4f 100644
--- a/content/browser/renderer_host/sandbox_ipc_linux.cc
+++ b/content/browser/renderer_host/sandbox_ipc_linux.cc
@@ -158,6 +158,9 @@ void SandboxIPCProcess::Run() {
pfds[1].fd = browser_socket_;
pfds[1].events = POLLIN;
+ if (!UnixDomainSocket::EnableReceiveProcessId(browser_socket_))
+ LOG(FATAL) << "failed to enable receiving PIDs";
+
int failed_polls = 0;
for (;;) {
const int r = HANDLE_EINTR(poll(pfds, 2, -1 /* no timeout */));
@@ -187,6 +190,7 @@ void SandboxIPCProcess::Run() {
void SandboxIPCProcess::HandleRequestFromRenderer(int fd) {
std::vector<int> fds;
+ base::ProcessId sender_pid;
// A FontConfigIPC::METHOD_MATCH message could be kMaxFontFamilyLength
// bytes long (this is the largest message type).
@@ -194,7 +198,8 @@ void SandboxIPCProcess::HandleRequestFromRenderer(int fd) {
// error for a maximum length message.
char buf[FontConfigIPC::kMaxFontFamilyLength + 128];
- const ssize_t len = UnixDomainSocket::RecvMsg(fd, buf, sizeof(buf), &fds);
+ const ssize_t len =
+ UnixDomainSocket::RecvMsgWithPid(fd, buf, sizeof(buf), &fds, &sender_pid);
if (len == -1) {
// TODO: should send an error reply, or the sender might block forever.
NOTREACHED() << "Sandbox host message is larger than kMaxFontFamilyLength";
@@ -226,6 +231,8 @@ void SandboxIPCProcess::HandleRequestFromRenderer(int fd) {
HandleMakeSharedMemorySegment(fd, pickle, iter, fds);
} else if (kind == LinuxSandbox::METHOD_MATCH_WITH_FALLBACK) {
HandleMatchWithFallback(fd, pickle, iter, fds);
+ } else if (kind == LinuxSandbox::METHOD_GET_REAL_PID) {
+ HandleGetRealPid(fd, pickle, iter, fds, sender_pid);
}
error:
@@ -613,6 +620,29 @@ void SandboxIPCProcess::HandleMatchWithFallback(int fd,
}
}
+void SandboxIPCProcess::HandleGetRealPid(int fd,
+ const Pickle& pickle,
+ PickleIterator iter,
+ std::vector<int>& fds,
+ base::ProcessId sender_pid) {
+ if (fds.size() != 2)
+ return;
+
+ bool return_pid;
+ if (!iter.ReadBool(&return_pid))
+ return;
+
+ // Write it to the zygote process.
+ const ssize_t written =
+ HANDLE_EINTR(write(fds[1], &sender_pid, sizeof(sender_pid)));
+ if (written != sizeof(sender_pid))
+ LOG(ERROR) << "Failed to write real pid to zygote";
+
+ Pickle reply;
+ reply.WriteInt(return_pid ? sender_pid : 0);
+ SendRendererReply(fds, reply, -1);
+}
+
void SandboxIPCProcess::SendRendererReply(const std::vector<int>& fds,
const Pickle& reply,
int reply_fd) {
« no previous file with comments | « content/browser/renderer_host/sandbox_ipc_linux.h ('k') | content/browser/zygote_host/zygote_host_impl_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698