getpeereid man page on OpenBSD

Man page or keyword search:  
man Server   11362 pages
apropos Keyword Search (all sections)
Output format
OpenBSD logo
[printable version]

GETPEEREID(3)		  OpenBSD Programmer's Manual		 GETPEEREID(3)

NAME
     getpeereid - get effective user and group identification of
     locally-connected 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
     connected 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:

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

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

     o	 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
		   perform the operation.

SEE ALSO
     accept(2), bind(2), getpeername(2), getsockname(2), getsockopt(2),
     socket(2), unix(4)

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

OpenBSD 4.9			 July 1, 2010			   OpenBSD 4.9
[top]

List of man pages available for OpenBSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net