MirOS Manual: getpeereid(2)

GETPEEREID(2)              BSD Programmer's Manual               GETPEEREID(2)


     getpeereid - get effective user and group identification of locally-
     connected peer


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

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


     getpeereid() returns the effective user ID and group ID of the peer con-
     nected to a UNIX domain socket (see unix(4)). The argument s must be of
     type SOCK_STREAM.

     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.


     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]       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.


     accept(2), bind(2), getpeername(2), getsockname(2), socket(2), unix(4)


     The getpeereid() function call appeared in OpenBSD 3.0.

MirOS BSD #10-current           June 26, 2001                                1

Generated on 2017-04-03 16:26:17 by $MirOS: src/scripts/roff2htm,v 1.88 2017/01/29 00:51:06 tg Exp $

These manual pages and other documentation are copyrighted by their respective writers; their source is available at our CVSweb, AnonCVS, and other mirrors. The rest is Copyright © 2002–2017 The MirOS Project, Germany.
This product includes material provided by mirabilos.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report — diffs preferred.