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

Unified Diff: base/posix/unix_domain_socket_linux.h

Issue 241863002: Extend UnixDomainSocket::RecvMsg to return sender's PID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style guide doesn't allow default arguments and discourages unnecessary function overloading Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/posix/unix_domain_socket_linux.cc » ('j') | base/posix/unix_domain_socket_linux.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/posix/unix_domain_socket_linux.h
diff --git a/base/posix/unix_domain_socket_linux.h b/base/posix/unix_domain_socket_linux.h
index 66fb8bb1bf629894c5badb4564cf517a5e4ded71..c22dd46ceb1237ec979bd965e047316fcb3fe0bc 100644
--- a/base/posix/unix_domain_socket_linux.h
+++ b/base/posix/unix_domain_socket_linux.h
@@ -10,6 +10,7 @@
#include <vector>
#include "base/base_export.h"
+#include "base/process/process_handle.h"
class Pickle;
@@ -18,6 +19,9 @@ class BASE_EXPORT UnixDomainSocket {
// Maximum number of file descriptors that can be read by RecvMsg().
static const size_t kMaxFileDescriptors;
+ // Use to enable receiving pids in RecvMsg. Returns true if successful.
+ static bool EnableReceiveProcessId(int fd);
jln (very slow on Chromium) 2014/04/24 18:32:58 Perhaps make it clear that this should be used on
mdempsky 2014/04/24 19:00:34 Done.
+
// Use sendmsg to write the given msg and include a vector of file
// descriptors. Returns true if successful.
static bool SendMsg(int fd,
@@ -32,6 +36,15 @@ class BASE_EXPORT UnixDomainSocket {
size_t length,
std::vector<int>* fds);
+ // Same as RecvMsg above, but also returns the sender's PID (as seen from
+ // the caller's namespace). However, before using this function to receive
+ // PIDs, EnableReceiveProcessId() should be called on the socket.
+ static ssize_t RecvMsgWithPid(int fd,
+ void* msg,
+ size_t length,
+ std::vector<int>* fds,
+ base::ProcessId* pid);
+
// Perform a sendmsg/recvmsg pair.
// 1. This process creates a UNIX SEQPACKET socketpair. Using
// connection-oriented sockets (SEQPACKET or STREAM) is critical here,
@@ -70,7 +83,8 @@ class BASE_EXPORT UnixDomainSocket {
void* msg,
size_t length,
int flags,
- std::vector<int>* fds);
+ std::vector<int>* fds,
+ base::ProcessId* pid);
jln (very slow on Chromium) 2014/04/24 18:32:58 You didn't have to modify any caller? I was pretty
mdempsky 2014/04/24 19:00:34 It has 'private' visibility, so it's only used wit
};
#endif // BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_
« no previous file with comments | « no previous file | base/posix/unix_domain_socket_linux.cc » ('j') | base/posix/unix_domain_socket_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698