Date: Wed, 9 Jul 2008 12:49:12 GMT From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 144941 for review Message-ID: <200807091249.m69CnCUM065840@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=144941 Change 144941 by trasz@trasz_traszkan on 2008/07/09 12:48:43 Properly handle the case when we are renaming one {file,directory} over another. Affected files ... .. //depot/projects/soc2008/trasz_nfs4acl/sys/ufs/ufs/ufs_lookup.c#4 edit Differences ... ==== //depot/projects/soc2008/trasz_nfs4acl/sys/ufs/ufs/ufs_lookup.c#4 (text+ko) ==== @@ -542,7 +542,13 @@ * regular file, or empty directory. */ if (nameiop == RENAME && (flags & ISLASTCN)) { - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread))) + if (flags & WILLBEDIR) + error = VOP_GRANULAR(vdp, VWRITE, ACL_APPEND_DATA, + cred, cnp->cn_thread); + else + error = VOP_GRANULAR(vdp, VWRITE, ACL_WRITE_DATA, + cred, cnp->cn_thread); + if (error) return (error); /* * Careful about locking second inode. @@ -553,6 +559,27 @@ if ((error = VFS_VGET(vdp->v_mount, ino, LK_EXCLUSIVE, &tdp)) != 0) return (error); + + /* + * The only purpose of this check is to return the correct + * error. Assume that we want to rename directory "a" + * to a file "b", and that we have no ACL_WRITE_DATA on + * a containing directory, but we _do_ have ACL_APPEND_DATA. + * In that case, the VOP_GRANULAR check above will return 0, + * and the operation will fail with ENOTDIR instead + * of EACCESS. + */ + if (tdp->v_type == VDIR) + error = VOP_GRANULAR(vdp, VWRITE, ACL_APPEND_DATA, + cred, cnp->cn_thread); + else + error = VOP_GRANULAR(vdp, VWRITE, ACL_WRITE_DATA, + cred, cnp->cn_thread); + if (error) { + vput(tdp); + return (error); + } + *vpp = tdp; cnp->cn_flags |= SAVENAME; return (0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807091249.m69CnCUM065840>