summaryrefslogtreecommitdiff
path: root/sys/miscfs
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
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')
-rw-r--r--sys/miscfs/fdesc/fdesc_vnops.c4
-rw-r--r--sys/miscfs/procfs/procfs_subr.c42
-rw-r--r--sys/miscfs/procfs/procfs_vnops.c21
-rw-r--r--sys/miscfs/union/union.h8
-rw-r--r--sys/miscfs/union/union_vfsops.c4
5 files changed, 38 insertions, 41 deletions
diff --git a/sys/miscfs/fdesc/fdesc_vnops.c b/sys/miscfs/fdesc/fdesc_vnops.c
index 0943cec0029..af5ddbd05bf 100644
--- a/sys/miscfs/fdesc/fdesc_vnops.c
+++ b/sys/miscfs/fdesc/fdesc_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdesc_vnops.c,v 1.6 1996/09/26 11:52:35 deraadt Exp $ */
+/* $OpenBSD: fdesc_vnops.c,v 1.7 1997/08/01 05:58:55 millert Exp $ */
/* $NetBSD: fdesc_vnops.c,v 1.32 1996/04/11 11:24:29 mrg Exp $ */
/*
@@ -456,7 +456,7 @@ fdesc_attr(fd, vap, cred, p)
* directories can cause loops in the namespace,
* so turn off the 'x' bits to avoid trouble.
*/
- vap->va_mode &= ~((VEXEC)|(VEXEC>>3)|(VEXEC>>6));
+ vap->va_mode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
}
break;
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:
diff --git a/sys/miscfs/union/union.h b/sys/miscfs/union/union.h
index e7485705181..94052ea28be 100644
--- a/sys/miscfs/union/union.h
+++ b/sys/miscfs/union/union.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: union.h,v 1.2 1996/02/27 08:08:59 niklas Exp $ */
+/* $OpenBSD: union.h,v 1.3 1997/08/01 05:58:57 millert Exp $ */
/* $NetBSD: union.h,v 1.9 1996/02/09 22:41:08 christos Exp $ */
/*
@@ -63,10 +63,8 @@ struct union_mount {
/*
* DEFDIRMODE is the mode bits used to create a shadow directory.
*/
-#define VRWXMODE (VREAD|VWRITE|VEXEC)
-#define VRWMODE (VREAD|VWRITE)
-#define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6))
-#define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6))
+#define UN_DIRMODE (S_IRWXU|S_IRWXG|S_IRWXO)
+#define UN_FILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
/*
* A cache of vnode references
diff --git a/sys/miscfs/union/union_vfsops.c b/sys/miscfs/union/union_vfsops.c
index 654d6ba0acc..12873edf1cd 100644
--- a/sys/miscfs/union/union_vfsops.c
+++ b/sys/miscfs/union/union_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: union_vfsops.c,v 1.2 1996/02/27 08:09:02 niklas Exp $ */
+/* $OpenBSD: union_vfsops.c,v 1.3 1997/08/01 05:58:58 millert Exp $ */
/* $NetBSD: union_vfsops.c,v 1.10 1995/06/18 14:47:47 cgd Exp $ */
/*
@@ -55,6 +55,8 @@
#include <sys/malloc.h>
#include <sys/filedesc.h>
#include <sys/queue.h>
+#include <sys/stat.h>
+
#include <miscfs/union/union.h>
int union_mount __P((struct mount *, char *, caddr_t, struct nameidata *,