Index: tools/regression/fstest/tests/misc.sh =================================================================== --- tools/regression/fstest/tests/misc.sh (revision 184568) +++ tools/regression/fstest/tests/misc.sh (working copy) @@ -27,7 +27,7 @@ if [ $? -eq 0 ]; then echo "ok ${ntest}" else - echo "not ok ${ntest}" + echo "not ok ${ntest} - tried '$*', expected ${e}, got ${r}" fi ntest=`expr $ntest + 1` } @@ -43,7 +43,7 @@ if [ $? -eq 0 ]; then echo "ok ${ntest}" else - echo "not ok ${ntest}" + echo "not ok ${ntest} - tried '$*', expected ${e}, got ${r}" fi ntest=`expr $ntest + 1` } Index: tools/regression/fstest/tests/rename/21.t =================================================================== --- tools/regression/fstest/tests/rename/21.t (revision 184737) +++ tools/regression/fstest/tests/rename/21.t (working copy) @@ -6,7 +6,7 @@ dir=`dirname $0` . ${dir}/../misc.sh -echo "1..12" +echo "1..13" n0=`namegen` n1=`namegen` @@ -17,13 +17,17 @@ expect 0 mkdir ${n3} 0777 cdir=`pwd` +# Check that write permission on containing directory (${n2}) is enough +# to rename subdirectory (${n0}). +expect 0 mkdir ${n2}/${n0} 0700 +expect 0 -u 65534 -g 65534 rename ${n2}/${n0} ${n2}/${n1} + # Check that write permission on containing directory (${n2}) is not enough # to move subdirectory (${n0}) from that directory. -expect 0 mkdir ${n2}/${n0} 0700 -expect EACCES -u 65534 -g 65534 rename ${n2}/${n0} ${n3}/${n0} +expect EACCES -u 65534 -g 65534 rename ${n2}/${n1} ${n3}/${n0} -expect 0 rmdir ${n2}/${n0} -expect ENOENT rmdir ${n2}/${n0} +expect 0 rmdir ${n2}/${n1} +expect ENOENT rmdir ${n2}/${n1} # Check that write permission on containing directory (${n2}) is enough # to move file (${n0}) from that directory. Index: lib/libc/sys/rename.2 =================================================================== --- lib/libc/sys/rename.2 (revision 184568) +++ lib/libc/sys/rename.2 (working copy) @@ -156,6 +156,11 @@ .It Bq Er EACCES The requested link requires writing in a directory with a mode that denies write permission. +.It Bq Er EACCES +The directory pointed at by the +.Fa from +argument denies write permission, and the operation would move +it to another parent directory. .It Bq Er EPERM The file pointed at by the .Fa from Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c =================================================================== --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c (revision 184740) +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c (working copy) @@ -1580,7 +1580,15 @@ /* * Rename permissions are combination of delete permission + * add file/subdir permission. + * + * BSD operating systems also require write permission + * on the directory being moved from one parent directory + * to another. */ + if (ZTOV(szp)->v_type == VDIR && ZTOV(sdzp) != ZTOV(tdzp)) { + if (error = zfs_zaccess(szp, ACE_WRITE_DATA, cr)) + return (error); + } /* * first make sure we do the delete portion.