summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_prot.c
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2016-08-08 18:31:28 +0000
committerbdrewery <bdrewery@FreeBSD.org>2016-08-08 18:31:28 +0000
commitd9e6f9e9260091a6ec505c4c12b2c38bcc2811da (patch)
tree07e5eb3e99a93c3db39c2c484ac99c12c368cf09 /sys/kern/kern_prot.c
parent367e6d5ac9d44619a8c1cfe96d3e87f7bd2cf26e (diff)
downloadFreeBSD-src-d9e6f9e9260091a6ec505c4c12b2c38bcc2811da.zip
FreeBSD-src-d9e6f9e9260091a6ec505c4c12b2c38bcc2811da.tar.gz
MFC r280331:
cred: add proc_set_cred_init helper PR: D7431
Diffstat (limited to 'sys/kern/kern_prot.c')
-rw-r--r--sys/kern/kern_prot.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index 8235a1a..6d6a92f 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -1957,8 +1957,19 @@ cred_update_thread(struct thread *td)
}
/*
+ * Set initial process credentials.
+ * Callers are responsible for providing the reference for provided credentials.
+ */
+void
+proc_set_cred_init(struct proc *p, struct ucred *newcred)
+{
+
+ p->p_ucred = newcred;
+}
+
+/*
* Change process credentials.
- * Callers are responsible for providing the reference for current credentials
+ * Callers are responsible for providing the reference for passed credentials
* and for freeing old ones.
*
* Process has to be locked except when it does not have credentials (as it
@@ -1971,9 +1982,10 @@ proc_set_cred(struct proc *p, struct ucred *newcred)
{
struct ucred *oldcred;
+ MPASS(p->p_ucred != NULL);
if (newcred == NULL)
MPASS(p->p_state == PRS_ZOMBIE);
- else if (p->p_ucred != NULL)
+ else
PROC_LOCK_ASSERT(p, MA_OWNED);
oldcred = p->p_ucred;
OpenPOWER on IntegriCloud