Rather than let users get fd's to symlink files, make O_NOFOLLOW cause

an error if it gets a link (like it does if it gets a socket).  The
implications of letting users try and do file operations on symlinks
themselves were too worrying.
This commit is contained in:
peter 1998-04-06 18:25:21 +00:00
parent 14414bee85
commit b0a513624f

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94
* $Id: vfs_vnops.c,v 1.50 1998/02/25 05:58:47 bde Exp $
* $Id: vfs_vnops.c,v 1.51 1998/04/06 17:38:42 peter Exp $
*/
#include <sys/param.h>
@ -83,7 +83,7 @@ vn_open(ndp, fmode, cmode)
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 & O_NOFOLLOW) == 0)
ndp->ni_cnd.cn_flags |= FOLLOW;
error = namei(ndp);
if (error)
@ -125,7 +125,7 @@ vn_open(ndp, fmode, cmode)
return (error);
vp = ndp->ni_vp;
}
if (vp->v_type == VSOCK) {
if (vp->v_type == VSOCK || vp->v_type == VLNK) {
error = EOPNOTSUPP;
goto bad;
}