From owner-p4-projects@FreeBSD.ORG Wed Jul 9 12:49:12 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 72DCE106568A; Wed, 9 Jul 2008 12:49:12 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36B0A1065678 for ; Wed, 9 Jul 2008 12:49:12 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 27C318FC0A for ; Wed, 9 Jul 2008 12:49:12 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m69CnC3O065842 for ; Wed, 9 Jul 2008 12:49:12 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m69CnCUM065840 for perforce@freebsd.org; Wed, 9 Jul 2008 12:49:12 GMT (envelope-from trasz@freebsd.org) Date: Wed, 9 Jul 2008 12:49:12 GMT Message-Id: <200807091249.m69CnCUM065840@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Cc: Subject: PERFORCE change 144941 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jul 2008 12:49:12 -0000 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);