aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2020-08-03 22:13:02 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2020-08-03 22:13:02 +0000
commit6e0c8e1ae292e567ba6260d9a6c0b771629a89e3 (patch)
tree7e907ced00311ca65beaf6f1c593bdbd544dd01d
parente67c55c998417a2b3ad6d25086e14a96e6fabe69 (diff)
downloadsrc-6e0c8e1ae292e567ba6260d9a6c0b771629a89e3.tar.gz
src-6e0c8e1ae292e567ba6260d9a6c0b771629a89e3.zip
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
Notes
Notes: svn path=/head/; revision=363813
-rw-r--r--lib/libc/gen/getpeereid.c2
-rw-r--r--share/man/man4/unix.46
-rw-r--r--sys/kern/uipc_usrreq.c2
-rw-r--r--sys/sys/un.h2
4 files changed, 8 insertions, 4 deletions
diff --git a/lib/libc/gen/getpeereid.c b/lib/libc/gen/getpeereid.c
index 530ae0e6100e..86396d359ba3 100644
--- a/lib/libc/gen/getpeereid.c
+++ b/lib/libc/gen/getpeereid.c
@@ -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) {
diff --git a/share/man/man4/unix.4 b/share/man/man4/unix.4
index 8832e5eff870..569e6dd25208 100644
--- a/share/man/man4/unix.4
+++ b/share/man/man4/unix.4
@@ -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 :
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index efd592f82fe2..6261135f64ad 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -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);
diff --git a/sys/sys/un.h b/sys/sys/un.h
index 3c408628ce0a..3a011aeef635 100644
--- a/sys/sys/un.h
+++ b/sys/sys/un.h
@@ -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 */