diff options
Diffstat (limited to 'meta/recipes-extended/libarchive/files/0002-Fix-extracting-hardlinks-over-symlinks.patch')
-rw-r--r-- | meta/recipes-extended/libarchive/files/0002-Fix-extracting-hardlinks-over-symlinks.patch | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/meta/recipes-extended/libarchive/files/0002-Fix-extracting-hardlinks-over-symlinks.patch b/meta/recipes-extended/libarchive/files/0002-Fix-extracting-hardlinks-over-symlinks.patch deleted file mode 100644 index 37418632f3..0000000000 --- a/meta/recipes-extended/libarchive/files/0002-Fix-extracting-hardlinks-over-symlinks.patch +++ /dev/null | |||
@@ -1,120 +0,0 @@ | |||
1 | From ece28103885a079a129a23c5001252a1648517af Mon Sep 17 00:00:00 2001 | ||
2 | From: Martin Matuska <martin@matuska.org> | ||
3 | Date: Tue, 29 Nov 2016 16:55:41 +0100 | ||
4 | Subject: [PATCH 2/2] Fix extracting hardlinks over symlinks | ||
5 | |||
6 | Closes #821 | ||
7 | |||
8 | Upstream-Status: Backported | ||
9 | |||
10 | Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com> | ||
11 | --- | ||
12 | libarchive/archive_write_disk_posix.c | 43 +++++++++++++++++++++++++++++++++++ | ||
13 | tar/test/test_symlink_dir.c | 18 ++++++++++++++- | ||
14 | 2 files changed, 60 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c | ||
17 | index d786bc2..80b03cd 100644 | ||
18 | --- a/libarchive/archive_write_disk_posix.c | ||
19 | +++ b/libarchive/archive_write_disk_posix.c | ||
20 | @@ -2563,6 +2563,49 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr, int | ||
21 | break; | ||
22 | } | ||
23 | tail[0] = c; | ||
24 | + } else if ((flags & | ||
25 | + ARCHIVE_EXTRACT_SECURE_SYMLINKS) == 0) { | ||
26 | + /* | ||
27 | + * We are not the last element and we want to | ||
28 | + * follow symlinks if they are a directory. | ||
29 | + * | ||
30 | + * This is needed to extract hardlinks over | ||
31 | + * symlinks. | ||
32 | + */ | ||
33 | + r = stat(head, &st); | ||
34 | + if (r != 0) { | ||
35 | + tail[0] = c; | ||
36 | + if (errno == ENOENT) { | ||
37 | + break; | ||
38 | + } else { | ||
39 | + fsobj_error(a_eno, a_estr, | ||
40 | + errno, | ||
41 | + "Could not stat %s", path); | ||
42 | + res = (ARCHIVE_FAILED); | ||
43 | + break; | ||
44 | + } | ||
45 | + } else if (S_ISDIR(st.st_mode)) { | ||
46 | + if (chdir(head) != 0) { | ||
47 | + tail[0] = c; | ||
48 | + fsobj_error(a_eno, a_estr, | ||
49 | + errno, | ||
50 | + "Could not chdir %s", path); | ||
51 | + res = (ARCHIVE_FATAL); | ||
52 | + break; | ||
53 | + } | ||
54 | + /* | ||
55 | + * Our view is now from inside | ||
56 | + * this dir: | ||
57 | + */ | ||
58 | + head = tail + 1; | ||
59 | + } else { | ||
60 | + tail[0] = c; | ||
61 | + fsobj_error(a_eno, a_estr, 0, | ||
62 | + "Cannot extract through " | ||
63 | + "symlink %s", path); | ||
64 | + res = ARCHIVE_FAILED; | ||
65 | + break; | ||
66 | + } | ||
67 | } else { | ||
68 | tail[0] = c; | ||
69 | fsobj_error(a_eno, a_estr, 0, | ||
70 | diff --git a/tar/test/test_symlink_dir.c b/tar/test/test_symlink_dir.c | ||
71 | index 25bd8b1..852e00b 100644 | ||
72 | --- a/tar/test/test_symlink_dir.c | ||
73 | +++ b/tar/test/test_symlink_dir.c | ||
74 | @@ -47,11 +47,18 @@ DEFINE_TEST(test_symlink_dir) | ||
75 | assertMakeDir("source/dir3", 0755); | ||
76 | assertMakeDir("source/dir3/d3", 0755); | ||
77 | assertMakeFile("source/dir3/f3", 0755, "abcde"); | ||
78 | + assertMakeDir("source/dir4", 0755); | ||
79 | + assertMakeFile("source/dir4/file3", 0755, "abcdef"); | ||
80 | + assertMakeHardlink("source/dir4/file4", "source/dir4/file3"); | ||
81 | |||
82 | assertEqualInt(0, | ||
83 | systemf("%s -cf test.tar -C source dir dir2 dir3 file file2", | ||
84 | testprog)); | ||
85 | |||
86 | + /* Second archive with hardlinks */ | ||
87 | + assertEqualInt(0, | ||
88 | + systemf("%s -cf test2.tar -C source dir4", testprog)); | ||
89 | + | ||
90 | /* | ||
91 | * Extract with -x and without -P. | ||
92 | */ | ||
93 | @@ -118,9 +125,15 @@ DEFINE_TEST(test_symlink_dir) | ||
94 | assertMakeSymlink("dest2/file2", "real_file2"); | ||
95 | assertEqualInt(0, systemf("%s -xPf test.tar -C dest2", testprog)); | ||
96 | |||
97 | - /* dest2/dir symlink should be followed */ | ||
98 | + /* "dir4" is a symlink to existing "real_dir" */ | ||
99 | + if (canSymlink()) | ||
100 | + assertMakeSymlink("dest2/dir4", "real_dir"); | ||
101 | + assertEqualInt(0, systemf("%s -xPf test2.tar -C dest2", testprog)); | ||
102 | + | ||
103 | + /* dest2/dir and dest2/dir4 symlinks should be followed */ | ||
104 | if (canSymlink()) { | ||
105 | assertIsSymlink("dest2/dir", "real_dir"); | ||
106 | + assertIsSymlink("dest2/dir4", "real_dir"); | ||
107 | assertIsDir("dest2/real_dir", -1); | ||
108 | } | ||
109 | |||
110 | @@ -141,4 +154,7 @@ DEFINE_TEST(test_symlink_dir) | ||
111 | /* dest2/file2 symlink should be removed */ | ||
112 | failure("Symlink to non-existing file should be removed"); | ||
113 | assertIsReg("dest2/file2", -1); | ||
114 | + | ||
115 | + /* dest2/dir4/file3 and dest2/dir4/file4 should be hard links */ | ||
116 | + assertIsHardlink("dest2/dir4/file3", "dest2/dir4/file4"); | ||
117 | } | ||
118 | -- | ||
119 | 2.7.4 | ||
120 | |||