Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef IPC_UNIX_DOMAIN_SOCKET_UTIL_H_ | |
| 6 #define IPC_UNIX_DOMAIN_SOCKET_UTIL_H_ | |
| 7 | |
| 8 #include <string> | |
|
Mark Mentovai
2013/03/06 19:34:04
C system headers precede C++ system headers, so <s
jeremya
2013/03/06 21:46:01
Done.
| |
| 9 #include <sys/types.h> | |
| 10 | |
| 11 namespace base { | |
| 12 class FilePath; | |
| 13 } // namespace base | |
| 14 | |
| 15 namespace IPC { | |
| 16 | |
| 17 // Creates a UNIX-domain socket at |socket_name| and bind()s it, then listen()s | |
| 18 // on it. If successful, |server_listen_fd| will be set to the new file | |
| 19 // descriptor, and the function will return true. Otherwise returns false. | |
| 20 bool CreateServerUnixDomainSocket(const base::FilePath& socket_name, | |
| 21 int* server_listen_fd); | |
| 22 | |
| 23 // Opens a UNIX-domain socket at |socket_name| and connect()s to it. If | |
| 24 // successful, |client_socket| will be set to the new file descriptor, and the | |
| 25 // function will return true. Otherwise returns false. | |
| 26 bool CreateClientUnixDomainSocket(const base::FilePath& socket_name, | |
| 27 int* client_socket); | |
| 28 | |
| 29 // Gets the effective user ID of the other end of the UNIX-domain socket | |
| 30 // specified by |fd|. If successful, sets |client_euid| to the uid, and returns | |
| 31 // true. Otherwise returns false. | |
| 32 bool GetPeerEuid(int fd, uid_t* client_euid); | |
| 33 | |
| 34 // Checks that |peer_fd| belongs to the same user as the running process. | |
|
Mark Mentovai
2013/03/06 19:34:04
“belongs to” is ambiguous. “Checks that the proces
jeremya
2013/03/06 21:46:01
New comment:
// Checks that the process on the oth
| |
| 35 bool IsPeerAuthorized(int peer_fd); | |
| 36 | |
| 37 // Accepts a client attempting to connect to |server_listen_fd|, storing the | |
| 38 // new file descriptor for the connection in |server_socket|. | |
| 39 // | |
| 40 // Returns false if |server_listen_fd| encounters an unrecoverable error. | |
| 41 // Returns true if it's valid to keep listening on |server_listen_fd|. In this | |
| 42 // case, it's possible that a connection wasn't successfully established; then, | |
| 43 // |server_socket| will be set to -1. | |
| 44 bool ServerAcceptConnection(int server_listen_fd, int* server_socket); | |
| 45 | |
| 46 // The maximum length of the name of a socket for MODE_NAMED_SERVER or | |
| 47 // MODE_NAMED_CLIENT if you want to pass in your own socket. | |
| 48 // The standard size on linux is 108, mac is 104. To maintain consistency | |
| 49 // across platforms we standardize on the smaller value. | |
| 50 static const size_t kMaxSocketNameLength = 104; | |
| 51 | |
| 52 } // namespace IPC | |
| 53 | |
| 54 #endif // IPC_UNIX_DOMAIN_SOCKET_UTIL_H_ | |
| OLD | NEW |