Add/fix copyright notices and adjust to latest GNU FDL.
[platform/upstream/coreutils.git] / tests / cp / acl
1 #!/bin/sh
2 # copy files/directories across file system boundaries
3 # and make sure acls are preserved appropriately
4
5 # Copyright (C) 2005, 2006 Free Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21
22 . $srcdir/../acl
23 # Make sure we get English translations.
24 . $srcdir/../lang-default
25
26 if test "$VERBOSE" = yes; then
27   set -x
28   mv --version
29   getfacl --version
30   setfacl --version
31 fi
32
33 pwd=`pwd`
34 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
35 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
36 trap '(exit $?); exit $?' 1 2 13 15
37
38 framework_failure=0
39 mkdir -p $tmp || framework_failure=1
40 cd $tmp || framework_failure=1
41
42 mkdir -p a b || framework_failure=1
43 touch a/file || framework_failure=1
44
45 if test $framework_failure = 1; then
46   echo 'failure in testing framework'
47   (exit 1); exit 1
48 fi
49
50 skip=no
51 # Ensure that setfacl and getfacl work on this file system.
52 setfacl -m user:bin:rw a/file 2> /dev/null || skip=yes
53 acl1=`cd a && getfacl file | grep -v ':bin:' | grep -v 'mask::'` \
54   || skip=yes
55
56 test $skip = yes &&
57   {
58     echo "$0: '.' is not on a suitable file system for this test" 1>&2
59     echo "$0: skipping this test" 1>&2
60     (exit 77); exit 77
61   }
62
63 # copy a file without preserving permissions
64 cp a/file b/ || fail=1
65
66 acl2=`cd b && getfacl file` || framework_failure=1
67 test "$acl1" = "$acl2" || fail=1
68 rm a/file || framework_failure=1
69
70 # copy a file, preserving permissions
71 touch a/file || framework_failure=1
72 setfacl -m user:bin:rw a/file || framework_failure=1
73 acl1=`cd a && getfacl file` || framework_failure=1
74 cp -p a/file b/ || fail=1
75 acl2=`cd b && getfacl file` || framework_failure=1
76 test "$acl1" = "$acl2" || fail=1
77
78 if test $framework_failure = 1; then
79   echo 'failure in testing framework'
80   (exit 1); exit 1
81 fi
82
83 exit $fail