Specify the correct option level when emulating SO_PEERCRED.

Our equivalent to SO_PEERCRED, LOCAL_PEERCRED, is implemented at
socket option level 0, not SOL_SOCKET.

PR:		234722
Submitted by:	Dániel Bakai <bakaidl@gmail.com>
MFC after:	2 weeks
This commit is contained in:
Mark Johnston 2019-01-08 17:21:59 +00:00
parent 9cf6837897
commit bb376a990c

View File

@ -1633,6 +1633,11 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
case LOCAL_PEERCRED:
if (args->optlen < sizeof(lxu))
return (EINVAL);
/*
* LOCAL_PEERCRED is not served at the SOL_SOCKET level,
* but by the Unix socket's level 0.
*/
bsd_args.level = 0;
xulen = sizeof(xu);
error = kern_getsockopt(td, args->s, bsd_args.level,
name, &xu, UIO_SYSSPACE, &xulen);