Utilities for communicating over SO_PASSCRED
enabled AF_UNIX
sockets.
More...
#include "util/linux/socket.h"
Utilities for communicating over SO_PASSCRED
enabled AF_UNIX
sockets.
◆ CreateCredentialSocketpair()
Creates an AF_UNIX
family socket pair with SO_PASSCRED
set on each socket.
- Parameters
-
[out] | s1 | One end of the connected pair. |
[out] | s2 | The other end of the connected pair. |
- Returns
true
on success. Otherwise, false
with a message logged.
◆ RecvMsg()
bool crashpad::UnixCredentialSocket::RecvMsg |
( |
int |
fd, |
|
|
void * |
buf, |
|
|
size_t |
buf_size, |
|
|
ucred * |
creds, |
|
|
std::vector< ScopedFileHandle > * |
fds = nullptr |
|
) |
| |
|
static |
Wraps recvmsg()
to receive a message with file descriptors and credentials.
This function is intended to be used with AF_UNIX
family sockets. Up to kMaxSendRecvMsgFDs
file descriptors may be received (via SCM_RIGHTS
). The socket must have SO_PASSCRED
set.
- Parameters
-
[in] | fd | The file descriptor to receive the message on. |
[out] | buf | The buffer to fill with the message. |
[in] | buf_size | The size of the message. |
[out] | creds | The credentials of the sender. |
[out] | fds | The recieved file descriptors. Optional. If nullptr , all received file descriptors will be closed. |
- Returns
true
on success. Otherwise, false
, with a message logged. No message will be logged if the message was detected to be an EOF condition triggered by all clients disconnecting. This case is indistinguishable from misuses of this interface that haven't set SO_PASSCRED
on fd.
◆ SendMsg()
int crashpad::UnixCredentialSocket::SendMsg |
( |
int |
fd, |
|
|
const void * |
buf, |
|
|
size_t |
buf_size, |
|
|
const int * |
fds = nullptr , |
|
|
size_t |
fd_count = 0 |
|
) |
| |
|
static |
Wraps sendmsg()
to send a message with file descriptors.
This function is intended for use with AF_UNIX
family sockets and passes file descriptors with SCM_RIGHTS
.
This function may be used in a compromised context.
- Parameters
-
[in] | fd | The file descriptor to write the message to. |
[in] | buf | The buffer containing the message. |
[in] | buf_size | The size of the message. |
[in] | fds | An array of at most kMaxSendRecvMsgFDs file descriptors. Optional. |
[in] | fd_count | The number of file descriptors in fds. Required only if fds was set. |
- Returns
- 0 on success or an error code on failure.
The documentation for this class was generated from the following files:
- util/linux/socket.h
- util/linux/socket.cc