Deleted Added
sdiff udiff text old ( 144978 ) new ( 147398 )
full compact
1.\" Copyright (c) 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 16 unchanged lines hidden (view full) ---

25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)unix.4 8.1 (Berkeley) 6/9/93
33.\" $FreeBSD: head/share/man/man4/unix.4 147398 2005-06-15 13:31:23Z ru $
34.\"
35.Dd July 15, 2001
36.Dt UNIX 4
37.Os
38.Sh NAME
39.Nm unix
40.Nd UNIX-domain protocol family
41.Sh SYNOPSIS

--- 47 unchanged lines hidden (view full) ---

89.Xr bind 2
90and
91.Xr connect 2 ,
92can be calculated by the macro
93.Fn SUN_LEN
94defined in
95.In sys/un.h .
96The
97.Va sun_path
98field must be terminated by a
99.Dv NUL
100character to be used with
101.Fn SUN_LEN ,
102but the terminating
103.Dv NUL
104is
105.Em not
106part of the address.
107.Pp
108The
109.Ux Ns -domain
110protocol family does not support broadcast addressing or any form
111of
112.Dq wildcard

--- 81 unchanged lines hidden (view full) ---

194This mechanism is reliable; there is no way for either party to influence
195the credentials presented to its peer except by calling the appropriate
196system call (e.g.,
197.Xr connect 2
198or
199.Xr listen 2 )
200under different effective credentials.
201.Pp
202.Tn UNIX
203domain sockets support a number of socket options which can be set with
204.Xr setsockopt 2
205and tested with
206.Xr getsockopt 2 :
207.Bl -tag -width ".Dv LOCAL_CONNWAIT"
208.It Dv LOCAL_CREDS
209This option may be enabled on a
210.Dv SOCK_DGRAM
211or a
212.Dv SOCK_STREAM
213socket.
214This option provides a mechanism for the receiver to
215receive the credentials of the process as a
216.Xr recvmsg 2
217control message.
218The
219.Va msg_control
220field in the
221.Vt msghdr
222structure points to a buffer that contains a
223.Vt cmsghdr
224structure followed by a variable length
225.Vt sockcred
226structure, defined in
227.In sys/socket.h
228as follows:
229.Bd -literal
230struct sockcred {
231 id_t sc_uid; /* real user id */
232 uid_t sc_euid; /* effective user id */
233 gid_t sc_gid; /* real group id */
234 gid_t sc_egid; /* effective group id */
235 int sc_ngroups; /* number of supplemental groups */
236 gid_t sc_groups[1]; /* variable length */
237};
238.Ed
239.Pp
240The
241.Fn SOCKCREDSIZE
242macro computes the size of the
243.Vt sockcred
244structure for a specified number
245of groups.
246The
247.Vt cmsghdr
248fields have the following values:
249.Bd -literal
250cmsg_len = sizeof(struct cmsghdr) + SOCKCREDSIZE(ngroups)
251cmsg_level = SOL_SOCKET
252cmsg_type = SCM_CREDS
253.Ed
254.It Dv LOCAL_CONNWAIT
255Used with
256.Dv SOCK_STREAM
257sockets, this option causes the
258.Xr connect 2
259function to block until
260.Xr accept 2
261has been called on the listening socket.
262.El
263.Sh SEE ALSO
264.Xr socket 2 ,
265.Xr intro 4
266.Rs
267.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
268.%B PS1
269.%N 7
270.Re
271.Rs
272.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
273.%B PS1
274.%N 8
275.Re