Index: head/lib/libc/gen/getpeereid.c =================================================================== --- head/lib/libc/gen/getpeereid.c +++ head/lib/libc/gen/getpeereid.c @@ -47,7 +47,7 @@ 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) { Index: head/share/man/man4/unix.4 =================================================================== --- head/share/man/man4/unix.4 +++ head/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 @@ 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 : Index: head/sys/kern/uipc_usrreq.c =================================================================== --- head/sys/kern/uipc_usrreq.c +++ head/sys/kern/uipc_usrreq.c @@ -1470,7 +1470,7 @@ struct xucred xu; int error, optval; - if (sopt->sopt_level != 0) + if (sopt->sopt_level != SOL_LOCAL) return (EINVAL); unp = sotounpcb(so); Index: head/sys/sys/un.h =================================================================== --- head/sys/sys/un.h +++ head/sys/sys/un.h @@ -62,6 +62,8 @@ #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 */