OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ipc/unix_domain_socket_util.h" | 5 #include "ipc/unix_domain_socket_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
9 #include <sys/un.h> | 9 #include <sys/un.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 uid_t peer_euid; | 185 uid_t peer_euid; |
186 if (!GetPeerEuid(peer_fd, &peer_euid)) | 186 if (!GetPeerEuid(peer_fd, &peer_euid)) |
187 return false; | 187 return false; |
188 if (peer_euid != geteuid()) { | 188 if (peer_euid != geteuid()) { |
189 DLOG(ERROR) << "Client euid is not authorised"; | 189 DLOG(ERROR) << "Client euid is not authorised"; |
190 return false; | 190 return false; |
191 } | 191 } |
192 return true; | 192 return true; |
193 } | 193 } |
194 | 194 |
195 bool ServerAcceptConnection(int server_listen_fd, int* server_socket) { | 195 bool ServerOnConnect(int server_listen_fd, int* server_socket) { |
196 DCHECK(server_socket); | 196 DCHECK(server_socket); |
197 *server_socket = -1; | 197 *server_socket = -1; |
198 | 198 |
199 base::ScopedFD accept_fd(HANDLE_EINTR(accept(server_listen_fd, NULL, 0))); | 199 base::ScopedFD accept_fd(HANDLE_EINTR(accept(server_listen_fd, NULL, 0))); |
200 if (!accept_fd.is_valid()) | 200 if (!accept_fd.is_valid()) |
201 return IsRecoverableError(); | 201 return IsRecoverableError(); |
202 | 202 |
203 if (!base::SetNonBlocking(accept_fd.get())) { | 203 if (!base::SetNonBlocking(accept_fd.get())) { |
204 PLOG(ERROR) << "base::SetNonBlocking() failed " << accept_fd.get(); | 204 PLOG(ERROR) << "base::SetNonBlocking() failed " << accept_fd.get(); |
205 // It's safe to keep listening on |server_listen_fd| even if the attempt to | 205 // It's safe to keep listening on |server_listen_fd| even if the attempt to |
206 // set O_NONBLOCK failed on the client fd. | 206 // set O_NONBLOCK failed on the client fd. |
207 return true; | 207 return true; |
208 } | 208 } |
209 | 209 |
210 *server_socket = accept_fd.release(); | 210 *server_socket = accept_fd.release(); |
211 return true; | 211 return true; |
212 } | 212 } |
213 | 213 |
214 } // namespace IPC | 214 } // namespace IPC |
OLD | NEW |