diff --git a/tools/regression/pjdfstest/tests/chown/01.t b/tools/regression/pjdfstest/tests/chown/01.t index 9559e6e586e2..d410f5dff70e 100644 --- a/tools/regression/pjdfstest/tests/chown/01.t +++ b/tools/regression/pjdfstest/tests/chown/01.t @@ -6,7 +6,7 @@ desc="chown returns ENOTDIR if a component of the path prefix is not a directory dir=`dirname $0` . ${dir}/../misc.sh -echo "1..5" +echo "1..6" n0=`namegen` n1=`namegen` @@ -14,5 +14,6 @@ n1=`namegen` expect 0 mkdir ${n0} 0755 expect 0 create ${n0}/${n1} 0644 expect ENOTDIR chown ${n0}/${n1}/test 65534 65534 +expect ENOTDIR lchown ${n0}/${n1}/test 65534 65534 expect 0 unlink ${n0}/${n1} expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/chown/04.t b/tools/regression/pjdfstest/tests/chown/04.t index 8575de7a9b7a..e66d936ed5c0 100644 --- a/tools/regression/pjdfstest/tests/chown/04.t +++ b/tools/regression/pjdfstest/tests/chown/04.t @@ -6,12 +6,18 @@ desc="chown returns ENOENT if the named file does not exist" dir=`dirname $0` . ${dir}/../misc.sh -echo "1..4" +echo "1..9" n0=`namegen` n1=`namegen` +n2=`namegen` expect 0 mkdir ${n0} 0755 expect ENOENT chown ${n0}/${n1}/test 65534 65534 expect ENOENT chown ${n0}/${n1} 65534 65534 +expect ENOENT lchown ${n0}/${n1}/test 65534 65534 +expect ENOENT lchown ${n0}/${n1} 65534 65534 +expect 0 symlink ${n2} ${n0}/${n1} +expect ENOENT chown ${n0}/${n1} 65534 65534 +expect 0 unlink ${n0}/${n1} expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/chown/05.t b/tools/regression/pjdfstest/tests/chown/05.t index 6017f2d10eee..ec7cd5ccecec 100644 --- a/tools/regression/pjdfstest/tests/chown/05.t +++ b/tools/regression/pjdfstest/tests/chown/05.t @@ -6,7 +6,7 @@ desc="chown returns EACCES when search permission is denied for a component of t dir=`dirname $0` . ${dir}/../misc.sh -echo "1..15" +echo "1..18" n0=`namegen` n1=`namegen` @@ -22,11 +22,14 @@ expect 0 -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65533 expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid expect 0 chmod ${n1} 0644 expect EACCES -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65534 +expect EACCES -u 65534 -g 65533,65534 -- lchown ${n1}/${n2} -1 65534 expect 0 chmod ${n1} 0755 expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid expect 0 -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65534 expect 65534,65534 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid -expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 -u 65534 -g 65533,65534 -- lchown ${n1}/${n2} -1 65533 +expect 65534,65533 -u 65534 -g 65533 stat ${n1}/${n2} uid,gid +expect 0 unlink ${n1}/${n2} expect 0 rmdir ${n1} cd ${cdir} expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/chown/06.t b/tools/regression/pjdfstest/tests/chown/06.t index 8e6d2cc63898..39ccac68e879 100644 --- a/tools/regression/pjdfstest/tests/chown/06.t +++ b/tools/regression/pjdfstest/tests/chown/06.t @@ -6,14 +6,18 @@ desc="chown returns ELOOP if too many symbolic links were encountered in transla dir=`dirname $0` . ${dir}/../misc.sh -echo "1..6" +echo "1..10" n0=`namegen` n1=`namegen` expect 0 symlink ${n0} ${n1} expect 0 symlink ${n1} ${n0} +expect ELOOP chown ${n0} 65534 65534 +expect ELOOP chown ${n1} 65534 65534 expect ELOOP chown ${n0}/test 65534 65534 expect ELOOP chown ${n1}/test 65534 65534 +expect ELOOP lchown ${n0}/test 65534 65534 +expect ELOOP lchown ${n1}/test 65534 65534 expect 0 unlink ${n0} expect 0 unlink ${n1} diff --git a/tools/regression/pjdfstest/tests/chown/07.t b/tools/regression/pjdfstest/tests/chown/07.t index 3fd4437b4bcb..7f73cbe0ec09 100644 --- a/tools/regression/pjdfstest/tests/chown/07.t +++ b/tools/regression/pjdfstest/tests/chown/07.t @@ -6,23 +6,48 @@ desc="chown returns EPERM if the operation would change the ownership, but the e dir=`dirname $0` . ${dir}/../misc.sh -echo "1..11" +echo "1..132" n0=`namegen` n1=`namegen` n2=`namegen` +n3=`namegen` expect 0 mkdir ${n0} 0755 cdir=`pwd` cd ${n0} expect 0 mkdir ${n1} 0755 expect 0 chown ${n1} 65534 65534 -expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 -expect EPERM -u 65534 -g 65534 chown ${n1}/${n2} 65533 65533 -expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65534 65534 -expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65533 65533 -expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n2} -1 65533 -expect 0 unlink ${n1}/${n2} +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1}/${n2} 65534 65534 + expect EPERM -u 65534 -g 65534 chown ${n1}/${n2} 65533 65533 + expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65534 65534 + expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65533 65533 + expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n2} -1 65533 + expect 0 -u 65534 -g 65534 symlink ${n2} ${n1}/${n3} + expect EPERM -u 65534 -g 65534 chown ${n1}/${n3} 65533 65533 + expect EPERM -u 65533 -g 65533 chown ${n1}/${n3} 65534 65534 + expect EPERM -u 65533 -g 65533 chown ${n1}/${n3} 65533 65533 + expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n3} -1 65533 + expect 0 unlink ${n1}/${n3} + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1}/${n2} + else + expect 0 unlink ${n1}/${n2} + fi + fi + create_file ${type} ${n1}/${n2} 65534 65534 + expect EPERM -u 65534 -g 65534 lchown ${n1}/${n2} 65533 65533 + expect EPERM -u 65533 -g 65533 lchown ${n1}/${n2} 65534 65534 + expect EPERM -u 65533 -g 65533 lchown ${n1}/${n2} 65533 65533 + expect EPERM -u 65534 -g 65534 -- lchown ${n1}/${n2} -1 65533 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1}/${n2} + else + expect 0 unlink ${n1}/${n2} + fi +done expect 0 rmdir ${n1} cd ${cdir} expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/chown/10.t b/tools/regression/pjdfstest/tests/chown/10.t index 1ef6f850f7a5..961a5be27a78 100644 --- a/tools/regression/pjdfstest/tests/chown/10.t +++ b/tools/regression/pjdfstest/tests/chown/10.t @@ -6,7 +6,9 @@ desc="chown returns EFAULT if the path argument points outside the process's all dir=`dirname $0` . ${dir}/../misc.sh -echo "1..2" +echo "1..4" expect EFAULT chown NULL 65534 65534 expect EFAULT chown DEADCODE 65534 65534 +expect EFAULT lchown NULL 65534 65534 +expect EFAULT lchown DEADCODE 65534 65534