Add SIGCKPT support to tcsh's built-in kill.
[dragonfly.git] / lib / libc / gen / getpeereid.3
1 .\"
2 .\" Copyright (c) 2001 Dima Dorfman.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD: src/lib/libc/gen/getpeereid.3,v 1.5.2.2 2003/03/13 18:05:37 trhodes Exp $
27 .\" $DragonFly: src/lib/libc/gen/getpeereid.3,v 1.2 2003/06/17 04:26:42 dillon Exp $
28 .\"
29 .Dd July 15, 2001
30 .Dt GETPEEREID 3
31 .Os
32 .Sh NAME
33 .Nm getpeereid
34 .Nd get the effective credentials of a UNIX-domain peer
35 .Sh LIBRARY
36 .Lb libc
37 .Sh SYNOPSIS
38 .In sys/types.h
39 .In unistd.h
40 .Ft int
41 .Fn getpeereid "int s" "uid_t *euid" "gid_t *egid"
42 .Sh DESCRIPTION
43 The
44 .Fn getpeereid
45 function returns the effective user and group IDs of the
46 peer connected to a
47 .Ux Ns -domain
48 socket.
49 The argument
50 .Fa s
51 must be a
52 .Ux Ns -domain
53 socket
54 .Pq Xr unix 4
55 of type
56 .Dv SOCK_STREAM
57 on which either
58 .Xr connect 2
59 or
60 .Xr listen 2
61 have been called.
62 The effective used ID is placed in
63 .Fa euid ,
64 and the effective group ID in
65 .Fa egid .
66 .Pp
67 The credentials returned to the
68 .Xr listen 2
69 caller are those of its peer at the time it called
70 .Xr connect 2 ;
71 the credentials returned to the
72 .Xr connect 2
73 caller are those of its peer at the time it called
74 .Xr listen 2 .
75 This mechanism is reliable; there is no way for either side to influence
76 the credentials returned to its peer except by calling the appropriate
77 system call (i.e., either
78 .Xr connect 2
79 or
80 .Xr listen 2 )
81 under different effective credentials.
82 .Pp
83 One common use of this routine is for a
84 .Ux Ns -domain
85 server
86 to verify the credentials of its client.
87 Likewise, the client can verify the credentials of the server.
88 .Sh IMPLEMENTATION NOTES
89 On
90 .Fx ,
91 .Fn getpeereid
92 is implemented in terms of the
93 .Dv LOCAL_PEERCRED
94 .Xr unix 4
95 socket option.
96 .Sh RETURN VALUES
97 .Rv -std getpeereid
98 .Sh ERRORS
99 The
100 .Fn getpeereid
101 function
102 fails if:
103 .Bl -tag -width Er
104 .It Bq Er EBADF
105 The argument
106 .Fa s
107 is not a valid descriptor.
108 .It Bq Er ENOTSOCK
109 The argument
110 .Fa s
111 is a file, not a socket.
112 .It Bq Er ENOTCONN
113 The argument
114 .Fa s
115 does not refer to a socket on which
116 .Xr connect 2
117 or
118 .Xr listen 2
119 have been called.
120 .It Bq Er EINVAL
121 The argument
122 .Fa s
123 does not refer to a socket of type
124 .Dv SOCK_STREAM ,
125 or the kernel returned invalid data.
126 .El
127 .Sh SEE ALSO
128 .Xr connect 2 ,
129 .Xr getpeername 2 ,
130 .Xr getsockname 2 ,
131 .Xr getsockopt 2 ,
132 .Xr listen 2 ,
133 .Xr unix 4
134 .Sh HISTORY
135 The
136 .Fn getpeereid
137 function appeared in
138 .Fx 4.6 .