diff --git a/sys/miscfs/procfs/procfs_mem.c b/sys/miscfs/procfs/procfs_mem.c index c7688ab73d70..dd2c54a39b11 100644 --- a/sys/miscfs/procfs/procfs_mem.c +++ b/sys/miscfs/procfs/procfs_mem.c @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_mem.c,v 1.12 1997/08/12 22:47:20 thorpej Exp $ */ +/* $NetBSD: procfs_mem.c,v 1.13 1997/08/13 04:01:22 explorer Exp $ */ /* * Copyright (c) 1993 Jan-Simon Pendry @@ -56,6 +56,8 @@ #include #include +#define ISSET(t, f) ((t) & (f)) + static int procfs_rwmem __P((struct proc *, struct uio *)); static int @@ -243,6 +245,33 @@ procfs_findtextvp(p) return (p->p_textvp); } +int +procfs_checkioperm(t, p) + struct proc *t, *p; +{ + int error; + + /* + * You cannot attach to a processes mem/regs if: + * + * (1) it's not owned by you, or is set-id on exec + * (unless you're root), or... + */ + if ((t->p_cred->p_ruid != p->p_cred->p_ruid || + ISSET(t->p_flag, P_SUGID)) && + (error = suser(p->p_ucred, &p->p_acflag)) != 0) + return (error); + + /* + * (2) ...it's init, which controls the security level + * of the entire system, and the system was not + * compiled with permanetly insecure mode turned on. + */ + if (t == initproc && securelevel > -1) + return (EPERM); + + return (0); +} #ifdef probably_never /* diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c index ba5407422ee0..4b01546c8460 100644 --- a/sys/miscfs/procfs/procfs_subr.c +++ b/sys/miscfs/procfs/procfs_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_subr.c,v 1.20 1997/08/12 22:47:21 thorpej Exp $ */ +/* $NetBSD: procfs_subr.c,v 1.21 1997/08/13 04:01:23 explorer Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou. All rights reserved. @@ -325,31 +325,3 @@ vfs_findname(nm, buf, buflen) return (0); } - -int -procfs_checkioperm(t, p) - struct proc *t, *p; -{ - int error; - - /* - * You cannot attach to a processes mem/regs if: - * - * (1) it's not owned by you, or is set-id on exec - * (unless you're root), or... - */ - if ((t->p_cred->p_ruid != p->p_cred->p_ruid || - ISSET(t->p_flag, P_SUGID)) && - (error = suser(p->p_ucred, &p->p_acflag)) != 0) - return (error); - - /* - * (2) ...it's init, which controls the security level - * of the entire system, and the system was not - * compiled with permanetly insecure mode turned on. - */ - if (t == initproc && securelevel > -1) - return (EPERM); - - return (0); -}