Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
GETPEEREID(2)             OpenBSD Programmer's Manual            GETPEEREID(2)

NAME
     getpeereid - get effective user and group identification of locally-con-
     nected peer

SYNOPSIS
     #include <sys/types.h>
     #include <sys/socket.h>

     int
     getpeereid(int s, uid_t *euid, gid_t *egid);

DESCRIPTION
     getpeereid() returns the effective user ID and group ID of the peer con-
     nected to the UNIX domain socket s.

     One common use is for UNIX domain servers to determine the credentials of
     clients that have connected to it.

     getpeereid() takes three parameters:

     s Contains the file descriptor of the socket whose peer credentials
     should be looked up.

     euid Points to a uid_t variable into which the effective user ID for the
     connected peer will be stored.

     egid Points to a gid_t variable into which the effective group ID for the
     connected peer will be stored.

RETURN VALUES
     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.

ERRORS
     On failure, errno is set to one of the following:

     [EBADF]       The argument s is not a valid descriptor.

     [ENOTSOCK]    The argument s is a file, not a socket.

     [EOPNOTSUPP]  The socket is not in the UNIX domain.

     [ENOTCONN]    The socket is not connected.

     [ENOBUFS]     Insufficient resources were available in the system to per-
                   form the operation.

     [EFAULT]      The euid or egid parameters point to memory not in a valid
                   part of the process address space.

SEE ALSO
     accept(2), bind(2), getpeername(2), getsockname(2), socket(2)

HISTORY
     The getpeereid() function call appeared in OpenBSD 3.0.

OpenBSD 3.4                      June 26, 2001                               1

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | SEE ALSO | HISTORY

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=getpeereid&sektion=2&manpath=OpenBSD+3.4>

home | help