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/unlink | |
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/unlink')
-rw-r--r-- | contrib/pjdfstest/tests/unlink/00.t | 212 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/01.t | 18 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/02.t | 17 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/03.t | 21 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/04.t | 17 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/05.t | 27 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/06.t | 27 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/07.t | 19 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/08.t | 16 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/09.t | 65 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/10.t | 67 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/11.t | 63 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/12.t | 27 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/unlink/13.t | 12 |
14 files changed, 608 insertions, 0 deletions
diff --git a/contrib/pjdfstest/tests/unlink/00.t b/contrib/pjdfstest/tests/unlink/00.t new file mode 100644 index 0000000..0b9b1f1 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/00.t @@ -0,0 +1,212 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink removes regular files, symbolic links, fifos and sockets" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..112" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +expect 0 create ${n0} 0644 +expect regular lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +expect 0 symlink ${n1} ${n0} +expect symlink lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +expect 0 mkfifo ${n0} 0644 +expect fifo lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +expect 0 mknod ${n0} b 0644 1 2 +expect block lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +expect 0 mknod ${n0} c 0644 1 2 +expect char lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +expect 0 bind ${n0} +expect socket lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +# successful unlink(2) updates ctime. +expect 0 create ${n0} 0644 +expect 0 link ${n0} ${n1} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +expect 0 mkfifo ${n0} 0644 +expect 0 link ${n0} ${n1} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +expect 0 mknod ${n0} b 0644 1 2 +expect 0 link ${n0} ${n1} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +expect 0 mknod ${n0} c 0644 1 2 +expect 0 link ${n0} ${n1} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +expect 0 bind ${n0} +expect 0 link ${n0} ${n1} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +# unsuccessful unlink(2) does not update ctime. +expect 0 create ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 unlink ${n0} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +expect 0 mkfifo ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 unlink ${n0} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +expect 0 mknod ${n0} b 0644 1 2 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 unlink ${n0} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +expect 0 mknod ${n0} c 0644 1 2 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 unlink ${n0} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +expect 0 bind ${n0} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 unlink ${n0} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 mkfifo ${n0}/${n1} 0644 +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 mknod ${n0}/${n1} b 0644 1 2 +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 mknod ${n0}/${n1} c 0644 1 2 +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 bind ${n0}/${n1} +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 symlink test ${n0}/${n1} +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 create ${n0} 0644 +expect 0 link ${n0} ${n1} +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/unlink/01.t b/contrib/pjdfstest/tests/unlink/01.t new file mode 100644 index 0000000..7e29671 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/01.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/01.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +expect ENOTDIR unlink ${n0}/${n1}/test +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/unlink/02.t b/contrib/pjdfstest/tests/unlink/02.t new file mode 100644 index 0000000..e624d98 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/02.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 unlink ${nx} +expect ENOENT unlink ${nx} +expect ENAMETOOLONG unlink ${nxx} diff --git a/contrib/pjdfstest/tests/unlink/03.t b/contrib/pjdfstest/tests/unlink/03.t new file mode 100644 index 0000000..f4c939e --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/03.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 unlink ${nx} +expect ENOENT unlink ${nx} +expect ENAMETOOLONG unlink ${nxx} + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/unlink/04.t b/contrib/pjdfstest/tests/unlink/04.t new file mode 100644 index 0000000..0717eaa --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/04.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns ENOENT if the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` +n1=`namegen` + +expect 0 create ${n0} 0644 +expect 0 unlink ${n0} +expect ENOENT unlink ${n0} +expect ENOENT unlink ${n1} diff --git a/contrib/pjdfstest/tests/unlink/05.t b/contrib/pjdfstest/tests/unlink/05.t new file mode 100644 index 0000000..91dccf9 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/05.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +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 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 chmod ${n1} 0755 +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/unlink/06.t b/contrib/pjdfstest/tests/unlink/06.t new file mode 100644 index 0000000..2937429 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/06.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EACCES when write permission is denied on the directory containing the link to be removed" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +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 chmod ${n1} 0555 +expect EACCES -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 chmod ${n1} 0755 +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/unlink/07.t b/contrib/pjdfstest/tests/unlink/07.t new file mode 100644 index 0000000..e63eafa --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/07.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP unlink ${n0}/test +expect ELOOP unlink ${n1}/test +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/unlink/08.t b/contrib/pjdfstest/tests/unlink/08.t new file mode 100644 index 0000000..666400c --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/08.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink may return EPERM if the named file is a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 mkdir ${n0} 0755 +todo Linux "According to POSIX: EPERM - The file named by path is a directory, and either the calling process does not have appropriate privileges, or the implementation prohibits using unlink() on directories." +expect "0|EPERM" unlink ${n0} +expect "0|ENOENT" rmdir ${n0} diff --git a/contrib/pjdfstest/tests/unlink/09.t b/contrib/pjdfstest/tests/unlink/09.t new file mode 100644 index 0000000..dbc202a --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/09.t @@ -0,0 +1,65 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EPERM if the named file has its immutable, undeletable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..15" + ;; +FreeBSD:UFS) + echo "1..30" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM unlink ${n0} +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect EPERM unlink ${n0} +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_APPEND +todo FreeBSD:ZFS "Removing a file protected by SF_APPEND should return EPERM." +expect EPERM unlink ${n0} +todo FreeBSD:ZFS "Removing a file protected by SF_APPEND should return EPERM." +expect 0 chflags ${n0} none +todo FreeBSD:ZFS "Removing a file protected by SF_APPEND should return EPERM." +expect 0 unlink ${n0} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM unlink ${n0} + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect EPERM unlink ${n0} + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_APPEND + expect EPERM unlink ${n0} + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/unlink/10.t b/contrib/pjdfstest/tests/unlink/10.t new file mode 100644 index 0000000..9ca1d5b --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/10.t @@ -0,0 +1,67 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EPERM if the parent directory of the named file has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..16" + ;; +FreeBSD:UFS) + echo "1..30" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 create ${n0}/${n1} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM unlink ${n0}/${n1} +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +expect 0 create ${n0}/${n1} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 unlink ${n0}/${n1} +expect 0 chflags ${n0} none + +expect 0 create ${n0}/${n1} 0644 +expect 0 chflags ${n0} SF_APPEND +todo FreeBSD:ZFS "Removing a file from a directory protected by SF_APPEND should return EPERM." +expect EPERM unlink ${n0}/${n1} +expect 0 chflags ${n0} none +todo FreeBSD:ZFS "Removing a file from a directory protected by SF_APPEND should return EPERM." +expect 0 unlink ${n0}/${n1} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 create ${n0}/${n1} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM unlink ${n0}/${n1} + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n1} + + expect 0 create ${n0}/${n1} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 unlink ${n0}/${n1} + expect 0 chflags ${n0} none + + expect 0 create ${n0}/${n1} 0644 + expect 0 chflags ${n0} UF_APPEND + expect EPERM unlink ${n0}/${n1} + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n1} + ;; +esac + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/unlink/11.t b/contrib/pjdfstest/tests/unlink/11.t new file mode 100644 index 0000000..d7d71d8 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/11.t @@ -0,0 +1,63 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EACCES or EPERM if the directory containing the file is marked sticky, and neither the containing directory nor the file to be removed are owned by the effective user ID" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..270" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +expect 0 mkdir ${n0} 0755 +expect 0 chmod ${n0} 01777 +expect 0 chown ${n0} 65534 65534 + +for type in regular fifo block char socket symlink; do + # User owns both: the sticky directory and the file. + expect 0 chown ${n0} 65534 65534 + create_file ${type} ${n0}/${n1} 65534 65534 + expect ${type},65534,65534 lstat ${n0}/${n1} type,uid,gid + expect 0 -u 65534 -g 65534 unlink ${n0}/${n1} + expect ENOENT lstat ${n0}/${n1} type + + # User owns the sticky directory, but doesn't own the file. + for id in 0 65533; do + expect 0 chown ${n0} 65534 65534 + create_file ${type} ${n0}/${n1} ${id} ${id} + expect ${type},${id},${id} lstat ${n0}/${n1} type,uid,gid + expect 0 -u 65534 -g 65534 unlink ${n0}/${n1} + expect ENOENT lstat ${n0}/${n1} type + done + + # User owns the file, but doesn't own the sticky directory. + for id in 0 65533; do + expect 0 chown ${n0} ${id} ${id} + create_file ${type} ${n0}/${n1} 65534 65534 + expect ${type},65534,65534 lstat ${n0}/${n1} type,uid,gid + expect 0 -u 65534 -g 65534 unlink ${n0}/${n1} + expect ENOENT lstat ${n0}/${n1} type + done + + # User doesn't own the sticky directory nor the file. + for id in 0 65533; do + expect 0 chown ${n0} ${id} ${id} + create_file ${type} ${n0}/${n1} ${id} ${id} + expect ${type},${id},${id} lstat ${n0}/${n1} type,uid,gid + expect "EACCES|EPERM" -u 65534 -g 65534 unlink ${n0}/${n1} + expect ${type},${id},${id} lstat ${n0}/${n1} type,uid,gid + expect 0 unlink ${n0}/${n1} + done +done + +expect 0 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/unlink/12.t b/contrib/pjdfstest/tests/unlink/12.t new file mode 100644 index 0000000..ae39724 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/12.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..5" + +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} || exit +expect 0 create ${n0}/${n1} 0644 +mount -ur /dev/md${n} +expect EROFS unlink ${n0}/${n1} +mount -uw /dev/md${n} +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/unlink/13.t b/contrib/pjdfstest/tests/unlink/13.t new file mode 100644 index 0000000..c424b7e --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/13.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT unlink NULL +expect EFAULT unlink DEADCODE |