summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2019-02-13 11:55:22 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2019-02-13 11:55:22 +0000
commit622c7a69aacb2b5d2f4bf2b5765f8cb81718825e (patch)
tree2a261d69084db1276ecc5e3bfdbc7b1afddcb1a3 /sys
parent13dcd41b74ef9118073e90a2a81894063f23d10d (diff)
Allow SO_PEERCRED to be called on sockets created with socketpair.
OK claudio@ and jca@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_usrreq.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 01a65ccf3f2..6444de09019 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_usrreq.c,v 1.138 2019/02/04 21:40:52 bluhm Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.139 2019/02/13 11:55:21 martijn Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
@@ -108,6 +108,7 @@ uipc_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
struct mbuf *control, struct proc *p)
{
struct unpcb *unp = sotounpcb(so);
+ struct unpcb *unp2;
struct socket *so2;
int error = 0;
@@ -141,6 +142,17 @@ uipc_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
case PRU_CONNECT2:
error = unp_connect2(so, (struct socket *)nam);
+ if (!error) {
+ unp->unp_connid.uid = p->p_ucred->cr_uid;
+ unp->unp_connid.gid = p->p_ucred->cr_gid;
+ unp->unp_connid.pid = p->p_p->ps_pid;
+ unp->unp_flags |= UNP_FEIDS;
+ unp2 = sotounpcb((struct socket *)nam);
+ unp2->unp_connid.uid = p->p_ucred->cr_uid;
+ unp2->unp_connid.gid = p->p_ucred->cr_gid;
+ unp2->unp_connid.pid = p->p_p->ps_pid;
+ unp2->unp_flags |= UNP_FEIDS;
+ }
break;
case PRU_DISCONNECT: