Add SOL_LOCAL symbolic constant for unix socket option level.

The constant seems to exists on MacOS X >= 10.8.

Requested by:	swills
Reviewed by:	allanjude, kevans
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D25933
This commit is contained in:
Konstantin Belousov 2020-08-03 22:13:02 +00:00
parent e67c55c998
commit 6e0c8e1ae2
4 changed files with 8 additions and 4 deletions

View File

@ -47,7 +47,7 @@ getpeereid(int s, uid_t *euid, gid_t *egid)
int error;
xuclen = sizeof(xuc);
error = _getsockopt(s, 0, LOCAL_PEERCRED, &xuc, &xuclen);
error = _getsockopt(s, SOL_LOCAL, LOCAL_PEERCRED, &xuc, &xuclen);
if (error != 0)
return (error);
if (xuc.cr_version != XUCRED_VERSION) {

View File

@ -28,7 +28,7 @@
.\" @(#)unix.4 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
.Dd August 19, 2018
.Dd August 3, 2020
.Dt UNIX 4
.Os
.Sh NAME
@ -195,7 +195,9 @@ The sending process could have exited and its process ID already been
reused for a new process.
.Sh SOCKET OPTIONS
.Tn UNIX
domain sockets support a number of socket options which can be set with
domain sockets support a number of socket options for the options level
.Dv SOL_LOCAL ,
which can be set with
.Xr setsockopt 2
and tested with
.Xr getsockopt 2 :

View File

@ -1470,7 +1470,7 @@ uipc_ctloutput(struct socket *so, struct sockopt *sopt)
struct xucred xu;
int error, optval;
if (sopt->sopt_level != 0)
if (sopt->sopt_level != SOL_LOCAL)
return (EINVAL);
unp = sotounpcb(so);

View File

@ -62,6 +62,8 @@ struct sockaddr_un {
#if __BSD_VISIBLE
#define SOL_LOCAL 0 /* Options for local socket */
/* Socket options. */
#define LOCAL_PEERCRED 1 /* retrieve peer credentials */
#define LOCAL_CREDS 2 /* pass credentials to receiver */