Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add a new flag, used by vn_open() which prevent symlinks...
details: https://anonhg.NetBSD.org/src/rev/9f8dc4fdd188
branches: trunk
changeset: 475957:9f8dc4fdd188
user: bouyer <bouyer%NetBSD.org@localhost>
date: Tue Aug 31 12:30:35 1999 +0000
description:
Add a new flag, used by vn_open() which prevent symlinks from being followed
at open time. Use this to prevent coredump to follow symlinks when the
kernel opens/creates the file.
diffstat:
sys/kern/kern_sig.c | 7 ++++---
sys/kern/vfs_vnops.c | 9 +++++++--
sys/sys/fcntl.h | 9 ++++++++-
3 files changed, 19 insertions(+), 6 deletions(-)
diffs (74 lines):
diff -r 5b0db9fe5f55 -r 9f8dc4fdd188 sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c Tue Aug 31 10:11:52 1999 +0000
+++ b/sys/kern/kern_sig.c Tue Aug 31 12:30:35 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sig.c,v 1.92 1999/07/25 06:30:34 thorpej Exp $ */
+/* $NetBSD: kern_sig.c,v 1.93 1999/08/31 12:30:35 bouyer Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -1297,8 +1297,9 @@
sprintf(name, "core");
else
sprintf(name, "%s.core", p->p_comm);
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, name, p);
- error = vn_open(&nd, O_CREAT | FWRITE, S_IRUSR | S_IWUSR);
+
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
+ error = vn_open(&nd, O_CREAT | FWRITE | FNOSYMLINK, S_IRUSR | S_IWUSR);
if (error)
return (error);
vp = nd.ni_vp;
diff -r 5b0db9fe5f55 -r 9f8dc4fdd188 sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c Tue Aug 31 10:11:52 1999 +0000
+++ b/sys/kern/vfs_vnops.c Tue Aug 31 12:30:35 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnops.c,v 1.37 1999/08/03 20:19:17 wrstuden Exp $ */
+/* $NetBSD: vfs_vnops.c,v 1.38 1999/08/31 12:30:36 bouyer Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -85,7 +85,8 @@
if (fmode & O_CREAT) {
ndp->ni_cnd.cn_nameiop = CREATE;
ndp->ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
- if ((fmode & O_EXCL) == 0)
+ if ((fmode & O_EXCL) == 0 &&
+ ((fmode & FNOSYMLINK) == 0))
ndp->ni_cnd.cn_flags |= FOLLOW;
if ((error = namei(ndp)) != 0)
return (error);
@@ -114,6 +115,10 @@
error = EEXIST;
goto bad;
}
+ if (ndp->ni_vp->v_type == VLNK) {
+ error = EFTYPE;
+ goto bad;
+ }
fmode &= ~O_CREAT;
}
} else {
diff -r 5b0db9fe5f55 -r 9f8dc4fdd188 sys/sys/fcntl.h
--- a/sys/sys/fcntl.h Tue Aug 31 10:11:52 1999 +0000
+++ b/sys/sys/fcntl.h Tue Aug 31 12:30:35 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fcntl.h,v 1.16 1999/08/03 20:19:21 wrstuden Exp $ */
+/* $NetBSD: fcntl.h,v 1.17 1999/08/31 12:30:35 bouyer Exp $ */
/*-
* Copyright (c) 1983, 1990, 1993
@@ -125,6 +125,13 @@
#define FMARK 0x00001000 /* mark during gc() */
#define FDEFER 0x00002000 /* defer for next gc pass */
#define FHASLOCK 0x00004000 /* descriptor holds advisory lock */
+/*
+ * Note: The below is not a flag that can be used in the struct file.
+ * It's an option that can be passed to vn_open to make sure it doesn't
+ * follow a symlink on the last lookup
+ */
+#define FNOSYMLINK 0x00080000 /* Don't follow symlink for last
+ component */
/* bits to save after open(2) */
#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FDSYNC|\
FRSYNC|FALTIO)
Home |
Main Index |
Thread Index |
Old Index