Index: ipc/unix_domain_socket_util.h |
diff --git a/ipc/unix_domain_socket_util.h b/ipc/unix_domain_socket_util.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..44099df44de17e5a02344cb737515274f33ebf27 |
--- /dev/null |
+++ b/ipc/unix_domain_socket_util.h |
@@ -0,0 +1,54 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef IPC_UNIX_DOMAIN_SOCKET_UTIL_H_ |
+#define IPC_UNIX_DOMAIN_SOCKET_UTIL_H_ |
+ |
+#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.
|
+#include <sys/types.h> |
+ |
+namespace base { |
+class FilePath; |
+} // namespace base |
+ |
+namespace IPC { |
+ |
+// Creates a UNIX-domain socket at |socket_name| and bind()s it, then listen()s |
+// on it. If successful, |server_listen_fd| will be set to the new file |
+// descriptor, and the function will return true. Otherwise returns false. |
+bool CreateServerUnixDomainSocket(const base::FilePath& socket_name, |
+ int* server_listen_fd); |
+ |
+// Opens a UNIX-domain socket at |socket_name| and connect()s to it. If |
+// successful, |client_socket| will be set to the new file descriptor, and the |
+// function will return true. Otherwise returns false. |
+bool CreateClientUnixDomainSocket(const base::FilePath& socket_name, |
+ int* client_socket); |
+ |
+// Gets the effective user ID of the other end of the UNIX-domain socket |
+// specified by |fd|. If successful, sets |client_euid| to the uid, and returns |
+// true. Otherwise returns false. |
+bool GetPeerEuid(int fd, uid_t* client_euid); |
+ |
+// 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
|
+bool IsPeerAuthorized(int peer_fd); |
+ |
+// Accepts a client attempting to connect to |server_listen_fd|, storing the |
+// new file descriptor for the connection in |server_socket|. |
+// |
+// Returns false if |server_listen_fd| encounters an unrecoverable error. |
+// Returns true if it's valid to keep listening on |server_listen_fd|. In this |
+// case, it's possible that a connection wasn't successfully established; then, |
+// |server_socket| will be set to -1. |
+bool ServerAcceptConnection(int server_listen_fd, int* server_socket); |
+ |
+// The maximum length of the name of a socket for MODE_NAMED_SERVER or |
+// MODE_NAMED_CLIENT if you want to pass in your own socket. |
+// The standard size on linux is 108, mac is 104. To maintain consistency |
+// across platforms we standardize on the smaller value. |
+static const size_t kMaxSocketNameLength = 104; |
+ |
+} // namespace IPC |
+ |
+#endif // IPC_UNIX_DOMAIN_SOCKET_UTIL_H_ |