* Set "nice" for a (whole) process. */
| 265 | * Set "nice" for a (whole) process. |
| 266 | */ |
| 267 | static int |
| 268 | donice(struct thread *td, struct proc *p, int n) |
| 269 | { |
| 270 | int error; |
| 271 | |
| 272 | PROC_LOCK_ASSERT(p, MA_OWNED); |
| 273 | if ((error = p_cansched(td, p))) |
| 274 | return (error); |
| 275 | if (n > PRIO_MAX) |
| 276 | n = PRIO_MAX; |
| 277 | if (n < PRIO_MIN) |
| 278 | n = PRIO_MIN; |
| 279 | if (n < p->p_nice && priv_check(td, PRIV_SCHED_SETPRIORITY) != 0) |
| 280 | return (EACCES); |
| 281 | sched_nice(p, n); |
| 282 | return (0); |
| 283 | } |
| 284 | |
| 285 | static int unprivileged_idprio; |
| 286 | SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_idprio, CTLFLAG_RW, |
no test coverage detected