mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
Open-code proc_set_cred_init()
This function is to be called only when initializing a new process (so,
'proc0' and at fork), and not in any other circumstances. Setting the
process' 'p_ucred' field to the result of crcowget() on the original
credentials is the only thing it does, hiding the fact that the process'
'p_ucred' field is crushed by the call. Moreover, most of the code it
executes is already encapsulated in crcowget().
To prevent misuse and improve code readability, just remove this
function and replace it with a direct assignment to 'p_ucred'.
Reviewed by: markj (earlier version), kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42255
(cherry picked from commit 92541c12bc)
This commit is contained in:
parent
279d6c5173
commit
1ae0a4f52a
4 changed files with 2 additions and 14 deletions
|
|
@ -562,7 +562,7 @@ proc0_init(void *dummy __unused)
|
|||
curthread->td_ucred = NULL;
|
||||
newcred->cr_prison = &prison0;
|
||||
newcred->cr_users++; /* avoid assertion failure */
|
||||
proc_set_cred_init(p, newcred);
|
||||
p->p_ucred = crcowget(newcred);
|
||||
newcred->cr_users--;
|
||||
crfree(newcred);
|
||||
#ifdef AUDIT
|
||||
|
|
|
|||
|
|
@ -1060,7 +1060,7 @@ fork1(struct thread *td, struct fork_req *fr)
|
|||
* XXX: This is ugly; when we copy resource usage, we need to bump
|
||||
* per-cred resource counters.
|
||||
*/
|
||||
proc_set_cred_init(newproc, td->td_ucred);
|
||||
newproc->p_ucred = crcowget(td->td_ucred);
|
||||
|
||||
/*
|
||||
* Initialize resource accounting for the child process.
|
||||
|
|
|
|||
|
|
@ -2278,17 +2278,6 @@ cru2xt(struct thread *td, struct xucred *xcr)
|
|||
xcr->cr_pid = td->td_proc->p_pid;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 = crcowget(newcred);
|
||||
}
|
||||
|
||||
/*
|
||||
* Change process credentials.
|
||||
* Callers are responsible for providing the reference for passed credentials
|
||||
|
|
|
|||
|
|
@ -158,7 +158,6 @@ void crcopy(struct ucred *dest, struct ucred *src);
|
|||
struct ucred *crcopysafe(struct proc *p, struct ucred *cr);
|
||||
struct ucred *crdup(struct ucred *cr);
|
||||
void crextend(struct ucred *cr, int n);
|
||||
void proc_set_cred_init(struct proc *p, struct ucred *cr);
|
||||
void proc_set_cred(struct proc *p, struct ucred *cr);
|
||||
void proc_unset_cred(struct proc *p);
|
||||
void crfree(struct ucred *cr);
|
||||
|
|
|
|||
Loading…
Reference in a new issue