Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_prot.c
| Show First 20 Lines • Show All 416 Lines • ▼ Show 20 Lines | |||||||||
| * | * | ||||||||
| * caller does setpgid(targpid, targpgid) | * caller does setpgid(targpid, targpgid) | ||||||||
| * | * | ||||||||
| * pid must be caller or child of caller (ESRCH) | * pid must be caller or child of caller (ESRCH) | ||||||||
| * if a child | * if a child | ||||||||
| * pid must be in same session (EPERM) | * pid must be in same session (EPERM) | ||||||||
| * pid can't have done an exec (EACCES) | * pid can't have done an exec (EACCES) | ||||||||
| * if pgid != pid | * if pgid != pid | ||||||||
| * there must exist some pid in same session having pgid (EPERM) | * there must exist some pid in same session having pgid (EPERM) | ||||||||
olce: This slipped in by mistake, removed in my local commit. | |||||||||
| * pid must not be session leader (EPERM) | * pid must not be session leader (EPERM) | ||||||||
| */ | */ | ||||||||
| #ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||||||
| struct setpgid_args { | struct setpgid_args { | ||||||||
| int pid; /* target process id */ | int pid; /* target process id */ | ||||||||
| int pgid; /* target pgrp id */ | int pgid; /* target pgrp id */ | ||||||||
| }; | }; | ||||||||
| #endif | #endif | ||||||||
| ▲ Show 20 Lines • Show All 2,353 Lines • ▼ Show 20 Lines | |||||||||
| */ | */ | ||||||||
| static bool | static bool | ||||||||
| _proc_set_cred(struct proc *p, struct ucred *newcred, bool enforce_proc_lim) | _proc_set_cred(struct proc *p, struct ucred *newcred, bool enforce_proc_lim) | ||||||||
| { | { | ||||||||
| struct ucred *const oldcred = p->p_ucred; | struct ucred *const oldcred = p->p_ucred; | ||||||||
| MPASS(oldcred != NULL); | MPASS(oldcred != NULL); | ||||||||
| PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||||||
| KASSERT(newcred->cr_users == 0, ("%s: users %d not 0 on cred %p", | |||||||||
| __func__, newcred->cr_users, newcred)); | |||||||||
| KASSERT(newcred->cr_ref == 1, ("%s: ref %ld not 1 on cred %p", | |||||||||
| __func__, newcred->cr_ref, newcred)); | |||||||||
| if (newcred->cr_ruidinfo != oldcred->cr_ruidinfo) { | if (newcred->cr_ruidinfo != oldcred->cr_ruidinfo) { | ||||||||
| /* | /* | ||||||||
| * XXXOC: This check is flawed but nonetheless the best we can | * XXXOC: This check is flawed but nonetheless the best we can | ||||||||
| * currently do as we don't really track limits per UID contrary | * currently do as we don't really track limits per UID contrary | ||||||||
| * to what we pretend in setrlimit(2). Until this is reworked, | * to what we pretend in setrlimit(2). Until this is reworked, | ||||||||
| * we just check here that the number of processes for our new | * we just check here that the number of processes for our new | ||||||||
| * real UID doesn't exceed this process' process number limit | * real UID doesn't exceed this process' process number limit | ||||||||
| Show All 9 Lines | if (newcred->cr_ruidinfo != oldcred->cr_ruidinfo) { | ||||||||
| } | } | ||||||||
| } | } | ||||||||
| mtx_lock(&oldcred->cr_mtx); | mtx_lock(&oldcred->cr_mtx); | ||||||||
| KASSERT(oldcred->cr_users > 0, ("%s: users %d not > 0 on cred %p", | KASSERT(oldcred->cr_users > 0, ("%s: users %d not > 0 on cred %p", | ||||||||
| __func__, oldcred->cr_users, oldcred)); | __func__, oldcred->cr_users, oldcred)); | ||||||||
| oldcred->cr_users--; | oldcred->cr_users--; | ||||||||
| mtx_unlock(&oldcred->cr_mtx); | mtx_unlock(&oldcred->cr_mtx); | ||||||||
| mtx_lock(&newcred->cr_mtx); | |||||||||
| newcred->cr_users++; | |||||||||
Done Inline Actions
markj: | |||||||||
| mtx_unlock(&newcred->cr_mtx); | |||||||||
| p->p_ucred = newcred; | p->p_ucred = newcred; | ||||||||
| newcred->cr_users = 1; | |||||||||
| PROC_UPDATE_COW(p); | PROC_UPDATE_COW(p); | ||||||||
| if (newcred->cr_ruidinfo != oldcred->cr_ruidinfo) | if (newcred->cr_ruidinfo != oldcred->cr_ruidinfo) | ||||||||
| (void)chgproccnt(oldcred->cr_ruidinfo, -1, 0); | (void)chgproccnt(oldcred->cr_ruidinfo, -1, 0); | ||||||||
| return (true); | return (true); | ||||||||
| } | } | ||||||||
| void | void | ||||||||
| proc_set_cred(struct proc *p, struct ucred *newcred) | proc_set_cred(struct proc *p, struct ucred *newcred) | ||||||||
| ▲ Show 20 Lines • Show All 382 Lines • Show Last 20 Lines | |||||||||
This slipped in by mistake, removed in my local commit.