mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-29 12:03:03 +00:00
Emulate SO_PEERCRED socket option.
Temporarily use 0 for pid member as the FreeBSD does not cache remote UNIX domain socket peer pid. PR: kern/102956 Reviewed by: rwatson Approved by: kib (mentor) MFC after: 1 month
This commit is contained in:
parent
ae28ded2c8
commit
d4dd69c46c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=192203
@ -1354,7 +1354,9 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
|
||||
} */ bsd_args;
|
||||
l_timeval linux_tv;
|
||||
struct timeval tv;
|
||||
socklen_t tv_len;
|
||||
socklen_t tv_len, xulen;
|
||||
struct xucred xu;
|
||||
struct l_ucred lxu;
|
||||
int error, name;
|
||||
|
||||
bsd_args.s = args->s;
|
||||
@ -1377,6 +1379,23 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
|
||||
sizeof(linux_tv)));
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case LOCAL_PEERCRED:
|
||||
if (args->optlen != sizeof(lxu))
|
||||
return (EINVAL);
|
||||
xulen = sizeof(xu);
|
||||
error = kern_getsockopt(td, args->s, bsd_args.level,
|
||||
name, &xu, UIO_SYSSPACE, &xulen);
|
||||
if (error)
|
||||
return (error);
|
||||
/*
|
||||
* XXX Use 0 for pid as the FreeBSD does not cache peer pid.
|
||||
*/
|
||||
lxu.pid = 0;
|
||||
lxu.uid = xu.cr_uid;
|
||||
lxu.gid = xu.cr_gid;
|
||||
return (copyout(&lxu, PTRIN(args->optval), sizeof(lxu)));
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -90,4 +90,10 @@
|
||||
#define LINUX_AF_APPLETALK 5
|
||||
#define LINUX_AF_INET6 10
|
||||
|
||||
struct l_ucred {
|
||||
uint32_t pid;
|
||||
uint32_t uid;
|
||||
uint32_t gid;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_SOCKET_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user