blob: 0f2e89112388b3d60018f0949a94fb6dad21677f [file] [log] [blame]
Denys Vlasenkobf224752009-11-29 19:09:29 +01001#!/bin/sh
2# Copyright 2009 by Denys Vlasenko
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02003# Licensed under GPLv2, see file LICENSE in this source tree.
Denys Vlasenkobf224752009-11-29 19:09:29 +01004
5. ./testing.sh
Denys Vlasenko8d718682021-08-16 00:48:50 +02006test -f "$bindir/.config" && . "$bindir/.config"
Denys Vlasenkobf224752009-11-29 19:09:29 +01007
Dan Fandrich775965d2010-08-10 23:33:57 -07008unset LANG
9unset LANGUAGE
10unset LC_COLLATE
11unset LC_ALL
12umask 022
13
Denys Vlasenkobf224752009-11-29 19:09:29 +010014# testing "test name" "script" "expected result" "file input" "stdin"
15
Denys Vlasenko8d718682021-08-16 00:48:50 +020016testing "tar Empty file is not a tarball" '\
Denys Vlasenko0545e3b2013-11-19 17:17:48 +010017tar xvf - 2>&1; echo $?
18' "\
19tar: short read
201
21" \
22"" ""
23SKIP=
24
Denys Vlasenko0ad872b2016-06-20 01:40:19 +020025optional FEATURE_SEAMLESS_GZ GUNZIP
Denys Vlasenko198b02f2013-12-31 23:22:36 +010026# In NOMMU case, "invalid magic" message comes from gunzip child process.
27# Otherwise, it comes from tar.
28# Need to fix output up to avoid false positive.
Denys Vlasenko8d718682021-08-16 00:48:50 +020029testing "tar Empty file is not a tarball.tar.gz" '\
Denys Vlasenko198b02f2013-12-31 23:22:36 +010030{ tar xvzf - 2>&1; echo $?; } | grep -Fv "invalid magic"
Denys Vlasenko1cbc6422013-11-19 14:52:02 +010031' "\
Denys Vlasenko1cbc6422013-11-19 14:52:02 +010032tar: short read
331
34" \
35"" ""
36SKIP=
37
Denys Vlasenko8d718682021-08-16 00:48:50 +020038testing "tar Two zeroed blocks is a ('truncated') empty tarball" '\
Denys Vlasenko76258112013-12-31 23:25:46 +010039dd if=/dev/zero bs=512 count=2 2>/dev/null | tar xvf - 2>&1; echo $?
Denys Vlasenko0545e3b2013-11-19 17:17:48 +010040' "\
410
42" \
43"" ""
44SKIP=
45
Denys Vlasenko8d718682021-08-16 00:48:50 +020046testing "tar Twenty zeroed blocks is an empty tarball" '\
Denys Vlasenko0545e3b2013-11-19 17:17:48 +010047dd if=/dev/zero bs=512 count=20 2>/dev/null | tar xvf - 2>&1; echo $?
48' "\
490
50" \
51"" ""
52SKIP=
53
Denys Vlasenkob920a382017-07-24 17:20:13 +020054mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenko6c563e32015-10-22 01:07:13 +020055# "tar cf test.tar input input_dir/ input_hard1 input_hard2 input_hard1 input_dir/ input":
56# GNU tar 1.26 records as hardlinks:
57# input_hard2 -> input_hard1
58# input_hard1 -> input_hard1 (!!!)
59# input_dir/file -> input_dir/file
60# input -> input
61# As of 1.24.0, we don't record last two: for them, nlink==1
62# and we check for "hardlink"ness only files with nlink!=1
63# We also don't use "hrw-r--r--" notation for hardlinks in "tar tv" listing.
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +020064optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES
Denys Vlasenko02365a62010-04-09 10:52:52 +020065testing "tar hardlinks and repeated files" '\
Denys Vlasenko425ad9c2009-12-16 22:46:01 +010066>input_hard1
Denys Vlasenkobf224752009-11-29 19:09:29 +010067ln input_hard1 input_hard2
68mkdir input_dir
69>input_dir/file
Denys Vlasenko02365a62010-04-09 10:52:52 +020070chmod -R 644 *
71chmod 755 input_dir
Denys Vlasenkobf224752009-11-29 19:09:29 +010072tar cf test.tar input input_dir/ input_hard1 input_hard2 input_hard1 input_dir/ input
Denys Vlasenko02365a62010-04-09 10:52:52 +020073tar tvf test.tar | sed "s/.*[0-9] input/input/"
Denys Vlasenko6c563e32015-10-22 01:07:13 +020074rm -rf input_dir
Denys Vlasenko02365a62010-04-09 10:52:52 +020075tar xf test.tar 2>&1
76echo Ok: $?
77ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
78' "\
Denys Vlasenko425ad9c2009-12-16 22:46:01 +010079input
Denys Vlasenkobf224752009-11-29 19:09:29 +010080input_dir/
81input_dir/file
82input_hard1
83input_hard2 -> input_hard1
84input_hard1 -> input_hard1
85input_dir/
86input_dir/file
87input
Denys Vlasenko02365a62010-04-09 10:52:52 +020088Ok: 0
89-rw-r--r-- input_dir/file
90drwxr-xr-x input_dir
91-rw-r--r-- input_hard1
92-rw-r--r-- input_hard2
93" \
94"" ""
Denys Vlasenkoe3d90a92010-05-10 05:53:16 +020095SKIP=
Denys Vlasenkob920a382017-07-24 17:20:13 +020096cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Denys Vlasenko02365a62010-04-09 10:52:52 +020097
Denys Vlasenkob920a382017-07-24 17:20:13 +020098mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +020099optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES
Denys Vlasenko02365a62010-04-09 10:52:52 +0200100testing "tar hardlinks mode" '\
Denys Vlasenko02365a62010-04-09 10:52:52 +0200101>input_hard1
102chmod 741 input_hard1
103ln input_hard1 input_hard2
104mkdir input_dir
Denys Vlasenko02365a62010-04-09 10:52:52 +0200105ln input_hard1 input_dir
106ln input_hard2 input_dir
Dan Fandricheb2bf5b2010-09-02 18:38:00 -0700107chmod 550 input_dir
Denys Vlasenko0d7cb4c2010-09-03 17:22:56 +0200108# On some filesystems, input_dir/input_hard2 is returned by readdir
109# BEFORE input_dir/input_hard1! Thats why we cant just "tar cf ... input_*":
110tar cf test.tar input_dir/input_hard* input_hard*
Denys Vlasenko02365a62010-04-09 10:52:52 +0200111tar tvf test.tar | sed "s/.*[0-9] input/input/"
Dan Fandricheb2bf5b2010-09-02 18:38:00 -0700112chmod 770 input_dir
113rm -rf input_*
Denys Vlasenko02365a62010-04-09 10:52:52 +0200114tar xf test.tar 2>&1
115echo Ok: $?
Denys Vlasenko0d7cb4c2010-09-03 17:22:56 +0200116ls -l . input_dir/* | grep "input.*hard" | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
Denys Vlasenko02365a62010-04-09 10:52:52 +0200117' "\
Denys Vlasenko02365a62010-04-09 10:52:52 +0200118input_dir/input_hard1
119input_dir/input_hard2 -> input_dir/input_hard1
120input_hard1 -> input_dir/input_hard1
121input_hard2 -> input_dir/input_hard1
122Ok: 0
123-rwxr----x input_dir/input_hard1
124-rwxr----x input_dir/input_hard2
Denys Vlasenko02365a62010-04-09 10:52:52 +0200125-rwxr----x input_hard1
126-rwxr----x input_hard2
Denys Vlasenkobf224752009-11-29 19:09:29 +0100127" \
128"" ""
Denys Vlasenkoe3d90a92010-05-10 05:53:16 +0200129SKIP=
Denys Vlasenkob920a382017-07-24 17:20:13 +0200130cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Denys Vlasenkobf224752009-11-29 19:09:29 +0100131
Denys Vlasenkob920a382017-07-24 17:20:13 +0200132mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +0200133optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES
Denys Vlasenkoe69ad872010-04-09 14:11:45 +0200134testing "tar symlinks mode" '\
Denys Vlasenkoe69ad872010-04-09 14:11:45 +0200135>input_file
136chmod 741 input_file
137ln -s input_file input_soft
138mkdir input_dir
Denys Vlasenkoe69ad872010-04-09 14:11:45 +0200139ln input_file input_dir
140ln input_soft input_dir
Dan Fandricheb2bf5b2010-09-02 18:38:00 -0700141chmod 550 input_dir
Dan Fandrich80d80ba2010-09-11 00:28:50 -0700142tar cf test.tar input_dir/* input_[fs]*
Denys Vlasenkoe82cf332010-05-12 15:59:32 +0200143tar tvf test.tar | sed "s/.*[0-9] input/input/" | sort
Dan Fandricheb2bf5b2010-09-02 18:38:00 -0700144chmod 770 input_dir
145rm -rf input_*
Denys Vlasenkoe69ad872010-04-09 14:11:45 +0200146tar xf test.tar 2>&1
147echo Ok: $?
Dan Fandrich80d80ba2010-09-11 00:28:50 -0700148ls -l . input_dir/* | grep "input_[fs]" | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
Denys Vlasenkoe69ad872010-04-09 14:11:45 +0200149' "\
Denys Vlasenkoe69ad872010-04-09 14:11:45 +0200150input_dir/input_file
151input_dir/input_soft -> input_file
152input_file -> input_dir/input_file
153input_soft -> input_dir/input_soft
154Ok: 0
155-rwxr----x input_dir/input_file
156lrwxrwxrwx input_file
Denys Vlasenkoe69ad872010-04-09 14:11:45 +0200157-rwxr----x input_file
158lrwxrwxrwx input_file
159" \
160"" ""
Denys Vlasenkoe3d90a92010-05-10 05:53:16 +0200161SKIP=
Denys Vlasenkob920a382017-07-24 17:20:13 +0200162cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Denys Vlasenkoe69ad872010-04-09 14:11:45 +0200163
Denys Vlasenkob920a382017-07-24 17:20:13 +0200164mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenkoda138242010-05-11 12:02:48 +0200165optional FEATURE_TAR_CREATE FEATURE_TAR_LONG_OPTIONS
Denys Vlasenko8a936cf2009-12-16 23:18:59 +0100166testing "tar --overwrite" "\
Denys Vlasenko8a936cf2009-12-16 23:18:59 +0100167ln input input_hard
168tar cf test.tar input_hard
169echo WRONG >input
170# --overwrite opens 'input_hard' without unlinking,
171# thus 'input_hard' still linked to 'input' and we write 'Ok' into it
172tar xf test.tar --overwrite 2>&1 && cat input
173" "\
174Ok
175" \
176"Ok\n" ""
Chris Metcalf208d35d2010-04-02 09:57:27 +0200177SKIP=
Denys Vlasenkob920a382017-07-24 17:20:13 +0200178cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Denys Vlasenko8a936cf2009-12-16 23:18:59 +0100179
Denys Vlasenkob920a382017-07-24 17:20:13 +0200180mkdir tar.tempdir && cd tar.tempdir || exit 1
Dan Fandrich80d80ba2010-09-11 00:28:50 -0700181test x"$SKIP_KNOWN_BUGS" = x"" && {
Dan Fandrich8d789e42010-09-05 16:16:46 +0200182# Needs to be run under non-root for meaningful test
183optional FEATURE_TAR_CREATE
184testing "tar writing into read-only dir" '\
Dan Fandrich8d789e42010-09-05 16:16:46 +0200185mkdir input_dir
186>input_dir/input_file
187chmod 550 input_dir
188tar cf test.tar input_dir
189tar tvf test.tar | sed "s/.*[0-9] input/input/"
190chmod 770 input_dir
191rm -rf input_*
192tar xf test.tar 2>&1
193echo Ok: $?
194ls -l input_dir/* . | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
195chmod 770 input_dir
196' "\
197input_dir/
198input_dir/input_file
199Ok: 0
200-rw-r--r-- input_dir/input_file
201dr-xr-x--- input_dir
202" \
203"" ""
204SKIP=
Dan Fandrich80d80ba2010-09-11 00:28:50 -0700205}
Denys Vlasenkob920a382017-07-24 17:20:13 +0200206cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Dan Fandrich80d80ba2010-09-11 00:28:50 -0700207
Denys Vlasenkob920a382017-07-24 17:20:13 +0200208mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenkob8ab4b02011-02-06 20:02:15 +0100209# Had a bug where on extract autodetect first "switched off" -z
Denys Vlasenkoaef441c2011-02-06 20:01:11 +0100210# and then failed to recognize .tgz extension
Denys Vlasenkoecf25cb2016-06-20 11:04:04 +0200211optional FEATURE_TAR_CREATE FEATURE_SEAMLESS_GZ GUNZIP
Denys Vlasenkoaef441c2011-02-06 20:01:11 +0100212testing "tar extract tgz" "\
213dd count=1 bs=1M if=/dev/zero of=F0 2>/dev/null
214tar -czf F0.tgz F0
215rm F0
216tar -xzvf F0.tgz && echo Ok
217rm F0 || echo BAD
218" "\
219F0
220Ok
221" \
222"" ""
Denys Vlasenkob47b3ce2011-08-10 00:51:29 +0200223SKIP=
Denys Vlasenkob920a382017-07-24 17:20:13 +0200224cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Denys Vlasenkoaef441c2011-02-06 20:01:11 +0100225
Denys Vlasenkob920a382017-07-24 17:20:13 +0200226mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenkobb8d7db2012-03-06 16:57:01 +0100227# Do we detect XZ-compressed data (even w/o .tar.xz or txz extension)?
228# (the uuencoded hello_world.txz contains one empty file named "hello_world")
229optional UUDECODE FEATURE_TAR_AUTODETECT FEATURE_SEAMLESS_XZ
230testing "tar extract txz" "\
231uudecode -o input && tar tf input && echo Ok
232" "\
233hello_world
234Ok
235" \
236"" "\
237begin-base64 644 hello_world.txz
238/Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4AX/AEldADQZSe6ODIZQ3rSQ8kAJ
239SnMPTX+XWGKW3Yu/Rwqg4Ik5wqgQKgVH97J8yA8IvZ4ahaCQogUNHRkXibr2
240Q615wcb2G7fJU49AhWAAAAAAUA8gu9DyXfAAAWWADAAAAB5FXGCxxGf7AgAA
241AAAEWVo=
242====
243"
244SKIP=
Denys Vlasenkob920a382017-07-24 17:20:13 +0200245cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Denys Vlasenkobb8d7db2012-03-06 16:57:01 +0100246
Denys Vlasenkob920a382017-07-24 17:20:13 +0200247mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenko5e29e262011-03-01 17:21:07 +0100248# On extract, everything up to and including last ".." component is stripped
Denys Vlasenkob47b3ce2011-08-10 00:51:29 +0200249optional FEATURE_TAR_CREATE
Denys Vlasenko5e29e262011-03-01 17:21:07 +0100250testing "tar strips /../ on extract" "\
251rm -rf input_* test.tar 2>/dev/null
252mkdir input_dir
253echo Ok >input_dir/file
254tar cf test.tar ./../tar.tempdir/input_dir/../input_dir 2>&1
255rm -rf input_* 2>/dev/null
256tar -vxf test.tar 2>&1
257cat input_dir/file 2>&1
258" "\
Denys Vlasenkob80acf52011-03-02 01:21:02 +0100259tar: removing leading './../tar.tempdir/input_dir/../' from member names
Denys Vlasenko5e29e262011-03-01 17:21:07 +0100260input_dir/
261input_dir/file
262Ok
263" \
264"" ""
Denys Vlasenkob47b3ce2011-08-10 00:51:29 +0200265SKIP=
Denys Vlasenkob920a382017-07-24 17:20:13 +0200266cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Denys Vlasenko5e29e262011-03-01 17:21:07 +0100267
Denys Vlasenkob920a382017-07-24 17:20:13 +0200268mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenkoa9607482015-10-22 16:37:01 +0200269# attack.tar.bz2 has symlink pointing to a system file
270# followed by a regular file with the same name
271# containing "root::0:0::/root:/bin/sh":
272# lrwxrwxrwx root/root passwd -> /tmp/passwd
273# -rw-r--r-- root/root passwd
274# naive tar implementation may end up creating the symlink
275# and then writing into it.
276# The correct implementation unlinks target before
277# creating the second file.
278# We test that /tmp/passwd remains empty:
Denys Vlasenkobb0bf282016-06-19 21:54:04 +0200279optional UUDECODE FEATURE_TAR_AUTODETECT FEATURE_SEAMLESS_BZ2
Denys Vlasenkoa9607482015-10-22 16:37:01 +0200280testing "tar does not extract into symlinks" "\
281>>/tmp/passwd && uudecode -o input && tar xf input 2>&1 && rm passwd; cat /tmp/passwd; echo \$?
282" "\
Denys Vlasenkoa84db182018-02-20 15:57:45 +0100283tar: can't create symlink 'passwd' to '/tmp/passwd'
Denys Vlasenkoa9607482015-10-22 16:37:01 +02002840
285" \
286"" "\
287begin-base64 644 attack.tar.bz2
288QlpoOTFBWSZTWRVn/bIAAKt7hMqwAEBAAP2QAhB0Y96AAACACCAAlISgpqe0
289po0DIaDynqAkpDRP1ANAhiYNSPR8VchKhAz0AK59+DA6FcMKBggOARIJdVHL
290DGllrjs20ATUgR1HmccBX3EhoMnpMJaNyggmxgLDMz54lBnBTJO/1L1lbMS4
291l4/V8LDoe90yiWJhOJvIypgEfxdyRThQkBVn/bI=
292====
293"
294SKIP=
Denys Vlasenkob920a382017-07-24 17:20:13 +0200295cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
296
297mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenkoa9607482015-10-22 16:37:01 +0200298# And same with -k
Denys Vlasenkobb0bf282016-06-19 21:54:04 +0200299optional UUDECODE FEATURE_TAR_AUTODETECT FEATURE_SEAMLESS_BZ2
Denys Vlasenkoa9607482015-10-22 16:37:01 +0200300testing "tar -k does not extract into symlinks" "\
301>>/tmp/passwd && uudecode -o input && tar xf input -k 2>&1 && rm passwd; cat /tmp/passwd; echo \$?
302" "\
Denys Vlasenkoa84db182018-02-20 15:57:45 +0100303tar: can't create symlink 'passwd' to '/tmp/passwd'
Denys Vlasenkoa9607482015-10-22 16:37:01 +02003040
305" \
306"" "\
307begin-base64 644 attack.tar.bz2
308QlpoOTFBWSZTWRVn/bIAAKt7hMqwAEBAAP2QAhB0Y96AAACACCAAlISgpqe0
309po0DIaDynqAkpDRP1ANAhiYNSPR8VchKhAz0AK59+DA6FcMKBggOARIJdVHL
310DGllrjs20ATUgR1HmccBX3EhoMnpMJaNyggmxgLDMz54lBnBTJO/1L1lbMS4
311l4/V8LDoe90yiWJhOJvIypgEfxdyRThQkBVn/bI=
312====
313"
314SKIP=
Denys Vlasenkob920a382017-07-24 17:20:13 +0200315cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Denys Vlasenkoa9607482015-10-22 16:37:01 +0200316
Denys Vlasenko8d718682021-08-16 00:48:50 +0200317if test x"$CONFIG_UNICODE_USING_LOCALE" != x"y"; then
Denys Vlasenkob920a382017-07-24 17:20:13 +0200318mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenkodf25df72016-12-12 14:33:53 +0100319optional UNICODE_SUPPORT FEATURE_TAR_GNU_EXTENSIONS FEATURE_SEAMLESS_BZ2 FEATURE_TAR_AUTODETECT
Denys Vlasenko8d718682021-08-16 00:48:50 +0200320testing "tar Pax-encoded UTF8 names and symlinks" '\
Denys Vlasenko9655f952016-11-11 17:56:45 +0100321tar xvf ../tar.utf8.tar.bz2 2>&1; echo $?
322export LANG=en_US.UTF-8
Denys Vlasenko76de3252016-12-12 19:17:12 +0100323ls -l etc/ssl/certs/* | sed "s:.*etc/:etc/:" | sort
Denys Vlasenko9655f952016-11-11 17:56:45 +0100324unset LANG
325rm -rf etc usr
326' "\
327etc/ssl/certs/3b2716e5.0
328etc/ssl/certs/EBG_Elektronik_Sertifika_Hizmet_Sağlayıcısı.pem
329etc/ssl/certs/f80cc7f6.0
330usr/share/ca-certificates/mozilla/EBG_Elektronik_Sertifika_Hizmet_Sağlayıcısı.crt
3310
332etc/ssl/certs/3b2716e5.0 -> EBG_Elektronik_Sertifika_Hizmet_Sağlayıcısı.pem
Denys Vlasenkoa84db182018-02-20 15:57:45 +0100333etc/ssl/certs/EBG_Elektronik_Sertifika_Hizmet_Sağlayıcısı.pem -> /usr/share/ca-certificates/mozilla/EBG_Elektronik_Sertifika_Hizmet_Sağlayıcısı.crt
Denys Vlasenko9655f952016-11-11 17:56:45 +0100334etc/ssl/certs/f80cc7f6.0 -> EBG_Elektronik_Sertifika_Hizmet_Sağlayıcısı.pem
335" \
336"" ""
337SKIP=
Denys Vlasenkob920a382017-07-24 17:20:13 +0200338cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Denys Vlasenko8d718682021-08-16 00:48:50 +0200339fi
Denys Vlasenko9655f952016-11-11 17:56:45 +0100340
Denys Vlasenkob920a382017-07-24 17:20:13 +0200341mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenko57388232018-06-27 10:01:49 +0200342optional FEATURE_SEAMLESS_BZ2 FEATURE_TAR_AUTODETECT LS
Denys Vlasenko8d718682021-08-16 00:48:50 +0200343testing "tar Symlink attack: create symlink and then write through it" '\
Denys Vlasenkob920a382017-07-24 17:20:13 +0200344exec 2>&1
345uudecode -o input && tar xvf input; echo $?
346ls /tmp/bb_test_evilfile
347ls bb_test_evilfile
348ls symlink/bb_test_evilfile
349' "\
350anything.txt
351symlink
352symlink/bb_test_evilfile
Denys Vlasenkoa84db182018-02-20 15:57:45 +0100353tar: can't create symlink 'symlink' to '/tmp'
3541
Denys Vlasenkob920a382017-07-24 17:20:13 +0200355ls: /tmp/bb_test_evilfile: No such file or directory
356ls: bb_test_evilfile: No such file or directory
357symlink/bb_test_evilfile
358" \
359"" "\
360begin-base64 644 tar_symlink_attack.tar.bz2
361QlpoOTFBWSZTWZgs7bQAALT/hMmQAFBAAf+AEMAGJPPv32AAAIAIMAC5thlR
362omAjAmCMADQT1BqNE0AEwAAjAEwElTKeo9NTR6h6gaeoA0DQNLVdwZZ5iNTk
363AQwCAV6S00QFJYhrlfFkVCEDEGtgNVqYrI0uK3ggnt30gqk4e1TTQm5QIAKa
364SJqzRGSFLMmOloHSAcvLiFxxRiQtQZF+qPxbo173ZDISOAoNoPN4PQPhBhKS
365n8fYaKlioCTzL2oXYczyUUIP4u5IpwoSEwWdtoA=
366====
367"
368SKIP=
369cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
Denys Vlasenkobf224752009-11-29 19:09:29 +0100370
Harald van Dijk8c24af92018-05-22 17:34:31 +0200371mkdir tar.tempdir && cd tar.tempdir || exit 1
Denys Vlasenko332a1912018-06-27 14:35:56 +0200372optional FEATURE_TAR_CREATE
Denys Vlasenko8d718682021-08-16 00:48:50 +0200373testing "tar Symlinks and hardlinks coexist" '\
Harald van Dijk8c24af92018-05-22 17:34:31 +0200374mkdir dir
375>dir/a
376ln -s ../dir/a dir/b
377ln dir/b dir/c
378mkdir new
379tar cf - dir/* | tar -C new -xvf - 2>&1
380' "\
381dir/a
382dir/b
383dir/c
384" \
385"" ""
Denys Vlasenko332a1912018-06-27 14:35:56 +0200386SKIP=
Harald van Dijk8c24af92018-05-22 17:34:31 +0200387cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null
388
Denys Vlasenkobf224752009-11-29 19:09:29 +0100389exit $FAILCOUNT