Deleted Added
full compact
kern_resource.c (46112) kern_resource.c (46116)
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_resource.c 8.5 (Berkeley) 1/21/94
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_resource.c 8.5 (Berkeley) 1/21/94
39 * $Id: kern_resource.c,v 1.45 1999/03/13 19:46:12 bde Exp $
39 * $Id: kern_resource.c,v 1.46 1999/04/27 11:16:02 phk Exp $
40 */
41
42#include "opt_compat.h"
43#include "opt_rlimit.h"
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/sysproto.h>

--- 149 unchanged lines hidden (view full) ---

197 if (pcred->pc_ucred->cr_uid && pcred->p_ruid &&
198 pcred->pc_ucred->cr_uid != chgp->p_ucred->cr_uid &&
199 pcred->p_ruid != chgp->p_ucred->cr_uid)
200 return (EPERM);
201 if (n > PRIO_MAX)
202 n = PRIO_MAX;
203 if (n < PRIO_MIN)
204 n = PRIO_MIN;
40 */
41
42#include "opt_compat.h"
43#include "opt_rlimit.h"
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/sysproto.h>

--- 149 unchanged lines hidden (view full) ---

197 if (pcred->pc_ucred->cr_uid && pcred->p_ruid &&
198 pcred->pc_ucred->cr_uid != chgp->p_ucred->cr_uid &&
199 pcred->p_ruid != chgp->p_ucred->cr_uid)
200 return (EPERM);
201 if (n > PRIO_MAX)
202 n = PRIO_MAX;
203 if (n < PRIO_MIN)
204 n = PRIO_MIN;
205 if (n < chgp->p_nice && suser_xxx(pcred->pc_ucred, &curp->p_acflag))
205 if (n < chgp->p_nice && suser(curp))
206 return (EACCES);
207 chgp->p_nice = n;
208 (void)resetpriority(chgp);
209 return (0);
210}
211
212/* rtprio system call */
213#ifndef _SYS_SYSPROTO_H_

--- 35 unchanged lines hidden (view full) ---

249 case RTP_LOOKUP:
250 return (copyout(&p->p_rtprio, uap->rtp, sizeof(struct rtprio)));
251 case RTP_SET:
252 if (pcred->pc_ucred->cr_uid && pcred->p_ruid &&
253 pcred->pc_ucred->cr_uid != p->p_ucred->cr_uid &&
254 pcred->p_ruid != p->p_ucred->cr_uid)
255 return (EPERM);
256 /* disallow setting rtprio in most cases if not superuser */
206 return (EACCES);
207 chgp->p_nice = n;
208 (void)resetpriority(chgp);
209 return (0);
210}
211
212/* rtprio system call */
213#ifndef _SYS_SYSPROTO_H_

--- 35 unchanged lines hidden (view full) ---

249 case RTP_LOOKUP:
250 return (copyout(&p->p_rtprio, uap->rtp, sizeof(struct rtprio)));
251 case RTP_SET:
252 if (pcred->pc_ucred->cr_uid && pcred->p_ruid &&
253 pcred->pc_ucred->cr_uid != p->p_ucred->cr_uid &&
254 pcred->p_ruid != p->p_ucred->cr_uid)
255 return (EPERM);
256 /* disallow setting rtprio in most cases if not superuser */
257 if (suser_xxx(pcred->pc_ucred, &curp->p_acflag)) {
257 if (suser(curp)) {
258 /* can't set someone else's */
259 if (uap->pid)
260 return (EPERM);
261 /* can't set realtime priority */
262/*
263 * Realtime priority has to be restricted for reasons which should be
264 * obvious. However, for idle priority, there is a potential for
265 * system deadlock if an idleprio process gains a lock on a resource

--- 378 unchanged lines hidden ---
258 /* can't set someone else's */
259 if (uap->pid)
260 return (EPERM);
261 /* can't set realtime priority */
262/*
263 * Realtime priority has to be restricted for reasons which should be
264 * obvious. However, for idle priority, there is a potential for
265 * system deadlock if an idleprio process gains a lock on a resource

--- 378 unchanged lines hidden ---