.
[coreutils.git] / tests / cp / fail-perm
blob160b1e76a2ad656c07b856f185c307f45cf2e098
1 #!/bin/sh
3 pwd=`pwd`
4 tmp=fail-perm.$$
5 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
6 trap 'exit $?' 1 2 13 15
8 framework_failure=0
9 mkdir $tmp || framework_failure=1
10 cd $tmp || framework_failure=1
12 mkdir D || framework_failure=1
13 touch D/a || framework_failure=1
14 chmod 0 D/a || framework_failure=1
15 chmod 500 D || framework_failure=1
17 touch file || framework_failure=1
18 chmod u-w file || framework_failure=1
19 (echo foo >> file) >/dev/null 2>&1 && {
20 echo '********************************************'
21 echo "$0: NOTICE: This test case cannot be run as root."
22 echo '********************************************'
23 exit 77
26 if test $framework_failure = 1; then
27 echo 'failure in testing framework'
28 exit 1
31 fail=0
33 # This is expected to exit non-zero, because it can't read D/a.
34 cp -pR D DD > /dev/null 2>&1 && fail=1
36 # Permissions on DD must be `dr-x------'
38 set X `ls -ld DD`
39 shift
40 test "$1" = dr-x------ || fail=1
41 chmod 700 D
43 (exit $fail); exit