diff options
author | ngie <ngie@FreeBSD.org> | 2014-12-05 11:44:18 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2014-12-05 11:44:18 +0000 |
commit | 2ceba1b1340a12cfe78aa2589bb0bba87f7b33d9 (patch) | |
tree | e08795fd1d98cb1be488d6510c6b57e60398f2fa /contrib/pjdfstest/tests/chflags | |
parent | f88754a36c36675f66d041b57d0da1b2ea102c62 (diff) | |
download | FreeBSD-src-2ceba1b1340a12cfe78aa2589bb0bba87f7b33d9.zip FreeBSD-src-2ceba1b1340a12cfe78aa2589bb0bba87f7b33d9.tar.gz |
MFC r272057,r272083,r272084,r272087,r274016:
r272057:
Import pjdfstest from ^/vendor/pjdfstest/abf03c3a47745d4521b0e4aa141317553ca48f91
- Remove tools/regression/pjdfstest
- Add upgrade directions for contrib/pjdfstest
- Add a note to UPDATING for the move (the reachover Makefiles are coming
soon)
Functional differences:
- ftruncate testcases are added from upstream (github)
Non-functional differences:
- The copyright for the project has been updated to 2012
- pjd's contact information has been updated
Discussed with: -testing, jmmv, pjd
Sponsored by: EMC / Isilon Storage Division
r272083:
Expect ELOOP on Darwin/Linux with "O_NOFOLLOW was specified and the target is a
symbolic link" case. Assume EMLINK on the rest of the OSes (FreeBSD, Solaris,
etc)
Sponsored by: EMC / Isilon Storage Division
r272084:
Fix the executed testplan count
Sponsored by: EMC / Isilon Storage Division
r272087:
Increase the memory disk size in the following testcases to avoid mount
failures, which would cause cascade failures in the rest of the test
run:
link/15.t, open/19.t, mkdir/11.t, mkfifo/11.t, symlink/11.t
Fail quickly in all of the testcases if mdconfig, mount, umount, etc
fails to avoid issues similar to this in the future
Submitted by: Casey Peel <cpeel@isilon.com>
Sponsored by: EMC / Isilon Storage Division
r274016:
Integrate pjdfstest test suite execution into kyua
pjdfstest execution is opt-in and must be done as root due to some of the
assumptions made by the test suite and lack of error checking in the non-root
case
A description of how to execute pjdfstest with kyua is provided in
share/pjdfstest/README
Phabric: D824 (an earlier prototype patch)
Relnotes: yes
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'contrib/pjdfstest/tests/chflags')
-rw-r--r-- | contrib/pjdfstest/tests/chflags/00.t | 178 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/01.t | 22 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/02.t | 28 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/03.t | 32 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/04.t | 19 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/05.t | 35 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/06.t | 21 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/07.t | 50 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/08.t | 58 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/09.t | 66 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/10.t | 54 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/11.t | 58 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/12.t | 68 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/chflags/13.t | 14 |
14 files changed, 703 insertions, 0 deletions
diff --git a/contrib/pjdfstest/tests/chflags/00.t b/contrib/pjdfstest/tests/chflags/00.t new file mode 100644 index 0000000..4d7b4c9 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/00.t @@ -0,0 +1,178 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags changes flags" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:UFS) + allflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK" + userflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE" + systemflags="SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK" + + echo "1..742" + ;; +FreeBSD:ZFS) + allflags="UF_NODUMP,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK" + userflags="UF_NODUMP" + systemflags="SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK" + + echo "1..482" + ;; +*) + quick_exit + ;; +esac + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +for type in regular dir fifo block char socket; do + create_file ${type} ${n0} + expect none stat ${n0} flags + expect 0 chflags ${n0} ${allflags} + expect ${allflags} stat ${n0} flags + expect 0 chflags ${n0} ${userflags} + expect ${userflags} stat ${n0} flags + expect 0 chflags ${n0} ${systemflags} + expect ${systemflags} stat ${n0} flags + expect 0 chflags ${n0} none + expect none stat ${n0} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + + create_file ${type} ${n0} + expect none stat ${n0} flags + expect 0 lchflags ${n0} ${allflags} + expect ${allflags} stat ${n0} flags + expect 0 lchflags ${n0} ${userflags} + expect ${userflags} stat ${n0} flags + expect 0 lchflags ${n0} ${systemflags} + expect ${systemflags} stat ${n0} flags + expect 0 lchflags ${n0} none + expect none stat ${n0} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +expect 0 create ${n0} 0644 +expect 0 symlink ${n0} ${n1} +expect none stat ${n1} flags +expect none lstat ${n1} flags +expect 0 chflags ${n1} ${allflags} +expect ${allflags} stat ${n1} flags +expect none lstat ${n1} flags +expect 0 chflags ${n1} ${userflags} +expect ${userflags} stat ${n1} flags +expect none lstat ${n1} flags +expect 0 chflags ${n1} ${systemflags} +expect ${systemflags} stat ${n1} flags +expect none lstat ${n1} flags +expect 0 chflags ${n1} none +expect none stat ${n1} flags +expect none lstat ${n1} flags +expect 0 unlink ${n1} +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 symlink ${n0} ${n1} +expect none stat ${n1} flags +expect none lstat ${n1} flags +expect 0 lchflags ${n1} ${allflags} +expect ${allflags} lstat ${n1} flags +expect none stat ${n1} flags +expect 0 lchflags ${n1} ${userflags} +expect ${userflags} lstat ${n1} flags +expect none stat ${n1} flags +expect 0 lchflags ${n1} ${systemflags} +expect ${systemflags} lstat ${n1} flags +expect none stat ${n1} flags +expect 0 lchflags ${n1} none +expect none lstat ${n1} flags +expect none stat ${n1} flags +expect 0 unlink ${n1} +expect 0 unlink ${n0} + +# successful chflags(2) updates ctime. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + for flag in `echo ${allflags},none | tr ',' ' '`; do + ctime1=`${fstest} stat ${n0} ctime` + sleep 1 + expect 0 chflags ${n0} ${flag} + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + for flag in `echo ${allflags},none | tr ',' ' '`; do + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect 0 lchflags ${n0} ${flag} + ctime2=`${fstest} lstat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +# unsuccessful chflags(2) does not update ctime. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + for flag in `echo ${allflags},none | tr ',' ' '`; do + ctime1=`${fstest} stat ${n0} ctime` + sleep 1 + expect EPERM -u 65534 chflags ${n0} ${flag} + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -eq $ctime2 + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + for flag in `echo ${allflags},none | tr ',' ' '`; do + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect EPERM -u 65534 lchflags ${n0} ${flag} + ctime2=`${fstest} lstat ${n0} ctime` + test_check $ctime1 -eq $ctime2 + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/chflags/01.t b/contrib/pjdfstest/tests/chflags/01.t new file mode 100644 index 0000000..62713fd --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/01.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/01.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="chflags returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..17" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular fifo block char socket; do + create_file ${type} ${n0}/${n1} + expect ENOTDIR chflags ${n0}/${n1}/test SF_IMMUTABLE + expect 0 unlink ${n0}/${n1} +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/02.t b/contrib/pjdfstest/tests/chflags/02.t new file mode 100644 index 0000000..d4a0b37 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/02.t @@ -0,0 +1,28 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..12" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 chflags ${nx} SF_IMMUTABLE +expect SF_IMMUTABLE stat ${nx} flags +expect 0 chflags ${nx} none +expect 0 unlink ${nx} +expect ENAMETOOLONG chflags ${nxx} SF_IMMUTABLE + +expect 0 create ${nx} 0644 +expect 0 lchflags ${nx} SF_IMMUTABLE +expect SF_IMMUTABLE stat ${nx} flags +expect 0 lchflags ${nx} none +expect 0 unlink ${nx} +expect ENAMETOOLONG lchflags ${nxx} SF_IMMUTABLE diff --git a/contrib/pjdfstest/tests/chflags/03.t b/contrib/pjdfstest/tests/chflags/03.t new file mode 100644 index 0000000..87a6202 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/03.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..12" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 chflags ${nx} SF_IMMUTABLE +expect SF_IMMUTABLE stat ${nx} flags +expect 0 chflags ${nx} none +expect 0 unlink ${nx} +expect ENAMETOOLONG chflags ${nxx} SF_IMMUTABLE + +expect 0 create ${nx} 0644 +expect 0 lchflags ${nx} SF_IMMUTABLE +expect SF_IMMUTABLE stat ${nx} flags +expect 0 lchflags ${nx} none +expect 0 unlink ${nx} +expect ENAMETOOLONG lchflags ${nxx} SF_IMMUTABLE + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/chflags/04.t b/contrib/pjdfstest/tests/chflags/04.t new file mode 100644 index 0000000..3d5aa3b --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/04.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns ENOENT if the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..4" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT chflags ${n0}/${n1}/test SF_IMMUTABLE +expect ENOENT chflags ${n0}/${n1} SF_IMMUTABLE +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/05.t b/contrib/pjdfstest/tests/chflags/05.t new file mode 100644 index 0000000..cc3e04b --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/05.t @@ -0,0 +1,35 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..16" + +n0=`namegen` +n1=`namegen` +n2=`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 0 -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP +expect UF_NODUMP -u 65534 -g 65534 stat ${n1}/${n2} flags +expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} none +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP +expect UF_NODUMP -u 65534 -g 65534 stat ${n1}/${n2} flags +expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} none +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/06.t b/contrib/pjdfstest/tests/chflags/06.t new file mode 100644 index 0000000..e4899eb --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/06.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP chflags ${n0}/test SF_IMMUTABLE +expect ELOOP chflags ${n1}/test SF_IMMUTABLE +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/chflags/07.t b/contrib/pjdfstest/tests/chflags/07.t new file mode 100644 index 0000000..c2d0af2 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/07.t @@ -0,0 +1,50 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EPERM when the effective user ID does not match the owner of the file and the effective user ID is not the super-user" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..93" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP + expect none stat ${n1} flags + expect 0 chown ${n1} 65534 65534 + expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP + expect none stat ${n1} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + create_file ${type} ${n1} + expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP + expect none lstat ${n1} flags + expect 0 lchown ${n1} 65534 65534 + expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP + expect none lstat ${n1} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/08.t b/contrib/pjdfstest/tests/chflags/08.t new file mode 100644 index 0000000..62ed480 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/08.t @@ -0,0 +1,58 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is not the super-user" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..249" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect 0 chown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect 0 chflags ${n1} ${flag} + expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP + expect ${flag} stat ${n1} flags + expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP + expect ${flag} stat ${n1} flags + done + expect 0 chflags ${n1} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + create_file ${type} ${n1} + expect 0 lchown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect 0 lchflags ${n1} ${flag} + expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP + expect ${flag} lstat ${n1} flags + expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP + expect ${flag} lstat ${n1} flags + done + expect 0 lchflags ${n1} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/09.t b/contrib/pjdfstest/tests/chflags/09.t new file mode 100644 index 0000000..e7bd5cc --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/09.t @@ -0,0 +1,66 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and securelevel is greater than 0" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..327" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +old=`sysctl -n security.jail.chflags_allowed` +sysctl security.jail.chflags_allowed=1 >/dev/null + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect 0 chown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect 0 chflags ${n1} ${flag} + jexpect 1 `pwd` EPERM chflags ${n1} UF_NODUMP + expect ${flag} stat ${n1} flags + jexpect 1 `pwd` EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP + expect ${flag} stat ${n1} flags + jexpect 1 `pwd` EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP + expect ${flag} stat ${n1} flags + done + expect 0 chflags ${n1} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + create_file ${type} ${n1} + expect 0 lchown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect 0 lchflags ${n1} ${flag} + jexpect 1 `pwd` EPERM lchflags ${n1} UF_NODUMP + expect ${flag} lstat ${n1} flags + jexpect 1 `pwd` EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP + expect ${flag} lstat ${n1} flags + jexpect 1 `pwd` EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP + expect ${flag} lstat ${n1} flags + done + expect 0 lchflags ${n1} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +sysctl security.jail.chflags_allowed=${old} >/dev/null +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/10.t b/contrib/pjdfstest/tests/chflags/10.t new file mode 100644 index 0000000..11ce36b --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/10.t @@ -0,0 +1,54 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..197" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect 0 chown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag} + expect none stat ${n1} flags + expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag} + expect none stat ${n1} flags + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + create_file ${type} ${n1} + expect 0 lchown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag} + expect none lstat ${n1} flags + expect EPERM -u 65534 -g 65534 lchflags ${n1} ${flag} + expect none lstat ${n1} flags + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/11.t b/contrib/pjdfstest/tests/chflags/11.t new file mode 100644 index 0000000..33acca7 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/11.t @@ -0,0 +1,58 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EPERM if a user tries to set or remove the SF_SNAPSHOT flag" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags_SF_SNAPSHOT + +echo "1..145" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT + expect none stat ${n1} flags + expect EPERM chflags ${n1} SF_SNAPSHOT + expect none stat ${n1} flags + expect 0 chown ${n1} 65534 65534 + expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT + expect none stat ${n1} flags + expect EPERM chflags ${n1} SF_SNAPSHOT + expect none stat ${n1} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + create_file ${type} ${n1} + expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT + expect none lstat ${n1} flags + expect EPERM lchflags ${n1} SF_SNAPSHOT + expect none lstat ${n1} flags + expect 0 lchown ${n1} 65534 65534 + expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT + expect none lstat ${n1} flags + expect EPERM lchflags ${n1} SF_SNAPSHOT + expect none lstat ${n1} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/12.t b/contrib/pjdfstest/tests/chflags/12.t new file mode 100644 index 0000000..794139b --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/12.t @@ -0,0 +1,68 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:UFS) + echo "1..14" + + n0=`namegen` + n1=`namegen` + + expect 0 mkdir ${n0} 0755 + n=`mdconfig -a -n -t malloc -s 1m` || exit + newfs /dev/md${n} >/dev/null || exit + mount /dev/md${n} ${n0} + expect 0 create ${n0}/${n1} 0644 + expect 0 chflags ${n0}/${n1} UF_IMMUTABLE + expect UF_IMMUTABLE stat ${n0}/${n1} flags + expect 0 chflags ${n0}/${n1} none + expect none stat ${n0}/${n1} flags + mount -ur /dev/md${n} + expect EROFS chflags ${n0}/${n1} UF_IMMUTABLE + expect none stat ${n0}/${n1} flags + mount -uw /dev/md${n} + expect 0 chflags ${n0}/${n1} UF_IMMUTABLE + expect UF_IMMUTABLE stat ${n0}/${n1} flags + expect 0 chflags ${n0}/${n1} none + expect none stat ${n0}/${n1} flags + expect 0 unlink ${n0}/${n1} + umount /dev/md${n} + mdconfig -d -u ${n} || exit + expect 0 rmdir ${n0} + ;; +FreeBSD:ZFS) + echo "1..12" + + n0=`namegen` + n1=`namegen` + + n=`mdconfig -a -n -t malloc -s 128m` || exit + zpool create ${n0} /dev/md${n} + expect 0 create /${n0}/${n1} 0644 + expect 0 chflags /${n0}/${n1} UF_NODUMP + expect UF_NODUMP stat /${n0}/${n1} flags + expect 0 chflags /${n0}/${n1} none + expect none stat /${n0}/${n1} flags + zfs set readonly=on ${n0} + expect EROFS chflags /${n0}/${n1} UF_NODUMP + expect none stat /${n0}/${n1} flags + zfs set readonly=off ${n0} + expect 0 chflags /${n0}/${n1} UF_NODUMP + expect UF_NODUMP stat /${n0}/${n1} flags + expect 0 chflags /${n0}/${n1} none + expect none stat /${n0}/${n1} flags + expect 0 unlink /${n0}/${n1} + zpool destroy ${n0} + mdconfig -d -u ${n} || exit + ;; +*) + quick_exit + ;; +esac diff --git a/contrib/pjdfstest/tests/chflags/13.t b/contrib/pjdfstest/tests/chflags/13.t new file mode 100644 index 0000000..981122c --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/13.t @@ -0,0 +1,14 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..2" + +expect EFAULT chflags NULL UF_NODUMP +expect EFAULT chflags DEADCODE UF_NODUMP |