1#!/bin/sh 2# move files/directories across file system boundaries 3# and make sure acls are preserved 4 5# Copyright (C) 2005-2023 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 <https://www.gnu.org/licenses/>. 19 20. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 21print_ver_ mv 22 23require_acl_ 24 25# Skip this test if cp was built without ACL support: 26grep '^#define USE_ACL 1' $CONFIG_HEADER > /dev/null || 27 skip_ "insufficient ACL support" 28 29cleanup_() { rm -rf "$other_partition_tmpdir"; } 30. "$abs_srcdir/tests/other-fs-tmpdir" 31 32touch file || framework_failure_ 33t1=$other_partition_tmpdir/t1 34touch $t1 || framework_failure_ 35 36skip_partition=none 37# Ensure that setfacl and getfacl work on this file system. 38setfacl -m user:bin:rw- file 2> /dev/null || skip_partition=. 39# And on the destination file system. 40setfacl -m user:bin:rw- $t1 || skip_partition=$other_partition_tmpdir 41acl1=$(getfacl file) || skip_partition=. 42 43test $skip_partition != none && 44 skip_ "'$skip_partition' is not on a suitable file system for this test" 45 46# move the access acl of a file 47mv file "$other_partition_tmpdir" || fail=1 48acl2=$(cd "$other_partition_tmpdir" && getfacl file) || framework_failure_ 49test "$acl1" = "$acl2" || fail=1 50 51# move the access acl of a directory 52mkdir dir || framework_failure_ 53setfacl -m user:bin:rw- dir || framework_failure_ 54acl1=$(getfacl dir) || framework_failure_ 55mv dir "$other_partition_tmpdir" || fail=1 56acl2=$(cd "$other_partition_tmpdir" && getfacl dir) || framework_failure_ 57test "$acl1" = "$acl2" || fail=1 58 59# move the default acl of a directory 60mkdir dir2 || framework_failure_ 61setfacl -d -m user:bin:rw- dir2 || framework_failure_ 62acl1=$(getfacl dir2) || framework_failure_ 63mv dir2 "$other_partition_tmpdir" || fail=1 64acl2=$(cd "$other_partition_tmpdir" && getfacl dir2) || framework_failure_ 65test "$acl1" = "$acl2" || fail=1 66 67Exit $fail 68