2005-11-17 18:21:31 +00:00
|
|
|
#!/bin/sh
|
2005-11-17 21:17:35 +00:00
|
|
|
# copy files/directories across file system boundaries
|
2005-11-17 18:21:31 +00:00
|
|
|
# and make sure acls are preserved appropriately
|
|
|
|
|
|
2011-01-01 11:37:32 +01:00
|
|
|
# Copyright (C) 2005-2011 Free Software Foundation, Inc.
|
2006-08-17 19:58:17 +00:00
|
|
|
|
2007-07-23 14:35:58 +02:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2006-08-17 19:58:17 +00:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-23 14:35:58 +02:00
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
2006-08-17 19:58:17 +00:00
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-07-23 14:35:58 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-08-17 19:58:17 +00:00
|
|
|
|
2010-11-14 12:07:57 +01:00
|
|
|
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
2010-11-17 21:38:38 +01:00
|
|
|
print_ver_ mv getfacl setfacl
|
2010-11-14 12:02:39 +01:00
|
|
|
|
2007-11-29 08:55:47 +01:00
|
|
|
require_acl_
|
2005-11-17 18:21:31 +00:00
|
|
|
|
2008-02-12 18:45:54 +01:00
|
|
|
# Skip this test if cp was built without ACL support:
|
2010-01-22 19:26:16 +00:00
|
|
|
grep '^#define USE_ACL 1' $CONFIG_HEADER > /dev/null ||
|
2011-06-14 16:22:41 +02:00
|
|
|
skip_ "insufficient ACL support"
|
2008-02-12 18:45:54 +01:00
|
|
|
|
2011-08-04 20:52:31 +02:00
|
|
|
mkdir -p a b || framework_failure_
|
|
|
|
|
touch a/file || framework_failure_
|
2005-11-17 18:21:31 +00:00
|
|
|
|
2006-08-16 21:53:56 +00:00
|
|
|
# Ensure that setfacl and getfacl work on this file system.
|
2009-09-21 08:43:03 +01:00
|
|
|
skip=no
|
|
|
|
|
acl1=`cd a && getfacl file` || skip=yes
|
2006-08-16 21:53:56 +00:00
|
|
|
setfacl -m user:bin:rw a/file 2> /dev/null || skip=yes
|
|
|
|
|
test $skip = yes &&
|
2011-06-14 16:22:41 +02:00
|
|
|
skip_ "'.' is not on a suitable file system for this test"
|
2006-08-16 21:53:56 +00:00
|
|
|
|
|
|
|
|
# copy a file without preserving permissions
|
2005-11-17 18:21:31 +00:00
|
|
|
cp a/file b/ || fail=1
|
2011-08-04 20:52:31 +02:00
|
|
|
acl2=`cd b && getfacl file` || framework_failure_
|
2006-08-16 10:00:07 +00:00
|
|
|
test "$acl1" = "$acl2" || fail=1
|
2005-11-17 18:21:31 +00:00
|
|
|
|
2009-09-21 08:43:03 +01:00
|
|
|
# Update with acl set above
|
2011-08-04 20:52:31 +02:00
|
|
|
acl1=`cd a && getfacl file` || framework_failure_
|
2009-09-21 08:43:03 +01:00
|
|
|
|
|
|
|
|
# copy a file, preserving permissions
|
2005-11-17 18:21:31 +00:00
|
|
|
cp -p a/file b/ || fail=1
|
2011-08-04 20:52:31 +02:00
|
|
|
acl2=`cd b && getfacl file` || framework_failure_
|
2006-08-16 10:00:07 +00:00
|
|
|
test "$acl1" = "$acl2" || fail=1
|
2005-11-17 18:21:31 +00:00
|
|
|
|
2009-09-21 08:43:03 +01:00
|
|
|
# copy a file, preserving permissions, with --attributes-only
|
2011-08-04 20:52:31 +02:00
|
|
|
echo > a/file || framework_failure_ # add some data
|
|
|
|
|
test -s a/file || framework_failure_
|
2009-09-21 08:43:03 +01:00
|
|
|
cp -p --attributes-only a/file b/ || fail=1
|
|
|
|
|
test -s b/file && fail=1
|
2011-08-04 20:52:31 +02:00
|
|
|
acl2=`cd b && getfacl file` || framework_failure_
|
2009-09-21 08:43:03 +01:00
|
|
|
test "$acl1" = "$acl2" || fail=1
|
|
|
|
|
|
2008-09-07 10:31:27 +02:00
|
|
|
Exit $fail
|