text
stringlengths
0
234
.ir sun_path .
.pp
when coding portable applications,
keep in mind that some implementations
.\" hp-ux
have
.i sun_path
as short as 92 bytes.
.\" modern bsds generally have 104, tru64 and aix have 104,
.\" solaris and irix have 108
.pp
various system calls
.rb ( accept (2),
.br recvfrom (2),
.br getsockname (2),
.br getpeername (2))
return socket address structures.
when applied to unix domain sockets, the value-result
.i addrlen
argument supplied to the call should be initialized as above.
upon return, the argument is set to indicate the
.i actual
size of the address structure.
the caller should check the value returned in this argument:
if the output value exceeds the input value,
then there is no guarantee that a null terminator is present in
.ir sun_path .
(see bugs.)
.\"
.ss pathname socket ownership and permissions
in the linux implementation,
pathname sockets honor the permissions of the directory they are in.
creation of a new socket fails if the process does not have write and
search (execute) permission on the directory in which the socket is created.
.pp
on linux,
connecting to a stream socket object requires write permission on that socket;
sending a datagram to a datagram socket likewise
requires write permission on that socket.
posix does not make any statement about the effect of the permissions
on a socket file, and on some systems (e.g., older bsds),
the socket permissions are ignored.
portable programs should not rely on
this feature for security.
.pp
when creating a new socket, the owner and group of the socket file
are set according to the usual rules.
the socket file has all permissions enabled,
other than those that are turned off by the process
.br umask (2).
.pp
the owner, group, and permissions of a pathname socket can be changed (using
.br chown (2)
and
.br chmod (2)).
.\" however, fchown() and fchmod() do not seem to have an effect
.\"
.ss abstract sockets
socket permissions have no meaning for abstract sockets:
the process
.br umask (2)
has no effect when binding an abstract socket,
and changing the ownership and permissions of the object (via
.br fchown (2)
and
.br fchmod (2))
has no effect on the accessibility of the socket.
.pp
abstract sockets automatically disappear when all open references
to the socket are closed.
.pp
the abstract socket namespace is a nonportable linux extension.
.\"
.ss socket options
for historical reasons, these socket options are specified with a
.b sol_socket
type even though they are
.b af_unix
specific.
they can be set with
.br setsockopt (2)
and read with
.br getsockopt (2)
by specifying
.b sol_socket
as the socket family.
.tp
.b so_passcred
enabling this socket option causes receipt of the credentials of
the sending process in an
.b scm_credentials ancillary
message in each subsequently received message.
the returned credentials are those specified by the sender using
.br scm_credentials ,
or a default that includes the sender's pid, real user id, and real group id,
if the sender did not specify
.b scm_credentials
ancillary data.
.ip
when this option is set and the socket is not yet connected,