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

Side by Side Diff: ipc/unix_domain_socket_util.h

Issue 12386010: Implement IPC::ChannelFactory, a class that accept()s on a UNIX socket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: un-revert fix to tests Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_channel_proxy.cc ('k') | ipc/unix_domain_socket_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 <sys/types.h>
9
10 #include <string>
11
12 #include "ipc/ipc_export.h"
13
14 namespace base {
15 class FilePath;
16 } // namespace base
17
18 namespace IPC {
19
20 // Creates a UNIX-domain socket at |socket_name| and bind()s it, then listen()s
21 // on it. If successful, |server_listen_fd| will be set to the new file
22 // descriptor, and the function will return true. Otherwise returns false.
23 //
24 // This function also effectively performs `mkdir -p` on the dirname of
25 // |socket_name| to ensure that all the directories up to |socket_name| exist.
26 // As a result of which this function must be run on a thread that allows
27 // blocking I/O, e.g. the FILE thread in Chrome's browser process.
28 IPC_EXPORT bool CreateServerUnixDomainSocket(const base::FilePath& socket_name,
29 int* server_listen_fd);
30
31 // Opens a UNIX-domain socket at |socket_name| and connect()s to it. If
32 // successful, |client_socket| will be set to the new file descriptor, and the
33 // function will return true. Otherwise returns false.
34 IPC_EXPORT bool CreateClientUnixDomainSocket(const base::FilePath& socket_name,
35 int* client_socket);
36
37 // Gets the effective user ID of the other end of the UNIX-domain socket
38 // specified by |fd|. If successful, sets |peer_euid| to the uid, and returns
39 // true. Otherwise returns false.
40 IPC_EXPORT bool GetPeerEuid(int fd, uid_t* peer_euid);
41
42 // Checks that the process on the other end of the UNIX domain socket
43 // represented by |peer_fd| shares the same EUID as this process.
44 IPC_EXPORT bool IsPeerAuthorized(int peer_fd);
45
46 // Accepts a client attempting to connect to |server_listen_fd|, storing the
47 // new file descriptor for the connection in |server_socket|.
48 //
49 // Returns false if |server_listen_fd| encounters an unrecoverable error.
50 // Returns true if it's valid to keep listening on |server_listen_fd|. In this
51 // case, it's possible that a connection wasn't successfully established; then,
52 // |server_socket| will be set to -1.
53 IPC_EXPORT bool ServerAcceptConnection(int server_listen_fd,
54 int* server_socket);
55
56 // The maximum length of the name of a socket for MODE_NAMED_SERVER or
57 // MODE_NAMED_CLIENT if you want to pass in your own socket.
58 // The standard size on linux is 108, mac is 104. To maintain consistency
59 // across platforms we standardize on the smaller value.
60 static const size_t kMaxSocketNameLength = 104;
61
62 } // namespace IPC
63
64 #endif // IPC_UNIX_DOMAIN_SOCKET_UTIL_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_proxy.cc ('k') | ipc/unix_domain_socket_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698