diff options
Diffstat (limited to 'src/lib/libc/net/getpeereid.3')
| -rw-r--r-- | src/lib/libc/net/getpeereid.3 | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/src/lib/libc/net/getpeereid.3 b/src/lib/libc/net/getpeereid.3 new file mode 100644 index 0000000000..c1671a7516 --- /dev/null +++ b/src/lib/libc/net/getpeereid.3 | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | .\" $OpenBSD: getpeereid.3,v 1.1 2010/07/01 19:15:30 deraadt Exp $ | ||
| 2 | .\" | ||
| 3 | .\" Copyright (c) 1983, 1991, 1993 | ||
| 4 | .\" The Regents of the University of California. All rights reserved. | ||
| 5 | .\" | ||
| 6 | .\" Redistribution and use in source and binary forms, with or without | ||
| 7 | .\" modification, are permitted provided that the following conditions | ||
| 8 | .\" are met: | ||
| 9 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 10 | .\" notice, this list of conditions and the following disclaimer. | ||
| 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 12 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 13 | .\" documentation and/or other materials provided with the distribution. | ||
| 14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
| 15 | .\" may be used to endorse or promote products derived from this software | ||
| 16 | .\" without specific prior written permission. | ||
| 17 | .\" | ||
| 18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 28 | .\" SUCH DAMAGE. | ||
| 29 | .Dd $Mdocdate: July 1 2010 $ | ||
| 30 | .Dt GETPEEREID 3 | ||
| 31 | .Os | ||
| 32 | .Sh NAME | ||
| 33 | .Nm getpeereid | ||
| 34 | .Nd get effective user and group identification of locally-connected peer | ||
| 35 | .Sh SYNOPSIS | ||
| 36 | .Fd #include <sys/types.h> | ||
| 37 | .Fd #include <sys/socket.h> | ||
| 38 | .Ft int | ||
| 39 | .Fn getpeereid "int s" "uid_t *euid" "gid_t *egid" | ||
| 40 | .Sh DESCRIPTION | ||
| 41 | .Fn getpeereid | ||
| 42 | returns the effective user ID and group ID of the peer connected to | ||
| 43 | a | ||
| 44 | .Ux Ns -domain | ||
| 45 | socket (see | ||
| 46 | .Xr unix 4 ) . | ||
| 47 | The argument | ||
| 48 | .Fa s | ||
| 49 | must be of type | ||
| 50 | .Dv SOCK_STREAM . | ||
| 51 | .Pp | ||
| 52 | One common use is for | ||
| 53 | .Ux Ns -domain | ||
| 54 | servers to determine the credentials of clients that have connected to it. | ||
| 55 | .Pp | ||
| 56 | .Fn getpeereid | ||
| 57 | takes three parameters: | ||
| 58 | .Bl -bullet | ||
| 59 | .It | ||
| 60 | .Fa s | ||
| 61 | contains the file descriptor of the socket whose peer credentials | ||
| 62 | should be looked up. | ||
| 63 | .It | ||
| 64 | .Fa euid | ||
| 65 | points to a | ||
| 66 | .Li uid_t | ||
| 67 | variable into which the effective user ID for the connected peer will | ||
| 68 | be stored. | ||
| 69 | .It | ||
| 70 | .Fa egid | ||
| 71 | points to a | ||
| 72 | .Li gid_t | ||
| 73 | variable into which the effective group ID for the connected peer will | ||
| 74 | be stored. | ||
| 75 | .El | ||
| 76 | .Sh RETURN VALUES | ||
| 77 | If the call succeeds, a 0 is returned and | ||
| 78 | .Fa euid | ||
| 79 | and | ||
| 80 | .Fa egid | ||
| 81 | are set to the effective user ID and group ID of the connected peer. | ||
| 82 | Otherwise, | ||
| 83 | .Va errno | ||
| 84 | is set and a value of \-1 is returned. | ||
| 85 | .Sh ERRORS | ||
| 86 | On failure, | ||
| 87 | .Va errno | ||
| 88 | is set to one of the following: | ||
| 89 | .Bl -tag -width Er | ||
| 90 | .It Bq Er EBADF | ||
| 91 | The argument | ||
| 92 | .Fa s | ||
| 93 | is not a valid descriptor. | ||
| 94 | .It Bq Er ENOTSOCK | ||
| 95 | The argument | ||
| 96 | .Fa s | ||
| 97 | is a file, not a socket. | ||
| 98 | .It Bq Er EOPNOTSUPP | ||
| 99 | The socket is not in the | ||
| 100 | .Ux Ns -domain . | ||
| 101 | .It Bq Er ENOTCONN | ||
| 102 | The socket is not connected. | ||
| 103 | .It Bq Er ENOBUFS | ||
| 104 | Insufficient resources were available in the system | ||
| 105 | to perform the operation. | ||
| 106 | .El | ||
| 107 | .Sh SEE ALSO | ||
| 108 | .Xr accept 2 , | ||
| 109 | .Xr bind 2 , | ||
| 110 | .Xr getpeername 2 , | ||
| 111 | .Xr getsockname 2 , | ||
| 112 | .Xr getsockopt 2 , | ||
| 113 | .Xr socket 2 , | ||
| 114 | .Xr unix 4 | ||
| 115 | .Sh HISTORY | ||
| 116 | The | ||
| 117 | .Fn getpeereid | ||
| 118 | function call appeared in | ||
| 119 | .Ox 3.0 . | ||
