doc: move @shortcontents and @contents from end to start
[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-2008 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 3 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, see <http://www.gnu.org/licenses/>.
19
20 # Make sure we get English translations.
21
22 if test "$VERBOSE" = yes; then
23   set -x
24   mv --version
25   getfacl --version
26   setfacl --version
27 fi
28
29 . $srcdir/test-lib.sh
30 require_acl_
31
32 # Skip this test if cp was built without ACL support:
33 grep '^#define USE_ACL 0' $CONFIG_HEADER > /dev/null &&
34   skip_test_ "insufficient ACL support"
35
36 mkdir -p a b || framework_failure
37 touch a/file || framework_failure
38
39 skip=no
40 # Ensure that setfacl and getfacl work on this file system.
41 setfacl -m user:bin:rw a/file 2> /dev/null || skip=yes
42 acl1=`cd a && getfacl file | grep -v ':bin:' | grep -v 'mask::'` \
43   || skip=yes
44
45 test $skip = yes &&
46   skip_test_ "'.' is not on a suitable file system for this test"
47
48 # copy a file without preserving permissions
49 cp a/file b/ || fail=1
50
51 acl2=`cd b && getfacl file` || framework_failure
52 test "$acl1" = "$acl2" || fail=1
53 rm a/file || framework_failure
54
55 # copy a file, preserving permissions
56 touch a/file || framework_failure
57 setfacl -m user:bin:rw a/file || framework_failure
58 acl1=`cd a && getfacl file` || framework_failure
59 cp -p a/file b/ || fail=1
60 acl2=`cd b && getfacl file` || framework_failure
61 test "$acl1" = "$acl2" || fail=1
62
63 Exit $fail