2 # Ensure that cp --parents works properly with a preexisting dest. directory
4 # Copyright (C) 2008-2009 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 if test "$VERBOSE" = yes; then
26 working_umask_or_skip_
28 mkdir -p a/b/c a/b/d e || framework_failure
29 touch a/b/c/foo a/b/d/foo || framework_failure
30 cp -p --parent a/b/c/foo e || framework_failure
32 # Make permissions of e/a different, so that we exercise the
33 # code in cp -p --parents that propagates permissions even
34 # to a destination directory that it doesn't create.
35 chmod g-rx e/a e/a/b || framework_failure
37 cp -p --parent a/b/d/foo e || fail=1
39 # Ensure that permissions on just-created directory, e/a/,
40 # are the same as those on original, a/.
42 # The sed filter maps any 's' from an inherited set-GID bit
43 # to the usual 'x'. Otherwise, under unusual circumstances, this
44 # test would fail with e.g., drwxr-sr-x != drwxr-xr-x .
45 # For reference, the unusual circumstances is: build dir is set-gid,
46 # so "a/" inherits that. However, when the user does not belong to
47 # the group of the build directory, chmod ("a/e", 02755) returns 0,
48 # yet fails to set the S_ISGID bit.
49 for dir in a a/b a/b/d; do
50 test $(stat --printf %A $dir|sed s/s/x/g) \
51 = $(stat --printf %A e/$dir|sed s/s/x/g) ||