Documentation
¶
Overview ¶
Package peercred reads who is at the other end of a Unix socket, as the kernel recorded it when the peer connected: its credentials, and where the kernel gives one a pidfd, which keeps naming that process after its pid has been reused.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoPIDFD = errors.New("the kernel has no SO_PEERPIDFD")
ErrNoPIDFD is what PIDFDOf wraps on a kernel without SO_PEERPIDFD (before Linux 6.5): the peer is known by its Credentials alone.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
Credentials are the ids of the process at a socket's other end, from SO_PEERCRED.
func Of ¶
func Of(conn *net.UnixConn) (Credentials, error)
Of reads the credentials of the process at conn's other end.
func OfFD ¶
func OfFD(fd int) (Credentials, error)
OfFD reads the credentials of the process at the other end of the connected Unix socket fd, for a caller that holds the raw descriptor rather than a net.UnixConn.
type PIDFD ¶
type PIDFD struct {
// contains filtered or unexported fields
}
PIDFD is a pidfd of the process at a socket's other end, with that process's credentials. Unlike its pid it names that one process for as long as it is held, whatever the pid is reused for.
func PIDFDOf ¶
PIDFDOf opens a pidfd of the process at conn's other end, for the caller to Close. A kernel without SO_PEERPIDFD is ErrNoPIDFD: there Of still says who the peer is.
func (*PIDFD) Credentials ¶
func (p *PIDFD) Credentials() Credentials
Credentials are the ids of the process the pidfd names, as Of reads them.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package peercredtest gives a test a socket peer that is another process, with a pid and a lifetime of its own: what telling a peer from the test itself, or outliving it, needs.
|
Package peercredtest gives a test a socket peer that is another process, with a pid and a lifetime of its own: what telling a peer from the test itself, or outliving it, needs. |