GETPEEREID(3) | Library Functions Manual | GETPEEREID(3) |
getpeereid
— get
effective user and group identification of locally-connected peer
#include
<sys/types.h>
#include <sys/socket.h>
int
getpeereid
(int
s, uid_t *euid,
gid_t *egid);
getpeereid
()
returns the effective user ID and group ID of the peer connected to a
UNIX-domain socket (see
unix(4)). The argument
s must be of type SOCK_STREAM
or SOCK_SEQPACKET
.
One common use is for UNIX-domain servers to determine the credentials of clients that have connected to it.
getpeereid
()
takes three parameters:
uid_t
variable into which the effective user ID for the connected peer will be
stored.gid_t
variable into which the effective group ID for the connected peer will be
stored.If the call succeeds, a 0 is returned and euid and egid are set to the effective user ID and group ID of the connected peer. Otherwise, errno is set and a value of -1 is returned.
On failure, errno is set to one of the following:
EBADF
]ENOTSOCK
]EOPNOTSUPP
]ENOTCONN
]ENOBUFS
]accept(2), bind(2), getpeername(2), getsockname(2), getsockopt(2), socket(2), unix(4)
The getpeereid
() function call appeared in
OpenBSD 3.0.
June 5, 2013 | OpenBSD-6.4 |