summaryrefslogtreecommitdiff
path: root/sys/miscfs/procfs
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-08-01 05:58:59 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-08-01 05:58:59 +0000
commitbe6db7a84dcc65c9859cfd2a5ddfa5d902ee05cd (patch)
tree1ac875fc88f32a152139bc2de15252691bf355e0 /sys/miscfs/procfs
parent7d36c8e7ac49c256bf661f0139a7b283f4bddc4c (diff)
From NetBSD (mycroft):
Eliminate bogus uses of V{READ,WRITE,EXEC}. Use S_I[RWX]{USR,GRP,OTH} where appropriate.
Diffstat (limited to 'sys/miscfs/procfs')
-rw-r--r--sys/miscfs/procfs/procfs_subr.c42
-rw-r--r--sys/miscfs/procfs/procfs_vnops.c21
2 files changed, 30 insertions, 33 deletions
diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c
index 85b8e2ac4c3..42f527a97d3 100644
--- a/sys/miscfs/procfs/procfs_subr.c
+++ b/sys/miscfs/procfs/procfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_subr.c,v 1.6 1997/06/21 12:19:45 deraadt Exp $ */
+/* $OpenBSD: procfs_subr.c,v 1.7 1997/08/01 05:58:56 millert Exp $ */
/* $NetBSD: procfs_subr.c,v 1.15 1996/02/12 15:01:42 christos Exp $ */
/*
@@ -47,6 +47,8 @@
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/malloc.h>
+#include <sys/stat.h>
+
#include <miscfs/procfs/procfs.h>
static TAILQ_HEAD(, pfsnode) pfshead;
@@ -134,46 +136,38 @@ loop:
switch (pfs_type) {
case Proot: /* /proc = dr-xr-xr-x */
- pfs->pfs_mode = (VREAD|VEXEC) |
- (VREAD|VEXEC) >> 3 |
- (VREAD|VEXEC) >> 6;
+ pfs->pfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
vp->v_type = VDIR;
vp->v_flag = VROOT;
break;
case Pcurproc: /* /proc/curproc = lr--r--r-- */
- pfs->pfs_mode = (VREAD) |
- (VREAD >> 3) |
- (VREAD >> 6);
+ pfs->pfs_mode = S_IRUSR|S_IRGRP|S_IROTH;
vp->v_type = VLNK;
break;
- case Pproc:
- pfs->pfs_mode = (VREAD|VEXEC) |
- (VREAD|VEXEC) >> 3 |
- (VREAD|VEXEC) >> 6;
+ case Pproc: /* /proc/N = dr-xr-xr-x */
+ pfs->pfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
vp->v_type = VDIR;
break;
- case Pfile:
- case Pmem:
- case Pregs:
- case Pfpregs:
- pfs->pfs_mode = (VREAD|VWRITE);
+ case Pfile: /* /proc/N/file = -rw------- */
+ case Pmem: /* /proc/N/mem = -rw------- */
+ case Pregs: /* /proc/N/regs = -rw------- */
+ case Pfpregs: /* /proc/N/fpregs = -rw------- */
+ pfs->pfs_mode = S_IRUSR|S_IWUSR;
vp->v_type = VREG;
break;
- case Pctl:
- case Pnote:
- case Pnotepg:
- pfs->pfs_mode = (VWRITE);
+ case Pctl: /* /proc/N/ctl = --w------ */
+ case Pnote: /* /proc/N/note = --w------ */
+ case Pnotepg: /* /proc/N/notepg = --w------ */
+ pfs->pfs_mode = S_IWUSR;
vp->v_type = VREG;
break;
- case Pstatus:
- pfs->pfs_mode = (VREAD) |
- (VREAD >> 3) |
- (VREAD >> 6);
+ case Pstatus: /* /proc/N/status = -r--r--r-- */
+ pfs->pfs_mode = S_IRUSR|S_IRGRP|S_IROTH;
vp->v_type = VREG;
break;
diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c
index 4cf80b45c1d..2d9d840aebe 100644
--- a/sys/miscfs/procfs/procfs_vnops.c
+++ b/sys/miscfs/procfs/procfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_vnops.c,v 1.3 1996/04/21 22:28:19 deraadt Exp $ */
+/* $OpenBSD: procfs_vnops.c,v 1.4 1997/08/01 05:58:57 millert Exp $ */
/* $NetBSD: procfs_vnops.c,v 1.40 1996/03/16 23:52:55 christos Exp $ */
/*
@@ -56,8 +56,12 @@
#include <sys/dirent.h>
#include <sys/resourcevar.h>
#include <sys/ptrace.h>
+#include <sys/stat.h>
+
#include <vm/vm.h> /* for PAGE_SIZE */
+
#include <machine/reg.h>
+
#include <miscfs/procfs/procfs.h>
/*
@@ -549,19 +553,18 @@ procfs_getattr(v)
TIMEVAL_TO_TIMESPEC(&tv, &vap->va_ctime);
vap->va_atime = vap->va_mtime = vap->va_ctime;
- /*
- * If the process has exercised some setuid or setgid
- * privilege, then rip away read/write permission so
- * that only root can gain access.
- */
switch (pfs->pfs_type) {
case Pmem:
case Pregs:
case Pfpregs:
+ /*
+ * If the process has exercised some setuid or setgid
+ * privilege, then rip away read/write permission so
+ * that only root can gain access.
+ */
if (procp->p_flag & P_SUGID)
- vap->va_mode &= ~((VREAD|VWRITE)|
- ((VREAD|VWRITE)>>3)|
- ((VREAD|VWRITE)>>6));
+ vap->va_mode &= ~(S_IRUSR|S_IWUSR);
+ /* FALLTHROUGH */
case Pctl:
case Pstatus:
case Pnote: