From f82a64e18de9782389ca9b3deb995e1fc3d87d68 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Sun, 31 May 1998 18:28:45 +0000 Subject: [PATCH] Don't let the user try and unlink() a directory on a NFS server. Obtained from: NetBSD --- sys/nfs/nfs_vnops.c | 6 ++++-- sys/nfsclient/nfs_vnops.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index ec621a39c054..c7edc3cb5bb3 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95 - * $Id: nfs_vnops.c,v 1.95 1998/05/31 18:25:32 peter Exp $ + * $Id: nfs_vnops.c,v 1.96 1998/05/31 18:27:07 peter Exp $ */ @@ -1450,7 +1450,9 @@ nfs_remove(ap) if (vp->v_usecount < 1) panic("nfs_remove: bad v_usecount"); #endif - if (vp->v_usecount == 1 || (np->n_sillyrename && + if (vp->v_type == VDIR) + error = EPERM; + else if (vp->v_usecount == 1 || (np->n_sillyrename && VOP_GETATTR(vp, &vattr, cnp->cn_cred, cnp->cn_proc) == 0 && vattr.va_nlink > 1)) { /* diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index ec621a39c054..c7edc3cb5bb3 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95 - * $Id: nfs_vnops.c,v 1.95 1998/05/31 18:25:32 peter Exp $ + * $Id: nfs_vnops.c,v 1.96 1998/05/31 18:27:07 peter Exp $ */ @@ -1450,7 +1450,9 @@ nfs_remove(ap) if (vp->v_usecount < 1) panic("nfs_remove: bad v_usecount"); #endif - if (vp->v_usecount == 1 || (np->n_sillyrename && + if (vp->v_type == VDIR) + error = EPERM; + else if (vp->v_usecount == 1 || (np->n_sillyrename && VOP_GETATTR(vp, &vattr, cnp->cn_cred, cnp->cn_proc) == 0 && vattr.va_nlink > 1)) { /*