summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_socket2.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-09-19 02:17:02 +0000
committergreen <green@FreeBSD.org>1999-09-19 02:17:02 +0000
commit4395e552e2eb08e6dc53ccf82bfcc4040c59bda6 (patch)
treedd4bc747543783e9e5ae654bb73c96623d75d2e9 /sys/kern/uipc_socket2.c
parent7ab42b2253ccc67416479e053f47749a18e199df (diff)
downloadFreeBSD-src-4395e552e2eb08e6dc53ccf82bfcc4040c59bda6.zip
FreeBSD-src-4395e552e2eb08e6dc53ccf82bfcc4040c59bda6.tar.gz
Change so_cred's type to a ucred, not a pcred. THis makes more sense, actually.
Make a sonewconn3() which takes an extra argument (proc) so new sockets created with sonewconn() from a user's system call get the correct credentials, not just the parent's credentials.
Diffstat (limited to 'sys/kern/uipc_socket2.c')
-rw-r--r--sys/kern/uipc_socket2.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index f6115a9..a51f983 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -44,6 +44,7 @@
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
+#include <sys/resourcevar.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
@@ -203,6 +204,16 @@ sonewconn(head, connstatus)
register struct socket *head;
int connstatus;
{
+
+ return (sonewconn3(head, connstatus, NULL));
+}
+
+struct socket *
+sonewconn3(head, connstatus, p)
+ register struct socket *head;
+ int connstatus;
+ struct proc *p;
+{
register struct socket *so;
if (head->so_qlen > 3 * head->so_qlimit / 2)
@@ -217,12 +228,10 @@ sonewconn(head, connstatus)
so->so_state = head->so_state | SS_NOFDREF;
so->so_proto = head->so_proto;
so->so_timeo = head->so_timeo;
- so->so_cred = head->so_cred;
- if (so->so_cred)
- so->so_cred->p_refcnt++;
- (void) soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat);
-
- if ((*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) {
+ so->so_cred = p ? p->p_ucred : head->so_cred;
+ crhold(so->so_cred);
+ if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat) ||
+ (*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) {
sodealloc(so);
return ((struct socket *)0);
}
@@ -921,7 +930,7 @@ sotoxsocket(struct socket *so, struct xsocket *xso)
xso->so_oobmark = so->so_oobmark;
sbtoxsockbuf(&so->so_snd, &xso->so_snd);
sbtoxsockbuf(&so->so_rcv, &xso->so_rcv);
- xso->so_uid = so->so_cred ? so->so_cred->pc_ucred->cr_uid : -1;
+ xso->so_uid = so->so_cred->cr_uid;
}
/*
OpenPOWER on IntegriCloud