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

Side by Side Diff: mojo/edk/embedder/platform_channel_utils_posix.cc

Issue 2500263004: Remove ipc/unix_domain_socket_util.* (Closed)
Patch Set: rebase Created 4 years, 1 month 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
« no previous file with comments | « mojo/edk/embedder/platform_channel_utils_posix.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/edk/embedder/platform_channel_utils_posix.h" 5 #include "mojo/edk/embedder/platform_channel_utils_posix.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <sys/socket.h> 8 #include <sys/socket.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 platform_handles->push_back(PlatformHandle(fds[i])); 240 platform_handles->push_back(PlatformHandle(fds[i]));
241 DCHECK(platform_handles->back().is_valid()); 241 DCHECK(platform_handles->back().is_valid());
242 } 242 }
243 } 243 }
244 } 244 }
245 245
246 return result; 246 return result;
247 } 247 }
248 248
249 bool ServerAcceptConnection(PlatformHandle server_handle, 249 bool ServerAcceptConnection(PlatformHandle server_handle,
250 ScopedPlatformHandle* connection_handle) { 250 ScopedPlatformHandle* connection_handle,
251 bool check_peer_user) {
251 DCHECK(server_handle.is_valid()); 252 DCHECK(server_handle.is_valid());
252 connection_handle->reset(); 253 connection_handle->reset();
253 #if defined(OS_NACL) 254 #if defined(OS_NACL)
254 NOTREACHED(); 255 NOTREACHED();
255 return false; 256 return false;
256 #else 257 #else
257 ScopedPlatformHandle accept_handle( 258 ScopedPlatformHandle accept_handle(
258 PlatformHandle(HANDLE_EINTR(accept(server_handle.handle, NULL, 0)))); 259 PlatformHandle(HANDLE_EINTR(accept(server_handle.handle, NULL, 0))));
259 if (!accept_handle.is_valid()) 260 if (!accept_handle.is_valid())
260 return IsRecoverableError(); 261 return IsRecoverableError();
261 262
262 // Verify that the IPC channel peer is running as the same user. 263 // Verify that the IPC channel peer is running as the same user.
263 if (!IsPeerAuthorized(accept_handle.get())) { 264 if (check_peer_user && !IsPeerAuthorized(accept_handle.get())) {
264 return true; 265 return true;
265 } 266 }
266 267
267 if (!base::SetNonBlocking(accept_handle.get().handle)) { 268 if (!base::SetNonBlocking(accept_handle.get().handle)) {
268 PLOG(ERROR) << "base::SetNonBlocking() failed " 269 PLOG(ERROR) << "base::SetNonBlocking() failed "
269 << accept_handle.get().handle; 270 << accept_handle.get().handle;
270 // It's safe to keep listening on |server_handle| even if the attempt to set 271 // It's safe to keep listening on |server_handle| even if the attempt to set
271 // O_NONBLOCK failed on the client fd. 272 // O_NONBLOCK failed on the client fd.
272 return true; 273 return true;
273 } 274 }
274 275
275 *connection_handle = std::move(accept_handle); 276 *connection_handle = std::move(accept_handle);
276 return true; 277 return true;
277 #endif // defined(OS_NACL) 278 #endif // defined(OS_NACL)
278 } 279 }
279 280
280 } // namespace edk 281 } // namespace edk
281 } // namespace mojo 282 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/embedder/platform_channel_utils_posix.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698