GETPEEREID(2)

NAME
getpeereid - get the effective user ID and effective group ID of a peer connected through a Unix domain socket.

SYNOPSIS
#include <sys/socket.h>
int getpeereid(int sd, uid_t *euid, gid_t *egid);

DESCRIPTION
getpeereid() is often used to authenticate clients connecting to a server through a Unix domain socket. The server can call this function with a socket descriptor sd and this function will fill-in euid and egid with the effective user ID and the effective group ID of the client process.

RETURN VALUES
On success, this function returns 0, euid is set to the effective user ID of the peer connected through Unix domain socket sd, and egid is set to the effective group ID of the peer connected through Unix domain socket sd. On error, -1 is returned and errno is set.

ERRORS

[EBADF]
    The argument sd is not a descriptor.

[ENOTSOCK]
    The argument sd is a descriptor, but not a socket descriptor.

[EFAULT]
    The address pointed to by euid and/or egid is not in a valid part of the process address space.

SEE ALSO
socket(2), socketpair(2), unix(8)

HISTORY
This function first appeared in Minix 3.1.8.