summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_prot.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2002-02-17 01:09:56 +0000
committerjulian <julian@FreeBSD.org>2002-02-17 01:09:56 +0000
commitabe785e035306225e97c6f57f5c2e4f6345f3b8d (patch)
tree3dd328b38aee15fdbfd88129f31df6365b57a0d8 /sys/kern/kern_prot.c
parent6308e9245c1de5e4199690f0516a64f552824f07 (diff)
downloadFreeBSD-src-abe785e035306225e97c6f57f5c2e4f6345f3b8d.zip
FreeBSD-src-abe785e035306225e97c6f57f5c2e4f6345f3b8d.tar.gz
If the credential on an incoming thread is correct, don't bother
reaquiring it. In the same vein, don't bother dropping the thread cred when goinf ot userland. We are guaranteed to nned it when we come back, (which we are guaranteed to do). Reviewed by: jhb@freebsd.org, bde@freebsd.org (slightly different version)
Diffstat (limited to 'sys/kern/kern_prot.c')
-rw-r--r--sys/kern/kern_prot.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index 4214cc1..f7056a0 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -1684,6 +1684,27 @@ crdup(cr)
}
/*
+ * small routine to swap a thread's current ucred for the correct one
+ * taken from the process.
+ */
+void
+cred_update_thread(struct thread *td)
+{
+ struct proc *p;
+
+ p = td->td_proc;
+ if (td->td_ucred != NULL) {
+ mtx_lock(&Giant);
+ crfree(td->td_ucred);
+ mtx_unlock(&Giant);
+ td->td_ucred = NULL;
+ }
+ PROC_LOCK(p);
+ td->td_ucred = crhold(p->p_ucred);
+ PROC_UNLOCK(p);
+}
+
+/*
* Get login name, if available.
*/
#ifndef _SYS_SYSPROTO_H_
OpenPOWER on IntegriCloud