| 1 |
# Process this file with autom4te to create testsuite. -*- Autotest -*- |
| 2 |
# Test suite for GNU tar. |
| 3 |
# Copyright 2013-2023 Free Software Foundation, Inc. |
| 4 |
# |
| 5 |
# GNU tar is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation; either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# GNU tar is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
# Description: In tar 1.26 listed-incremental with -C and absolute path |
| 19 |
# would malfunction under certain conditions due to buggy filename |
| 20 |
# normalization. |
| 21 |
# |
| 22 |
# The value returned by normalize_filename() is used to populate the "caname" |
| 23 |
# field in both the "directory" structure in incremen.c and the "name" |
| 24 |
# structure in names.c, and in both cases that field is then used in the |
| 25 |
# "hash" and "compare" functions for the related hash tables. Thus, the |
| 26 |
# fact that the returned value doesn't reflect the operation of previous |
| 27 |
# "-C" options means that it's possible for two different directories to |
| 28 |
# be given the same "caname" value in the hashed structure and thus end up |
| 29 |
# being confused with each other. |
| 30 |
# |
| 31 |
# The bug is triggered when dumping both relative paths after -C and |
| 32 |
# absolute paths that match the process' current working directory. |
| 33 |
# |
| 34 |
# Reported by: Nathan Stratton Treadway <[email protected]> |
| 35 |
# References: <[email protected]>, |
| 36 |
# http://lists.gnu.org/archive/html/bug-tar/2013-09/msg00034.html |
| 37 |
|
| 38 |
AT_SETUP([filename normalization]) |
| 39 |
AT_KEYWORDS([incremental create incr08 chdir]) |
| 40 |
|
| 41 |
AT_TAR_WITH_HOOK( |
| 42 |
[AT_CHECK([ |
| 43 |
DIR=`pwd`/gnu/tartest |
| 44 |
sed "s|$DIR|ABSPATH|" stdout |
| 45 |
], |
| 46 |
[0], |
| 47 |
[A |
| 48 |
. |
| 49 |
./foo |
| 50 |
./foo/subdir |
| 51 |
./foo/subdir/dir1 |
| 52 |
./subdir |
| 53 |
./subdir/dir2 |
| 54 |
B |
| 55 |
./ |
| 56 |
./subdir/ |
| 57 |
./subdir/dir1/ |
| 58 |
ABSPATH/ |
| 59 |
ABSPATH/subdir/ |
| 60 |
ABSPATH/subdir/dir2/ |
| 61 |
]) |
| 62 |
|
| 63 |
AT_CHECK([ |
| 64 |
DIR=`pwd`/gnu/tartest |
| 65 |
sed "/tar: Removing leading \`\/*\/' from/d;s|$DIR|ABSPATH|" stderr], |
| 66 |
[0], |
| 67 |
[A |
| 68 |
B |
| 69 |
tar: .: Directory is new |
| 70 |
tar: ./subdir: Directory is new |
| 71 |
tar: ./subdir/dir1: Directory is new |
| 72 |
tar: ABSPATH: Directory is new |
| 73 |
tar: ABSPATH/subdir: Directory is new |
| 74 |
tar: ABSPATH/subdir/dir2: Directory is new |
| 75 |
])], |
| 76 |
[AT_TAR_CHECK([ |
| 77 |
AT_CHECK_TIMESTAMP |
| 78 |
AT_SORT_PREREQ |
| 79 |
mkdir tartest |
| 80 |
cd tartest |
| 81 |
mkdir foo |
| 82 |
mkdir foo/subdir |
| 83 |
mkdir foo/subdir/dir1 |
| 84 |
mkdir subdir |
| 85 |
mkdir subdir/dir2 |
| 86 |
decho A |
| 87 |
find .|sort |
| 88 |
|
| 89 |
decho B |
| 90 |
DIR=`pwd` |
| 91 |
tar -cvf ../foo.tar --listed-incremental=../foo.snar -C foo . $DIR |
| 92 |
], |
| 93 |
[0], |
| 94 |
[stdout], |
| 95 |
[stderr],[],[],[gnu])]) |
| 96 |
|
| 97 |
AT_CLEANUP |