summaryrefslogtreecommitdiff
path: root/archivers/libarchive/files/tar
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/libarchive/files/tar')
-rw-r--r--archivers/libarchive/files/tar/bsdtar.148
-rw-r--r--archivers/libarchive/files/tar/bsdtar.c93
-rw-r--r--archivers/libarchive/files/tar/bsdtar.h1
-rw-r--r--archivers/libarchive/files/tar/cmdline.c1
-rw-r--r--archivers/libarchive/files/tar/test/CMakeLists.txt1
-rw-r--r--archivers/libarchive/files/tar/test/list.h1
-rw-r--r--archivers/libarchive/files/tar/test/test_basic.c4
-rw-r--r--archivers/libarchive/files/tar/test/test_copy.c4
-rw-r--r--archivers/libarchive/files/tar/test/test_option_C_mtree.c18
-rw-r--r--archivers/libarchive/files/tar/test/test_option_H_upper.c36
-rw-r--r--archivers/libarchive/files/tar/test/test_option_L_upper.c28
-rw-r--r--archivers/libarchive/files/tar/test/test_option_U_upper.c18
-rw-r--r--archivers/libarchive/files/tar/test/test_option_exclude_vcs.c230
-rw-r--r--archivers/libarchive/files/tar/test/test_option_n.c81
-rw-r--r--archivers/libarchive/files/tar/test/test_option_s.c18
-rw-r--r--archivers/libarchive/files/tar/test/test_strip_components.c11
-rw-r--r--archivers/libarchive/files/tar/test/test_symlink_dir.c26
-rw-r--r--archivers/libarchive/files/tar/write.c12
18 files changed, 513 insertions, 118 deletions
diff --git a/archivers/libarchive/files/tar/bsdtar.1 b/archivers/libarchive/files/tar/bsdtar.1
index 132e1145794..6d8d6d3d617 100644
--- a/archivers/libarchive/files/tar/bsdtar.1
+++ b/archivers/libarchive/files/tar/bsdtar.1
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 1, 2017
+.Dd June 3, 2019
.Dt TAR 1
.Os
.Sh NAME
@@ -198,15 +198,28 @@ options and before extracting any files.
.It Fl Fl clear-nochange-fflags
(x mode only)
Before removing file system objects to replace them, clear platform-specific
-file flags that might prevent removal.
+file attributes or file flags that might prevent removal.
.It Fl Fl exclude Ar pattern
Do not process files or directories that match the
specified pattern.
Note that exclusions take precedence over patterns or filenames
specified on the command line.
+.It Fl Fl exclude-vcs
+Do not process files or directories internally used by the
+version control systems
+.Sq CVS ,
+.Sq RCS ,
+.Sq SCCS ,
+.Sq SVN ,
+.Sq Arch ,
+.Sq Bazaar ,
+.Sq Mercurial
+and
+.Sq Darcs .
.It Fl Fl fflags
(c, r, u, x modes only)
-Archive or extract file flags. This is the reverse of
+Archive or extract platform-specific file attributes or file flags.
+This is the reverse of
.Fl Fl no-fflags
and the default behavior in c, r, and u modes or if
.Nm
@@ -377,8 +390,8 @@ Do not extract modification time.
By default, the modification time is set to the time stored in the archive.
.It Fl Fl mac-metadata
(c, r, u and x mode only)
-Mac OS X specific. Archive or extract extended ACLs and extended attributes
-using
+Mac OS X specific. Archive or extract extended ACLs and extended file
+attributes using
.Xr copyfile 3
in AppleDouble format. This is the reverse of
.Fl Fl no-mac-metadata .
@@ -386,8 +399,7 @@ and the default behavior in c, r, and u modes or if
.Nm
is run in x mode as root.
.It Fl n , Fl Fl norecurse , Fl Fl no-recursion
-(c, r, u modes only)
-Do not recursively archive the contents of directories.
+Do not operate recursively on the content of directories.
.It Fl Fl newer Ar date
(c, r, u modes only)
Only include files and directories newer than the specified date.
@@ -434,21 +446,21 @@ and the default behavior if
is run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes).
.It Fl Fl no-fflags
(c, r, u, x modes only)
-Do not archive or extract file flags. This is the reverse of
+Do not archive or extract file attributes or file flags. This is the reverse of
.Fl Fl fflags
and the default behavior if
.Nm
is run as non-root in x mode.
.It Fl Fl no-mac-metadata
(x mode only)
-Mac OS X specific. Do not archive or extract ACLs and extended attributes using
+Mac OS X specific. Do not archive or extract ACLs and extended file attributes
+using
.Xr copyfile 3
in AppleDouble format. This is the reverse of
.Fl Fl mac-metadata .
and the default behavior if
.Nm
is run as non-root in x mode.
-.It Fl n , Fl Fl norecurse , Fl Fl no-recursion
.It Fl Fl no-same-owner
(x mode only)
Do not extract owner and group IDs.
@@ -459,8 +471,8 @@ and the default behavior if
is run as non-root.
.It Fl Fl no-same-permissions
(x mode only)
-Do not extract full permissions (SGID, SUID, sticky bit, ACLs,
-extended attributes or extended file flags).
+Do not extract full permissions (SGID, SUID, sticky bit,
+file attributes or file flags, extended file attributes and ACLs).
This is the reverse of
.Fl p
and the default behavior if
@@ -468,7 +480,7 @@ and the default behavior if
is run as non-root.
.It Fl Fl no-xattrs
(c, r, u, x modes only)
-Do not archive or extract extended attributes. This is the reverse of
+Do not archive or extract extended file attributes. This is the reverse of
.Fl Fl xattrs
and the default behavior if
.Nm
@@ -656,13 +668,13 @@ This option suppresses these behaviors.
.It Fl p , Fl Fl insecure , Fl Fl preserve-permissions
(x mode only)
Preserve file permissions.
-Attempt to restore the full permissions, including owner, file modes, ACLs,
-extended attributes and extended file flags, if available, for each item
-extracted from the archive. This is te reverse of
+Attempt to restore the full permissions, including file modes, file attributes
+or file flags, extended file attributes and ACLs, if available, for each item
+extracted from the archive. This is the reverse of
.Fl Fl no-same-permissions
and the default if
.Nm
-is being run by root and can be partially overridden by also specifying
+is being run as root. It can be partially overridden by also specifying
.Fl Fl no-acls ,
.Fl Fl no-fflags ,
.Fl Fl no-mac-metadata
@@ -833,7 +845,7 @@ See
for more information about the handling of exclusions.
.It Fl Fl xattrs
(c, r, u, x modes only)
-Archive or extract extended attributes. This is the reverse of
+Archive or extract extended file attributes. This is the reverse of
.Fl Fl no-xattrs
and the default behavior in c, r, and u modes or if
.Nm
diff --git a/archivers/libarchive/files/tar/bsdtar.c b/archivers/libarchive/files/tar/bsdtar.c
index 963bd4f9ad5..b59963d0f82 100644
--- a/archivers/libarchive/files/tar/bsdtar.c
+++ b/archivers/libarchive/files/tar/bsdtar.c
@@ -129,6 +129,28 @@ static void version(void) __LA_DEAD;
(ARCHIVE_EXTRACT_SECURE_SYMLINKS \
| ARCHIVE_EXTRACT_SECURE_NODOTDOT)
+static char const * const vcs_files[] = {
+ /* CVS */
+ "CVS", ".cvsignore",
+ /* RCS */
+ "RCS",
+ /* SCCS */
+ "SCCS",
+ /* SVN */
+ ".svn",
+ /* git */
+ ".git", ".gitignore", ".gitattributes", ".gitmodules",
+ /* Arch */
+ ".arch-ids", "{arch}", "=RELEASE-ID", "=meta-update", "=update",
+ /* Bazaar */
+ ".bzr", ".bzrignore", ".bzrtags",
+ /* Mercurial */
+ ".hg", ".hgignore", ".hgtags",
+ /* darcs */
+ "_darcs",
+ NULL
+};
+
int
main(int argc, char **argv)
{
@@ -137,6 +159,7 @@ main(int argc, char **argv)
char compression, compression2;
const char *compression_name, *compression2_name;
const char *compress_program;
+ char *tptr;
char possible_help_request;
char buff[16];
@@ -270,10 +293,15 @@ main(int argc, char **argv)
/* libarchive doesn't need this; just ignore it. */
break;
case 'b': /* SUSv2 */
- t = atoi(bsdtar->argument);
- if (t <= 0 || t > 8192)
- lafe_errc(1, 0,
- "Argument to -b is out of range (1..8192)");
+ errno = 0;
+ tptr = NULL;
+ t = (int)strtol(bsdtar->argument, &tptr, 10);
+ if (errno || t <= 0 || t > 8192 ||
+ *(bsdtar->argument) == '\0' || tptr == NULL ||
+ *tptr != '\0') {
+ lafe_errc(1, 0, "Invalid or out of range "
+ "(1..8192) argument to -b");
+ }
bsdtar->bytes_per_block = 512 * t;
/* Explicit -b forces last block size. */
bsdtar->bytes_in_last_block = bsdtar->bytes_per_block;
@@ -312,6 +340,15 @@ main(int argc, char **argv)
lafe_errc(1, 0,
"Couldn't exclude %s\n", bsdtar->argument);
break;
+ case OPTION_EXCLUDE_VCS: /* GNU tar */
+ for(t=0; vcs_files[t]; t++) {
+ if (archive_match_exclude_pattern(
+ bsdtar->matching,
+ vcs_files[t]) != ARCHIVE_OK)
+ lafe_errc(1, 0, "Couldn't "
+ "exclude %s\n", vcs_files[t]);
+ }
+ break;
case OPTION_FFLAGS:
bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
bsdtar->readdisk_flags &= ~ARCHIVE_READDISK_NO_FFLAGS;
@@ -324,10 +361,13 @@ main(int argc, char **argv)
bsdtar->filename = bsdtar->argument;
break;
case OPTION_GID: /* cpio */
- t = atoi(bsdtar->argument);
- if (t < 0)
- lafe_errc(1, 0,
- "Argument to --gid must be positive");
+ errno = 0;
+ tptr = NULL;
+ t = (int)strtol(bsdtar->argument, &tptr, 10);
+ if (errno || t < 0 || *(bsdtar->argument) == '\0' ||
+ tptr == NULL || *tptr != '\0') {
+ lafe_errc(1, 0, "Invalid argument to --gid");
+ }
bsdtar->gid = t;
break;
case OPTION_GNAME: /* cpio */
@@ -623,12 +663,14 @@ main(int argc, char **argv)
break;
case OPTION_STRIP_COMPONENTS: /* GNU tar 1.15 */
errno = 0;
- bsdtar->strip_components = strtol(bsdtar->argument,
- NULL, 0);
- if (errno)
- lafe_errc(1, 0,
- "Invalid --strip-components argument: %s",
- bsdtar->argument);
+ tptr = NULL;
+ t = (int)strtol(bsdtar->argument, &tptr, 10);
+ if (errno || t < 0 || *(bsdtar->argument) == '\0' ||
+ tptr == NULL || *tptr != '\0') {
+ lafe_errc(1, 0, "Invalid argument to "
+ "--strip-components");
+ }
+ bsdtar->strip_components = t;
break;
case 'T': /* GNU tar */
bsdtar->names_from_file = bsdtar->argument;
@@ -648,10 +690,13 @@ main(int argc, char **argv)
set_mode(bsdtar, opt);
break;
case OPTION_UID: /* cpio */
- t = atoi(bsdtar->argument);
- if (t < 0)
- lafe_errc(1, 0,
- "Argument to --uid must be positive");
+ errno = 0;
+ tptr = NULL;
+ t = (int)strtol(bsdtar->argument, &tptr, 10);
+ if (errno || t < 0 || *(bsdtar->argument) == '\0' ||
+ tptr == NULL || *tptr != '\0') {
+ lafe_errc(1, 0, "Invalid argument to --uid");
+ }
bsdtar->uid = t;
break;
case OPTION_UNAME: /* cpio */
@@ -794,8 +839,6 @@ main(int argc, char **argv)
break;
}
}
- if (bsdtar->flags & OPTFLAG_NO_SUBDIRS)
- only_mode(bsdtar, "-n", "cru");
if (bsdtar->flags & OPTFLAG_STDOUT)
only_mode(bsdtar, "-O", "xt");
if (bsdtar->flags & OPTFLAG_UNLINK_FIRST)
@@ -845,6 +888,16 @@ main(int argc, char **argv)
only_mode(bsdtar, buff, "cru");
}
+ /*
+ * When creating an archive from a directory tree, the directory
+ * walking code will already avoid entering directories when
+ * recursive inclusion of directory content is disabled, therefore
+ * changing the matching behavior has no effect for creation modes.
+ * It is relevant for extraction or listing.
+ */
+ archive_match_set_inclusion_recursion(bsdtar->matching,
+ !(bsdtar->flags & OPTFLAG_NO_SUBDIRS));
+
/* Filename "-" implies stdio. */
if (strcmp(bsdtar->filename, "-") == 0)
bsdtar->filename = NULL;
diff --git a/archivers/libarchive/files/tar/bsdtar.h b/archivers/libarchive/files/tar/bsdtar.h
index 543a228c907..c61d568fd74 100644
--- a/archivers/libarchive/files/tar/bsdtar.h
+++ b/archivers/libarchive/files/tar/bsdtar.h
@@ -135,6 +135,7 @@ enum {
OPTION_CHROOT,
OPTION_CLEAR_NOCHANGE_FFLAGS,
OPTION_EXCLUDE,
+ OPTION_EXCLUDE_VCS,
OPTION_FFLAGS,
OPTION_FORMAT,
OPTION_GID,
diff --git a/archivers/libarchive/files/tar/cmdline.c b/archivers/libarchive/files/tar/cmdline.c
index 66cf4c2d196..21558e12df4 100644
--- a/archivers/libarchive/files/tar/cmdline.c
+++ b/archivers/libarchive/files/tar/cmdline.c
@@ -85,6 +85,7 @@ static const struct bsdtar_option {
{ "disable-copyfile", 0, OPTION_NO_MAC_METADATA },
{ "exclude", 1, OPTION_EXCLUDE },
{ "exclude-from", 1, 'X' },
+ { "exclude-vcs", 0, OPTION_EXCLUDE_VCS },
{ "extract", 0, 'x' },
{ "fast-read", 0, 'q' },
{ "fflags", 0, OPTION_FFLAGS },
diff --git a/archivers/libarchive/files/tar/test/CMakeLists.txt b/archivers/libarchive/files/tar/test/CMakeLists.txt
index d7de42d6ab6..459d9dcb1ef 100644
--- a/archivers/libarchive/files/tar/test/CMakeLists.txt
+++ b/archivers/libarchive/files/tar/test/CMakeLists.txt
@@ -40,6 +40,7 @@ IF(ENABLE_TAR AND ENABLE_TEST)
test_option_b.c
test_option_b64encode.c
test_option_exclude.c
+ test_option_exclude_vcs.c
test_option_fflags.c
test_option_gid_gname.c
test_option_grzip.c
diff --git a/archivers/libarchive/files/tar/test/list.h b/archivers/libarchive/files/tar/test/list.h
index b5397fae8ec..08f346cdf1d 100644
--- a/archivers/libarchive/files/tar/test/list.h
+++ b/archivers/libarchive/files/tar/test/list.h
@@ -24,6 +24,7 @@ DEFINE_TEST(test_option_b)
DEFINE_TEST(test_option_C_mtree)
DEFINE_TEST(test_option_C_upper)
DEFINE_TEST(test_option_exclude)
+DEFINE_TEST(test_option_exclude_vcs)
DEFINE_TEST(test_option_fflags)
DEFINE_TEST(test_option_gid_gname)
DEFINE_TEST(test_option_grzip)
diff --git a/archivers/libarchive/files/tar/test/test_basic.c b/archivers/libarchive/files/tar/test/test_basic.c
index 0008e1cfb70..9bb966a0cf8 100644
--- a/archivers/libarchive/files/tar/test/test_basic.c
+++ b/archivers/libarchive/files/tar/test/test_basic.c
@@ -42,7 +42,7 @@ make_files(void)
/* Symlink to above file. */
if (canSymlink())
- assertMakeSymlink("symlink", "file");
+ assertMakeSymlink("symlink", "file", 0);
/* Directory. */
assertMakeDir("dir", 0775);
@@ -78,7 +78,7 @@ verify_files(const char *target)
/* Symlink */
if (canSymlink())
- assertIsSymlink("symlink", "file");
+ assertIsSymlink("symlink", "file", 0);
/* dir */
failure("%s", target);
diff --git a/archivers/libarchive/files/tar/test/test_copy.c b/archivers/libarchive/files/tar/test/test_copy.c
index e6e31f45228..b828666b93f 100644
--- a/archivers/libarchive/files/tar/test/test_copy.c
+++ b/archivers/libarchive/files/tar/test/test_copy.c
@@ -176,7 +176,7 @@ create_tree(void)
sprintf(buff, "s/%s", filenames[i]);
sprintf(buff2, "../f/%s", filenames[i]);
failure("buff=\"%s\" buff2=\"%s\"", buff, buff2);
- assertMakeSymlink(buff, buff2);
+ assertMakeSymlink(buff, buff2, 0);
}
/* Create a dir named "d/abcdef...". */
buff[0] = 'd';
@@ -222,7 +222,7 @@ verify_tree(size_t limit)
sprintf(name1, "s/%s", filenames[i]);
sprintf(name2, "../f/%s", filenames[i]);
if (strlen(name2) <= limit)
- assertIsSymlink(name1, name2);
+ assertIsSymlink(name1, name2, 0);
}
/* Verify dir "d/abcdef...". */
diff --git a/archivers/libarchive/files/tar/test/test_option_C_mtree.c b/archivers/libarchive/files/tar/test/test_option_C_mtree.c
index caf8044bf93..ccadc389974 100644
--- a/archivers/libarchive/files/tar/test/test_option_C_mtree.c
+++ b/archivers/libarchive/files/tar/test/test_option_C_mtree.c
@@ -36,6 +36,9 @@ DEFINE_TEST(test_option_C_mtree)
p0 = NULL;
char *content = "./foo type=file uname=root gname=root mode=0755\n";
char *filename = "output.tar";
+#if defined(_WIN32) && !defined(CYGWIN)
+ char *p;
+#endif
/* an absolute path to mtree file */
char *mtree_file = "/METALOG.mtree";
@@ -48,9 +51,21 @@ DEFINE_TEST(test_option_C_mtree)
assertMakeDir("bar", 0775);
assertMakeFile("bar/foo", 0777, "abc");
- r = systemf("%s -cf %s -C bar \"@%s\" >step1.out 2>step1.err", testprog, filename, absolute_path);
+#if defined(_WIN32) && !defined(CYGWIN)
+ p = absolute_path;
+ while(*p != '\0') {
+ if (*p == '/')
+ *p = '\\';
+ p++;
+ }
+ r = systemf("%s -cf %s -C bar @%s >step1.out 2>step1.err", testprog, filename, absolute_path);
failure("Error invoking %s -cf %s -C bar @%s", testprog, filename, absolute_path);
+#else
+ r = systemf("%s -cf %s -C bar \"@%s\" >step1.out 2>step1.err", testprog, filename, absolute_path);
+ failure("Error invoking %s -cf %s -C bar \"@%s\"", testprog, filename, absolute_path);
+#endif
+
assertEqualInt(r, 0);
assertEmptyFile("step1.out");
assertEmptyFile("step1.err");
@@ -68,6 +83,7 @@ DEFINE_TEST(test_option_C_mtree)
assertEqualMem(p0 + 1536, "\0\0\0\0\0\0\0\0", 8);
done:
free(p0);
+ free(absolute_path);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_H_upper.c b/archivers/libarchive/files/tar/test/test_option_H_upper.c
index adc294b55b2..2c2ad33ce75 100644
--- a/archivers/libarchive/files/tar/test/test_option_H_upper.c
+++ b/archivers/libarchive/files/tar/test/test_option_H_upper.c
@@ -39,13 +39,13 @@ DEFINE_TEST(test_option_H_upper)
assertMakeDir("in", 0755);
assertChdir("in");
assertMakeDir("d1", 0755);
- assertMakeSymlink("ld1", "d1");
+ assertMakeSymlink("ld1", "d1", 1);
assertMakeFile("d1/file1", 0644, "d1/file1");
assertMakeFile("d1/file2", 0644, "d1/file2");
- assertMakeSymlink("d1/link1", "file1");
- assertMakeSymlink("d1/linkX", "fileX");
- assertMakeSymlink("link2", "d1/file2");
- assertMakeSymlink("linkY", "d1/fileY");
+ assertMakeSymlink("d1/link1", "file1", 0);
+ assertMakeSymlink("d1/linkX", "fileX", 0);
+ assertMakeSymlink("link2", "d1/file2", 0);
+ assertMakeSymlink("linkY", "d1/fileY", 0);
assertChdir("..");
/* Test 1: Without -H */
@@ -55,11 +55,11 @@ DEFINE_TEST(test_option_H_upper)
assertChdir("test1");
assertEqualInt(0,
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
- assertIsSymlink("ld1", "d1");
- assertIsSymlink("d1/link1", "file1");
- assertIsSymlink("d1/linkX", "fileX");
- assertIsSymlink("link2", "d1/file2");
- assertIsSymlink("linkY", "d1/fileY");
+ assertIsSymlink("ld1", "d1", 1);
+ assertIsSymlink("d1/link1", "file1", 0);
+ assertIsSymlink("d1/linkX", "fileX", 0);
+ assertIsSymlink("link2", "d1/file2", 0);
+ assertIsSymlink("linkY", "d1/fileY", 0);
assertChdir("..");
/* Test 2: With -H, no symlink on command line. */
@@ -69,11 +69,11 @@ DEFINE_TEST(test_option_H_upper)
assertChdir("test2");
assertEqualInt(0,
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
- assertIsSymlink("ld1", "d1");
- assertIsSymlink("d1/link1", "file1");
- assertIsSymlink("d1/linkX", "fileX");
- assertIsSymlink("link2", "d1/file2");
- assertIsSymlink("linkY", "d1/fileY");
+ assertIsSymlink("ld1", "d1", 1);
+ assertIsSymlink("d1/link1", "file1", 0);
+ assertIsSymlink("d1/linkX", "fileX", 0);
+ assertIsSymlink("link2", "d1/file2", 0);
+ assertIsSymlink("linkY", "d1/fileY", 0);
assertChdir("..");
/* Test 3: With -H, some symlinks on command line. */
@@ -84,9 +84,9 @@ DEFINE_TEST(test_option_H_upper)
assertEqualInt(0,
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
assertIsDir("ld1", umasked(0755));
- assertIsSymlink("d1/linkX", "fileX");
- assertIsSymlink("d1/link1", "file1");
+ assertIsSymlink("d1/linkX", "fileX", 0);
+ assertIsSymlink("d1/link1", "file1", 0);
assertIsReg("link2", umasked(0644));
- assertIsSymlink("linkY", "d1/fileY");
+ assertIsSymlink("linkY", "d1/fileY", 0);
assertChdir("..");
}
diff --git a/archivers/libarchive/files/tar/test/test_option_L_upper.c b/archivers/libarchive/files/tar/test/test_option_L_upper.c
index f5a3c5ab4cb..5697b0f293c 100644
--- a/archivers/libarchive/files/tar/test/test_option_L_upper.c
+++ b/archivers/libarchive/files/tar/test/test_option_L_upper.c
@@ -39,13 +39,13 @@ DEFINE_TEST(test_option_L_upper)
assertMakeDir("in", 0755);
assertChdir("in");
assertMakeDir("d1", 0755);
- assertMakeSymlink("ld1", "d1");
+ assertMakeSymlink("ld1", "d1", 1);
assertMakeFile("d1/file1", 0644, "d1/file1");
assertMakeFile("d1/file2", 0644, "d1/file2");
- assertMakeSymlink("d1/link1", "file1");
- assertMakeSymlink("d1/linkX", "fileX");
- assertMakeSymlink("link2", "d1/file2");
- assertMakeSymlink("linkY", "d1/fileY");
+ assertMakeSymlink("d1/link1", "file1", 0);
+ assertMakeSymlink("d1/linkX", "fileX", 0);
+ assertMakeSymlink("link2", "d1/file2", 0);
+ assertMakeSymlink("linkY", "d1/fileY", 0);
assertChdir("..");
/* Test 1: Without -L */
@@ -55,11 +55,11 @@ DEFINE_TEST(test_option_L_upper)
assertChdir("test1");
assertEqualInt(0,
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
- assertIsSymlink("ld1", "d1");
- assertIsSymlink("d1/link1", "file1");
- assertIsSymlink("d1/linkX", "fileX");
- assertIsSymlink("link2", "d1/file2");
- assertIsSymlink("linkY", "d1/fileY");
+ assertIsSymlink("ld1", "d1", 1);
+ assertIsSymlink("d1/link1", "file1", 0);
+ assertIsSymlink("d1/linkX", "fileX", 0);
+ assertIsSymlink("link2", "d1/file2", 0);
+ assertIsSymlink("linkY", "d1/fileY", 0);
assertChdir("..");
/* Test 2: With -L, no symlink on command line. */
@@ -71,9 +71,9 @@ DEFINE_TEST(test_option_L_upper)
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
assertIsDir("ld1", umasked(0755));
assertIsReg("d1/link1", umasked(0644));
- assertIsSymlink("d1/linkX", "fileX");
+ assertIsSymlink("d1/linkX", "fileX", 0);
assertIsReg("link2", umasked(0644));
- assertIsSymlink("linkY", "d1/fileY");
+ assertIsSymlink("linkY", "d1/fileY", 0);
assertChdir("..");
/* Test 3: With -L, some symlinks on command line. */
@@ -85,8 +85,8 @@ DEFINE_TEST(test_option_L_upper)
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
assertIsDir("ld1", umasked(0755));
assertIsReg("d1/link1", umasked(0644));
- assertIsSymlink("d1/linkX", "fileX");
+ assertIsSymlink("d1/linkX", "fileX", 0);
assertIsReg("link2", umasked(0644));
- assertIsSymlink("linkY", "d1/fileY");
+ assertIsSymlink("linkY", "d1/fileY", 0);
assertChdir("..");
}
diff --git a/archivers/libarchive/files/tar/test/test_option_U_upper.c b/archivers/libarchive/files/tar/test/test_option_U_upper.c
index 2c43e002df5..d864e13c4f6 100644
--- a/archivers/libarchive/files/tar/test/test_option_U_upper.c
+++ b/archivers/libarchive/files/tar/test/test_option_U_upper.c
@@ -79,10 +79,10 @@ DEFINE_TEST(test_option_U_upper)
assertMakeDir("test3", 0755);
assertChdir("test3");
assertMakeDir("realDir", 0755);
- assertMakeSymlink("d1", "realDir");
+ assertMakeSymlink("d1", "realDir", 1);
r = systemf("%s -xf ../archive.tar d1/file1 >test.out 2>test.err", testprog);
assert(r != 0);
- assertIsSymlink("d1", "realDir");
+ assertIsSymlink("d1", "realDir", 1);
assertFileNotExists("d1/file1");
assertEmptyFile("test.out");
assertNonEmptyFile("test.err");
@@ -92,7 +92,7 @@ DEFINE_TEST(test_option_U_upper)
assertMakeDir("test4", 0755);
assertChdir("test4");
assertMakeDir("realDir", 0755);
- assertMakeSymlink("d1", "realDir");
+ assertMakeSymlink("d1", "realDir", 1);
assertEqualInt(0,
systemf("%s -xUf ../archive.tar >test.out 2>test.err", testprog));
assertIsDir("d1", -1);
@@ -105,10 +105,10 @@ DEFINE_TEST(test_option_U_upper)
assertMakeDir("test5", 0755);
assertChdir("test5");
assertMakeDir("realDir", 0755);
- assertMakeSymlink("d1", "realDir");
+ assertMakeSymlink("d1", "realDir", 1);
assertEqualInt(0,
systemf("%s -xPf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
- assertIsSymlink("d1", "realDir");
+ assertIsSymlink("d1", "realDir", 1);
assertFileContents("d1/file1", 8, "d1/file1");
assertEmptyFile("test.out");
assertEmptyFile("test.err");
@@ -118,10 +118,10 @@ DEFINE_TEST(test_option_U_upper)
assertMakeDir("test6", 0755);
assertChdir("test6");
assertMakeDir("realDir", 0755);
- assertMakeSymlink("d1", "realDir");
+ assertMakeSymlink("d1", "realDir", 1);
assertEqualInt(0,
systemf("%s -xPUf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
- assertIsSymlink("d1", "realDir");
+ assertIsSymlink("d1", "realDir", 1);
assertFileContents("d1/file1", 8, "d1/file1");
assertEmptyFile("test.out");
assertEmptyFile("test.err");
@@ -132,7 +132,7 @@ DEFINE_TEST(test_option_U_upper)
assertChdir("test7");
assertMakeDir("d1", 0755);
assertMakeFile("d1/realfile1", 0644, "realfile1");
- assertMakeSymlink("d1/file1", "d1/realfile1");
+ assertMakeSymlink("d1/file1", "d1/realfile1", 0);
assertEqualInt(0,
systemf("%s -xf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
assertIsReg("d1/file1", umasked(0644));
@@ -147,7 +147,7 @@ DEFINE_TEST(test_option_U_upper)
assertChdir("test8");
assertMakeDir("d1", 0755);
assertMakeFile("d1/realfile1", 0644, "realfile1");
- assertMakeSymlink("d1/file1", "d1/realfile1");
+ assertMakeSymlink("d1/file1", "d1/realfile1", 0);
assertEqualInt(0,
systemf("%s -xPUf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
assertIsReg("d1/file1", umasked(0644));
diff --git a/archivers/libarchive/files/tar/test/test_option_exclude_vcs.c b/archivers/libarchive/files/tar/test/test_option_exclude_vcs.c
new file mode 100644
index 00000000000..20215113999
--- /dev/null
+++ b/archivers/libarchive/files/tar/test/test_option_exclude_vcs.c
@@ -0,0 +1,230 @@
+/*-
+ * Copyright (c) 2019 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_exclude_vcs)
+{
+ assertMakeDir("in", 0755);
+ assertChdir("in");
+ assertMakeFile("file", 0644, "");
+ assertMakeDir("dir", 0755);
+ assertMakeDir("CVS", 0755);
+ assertMakeFile("CVS/fileattr", 0644, "");
+ assertMakeFile(".cvsignore", 0644, "");
+ assertMakeDir("RCS", 0755);
+ assertMakeFile("RCS/somefile", 0655, "");
+ assertMakeDir("SCCS", 0755);
+ assertMakeFile("SCCS/somefile", 0655, "");
+ assertMakeDir(".svn", 0755);
+ assertMakeFile(".svn/format", 0655, "");
+ assertMakeDir(".git", 0755);
+ assertMakeFile(".git/config", 0655, "");
+ assertMakeFile(".gitignore", 0644, "");
+ assertMakeFile(".gitattributes", 0644, "");
+ assertMakeFile(".gitmodules", 0644, "");
+ assertMakeDir(".arch-ids", 0755);
+ assertMakeFile(".arch-ids/somefile", 0644, "");
+ assertMakeDir("{arch}", 0755);
+ assertMakeFile("{arch}/somefile", 0644, "");
+ assertMakeFile("=RELEASE-ID", 0644, "");
+ assertMakeFile("=meta-update", 0644, "");
+ assertMakeFile("=update", 0644, "");
+ assertMakeDir(".bzr", 0755);
+ assertMakeDir(".bzr/checkout", 0755);
+ assertMakeFile(".bzrignore", 0644, "");
+ assertMakeFile(".bzrtags", 0644, "");
+ assertMakeDir(".hg", 0755);
+ assertMakeFile(".hg/dirstate", 0644, "");
+ assertMakeFile(".hgignore", 0644, "");
+ assertMakeFile(".hgtags", 0644, "");
+ assertMakeDir("_darcs", 0755);
+ assertMakeFile("_darcs/format", 0644, "");
+ assertChdir("..");
+
+ assertEqualInt(0, systemf("%s -c -C in -f included.tar .", testprog));
+ assertEqualInt(0,
+ systemf("%s -c --exclude-vcs -C in -f excluded.tar .", testprog));
+
+ /* No flags, archive with vcs files */
+ assertMakeDir("vcs-noexclude", 0755);
+ assertEqualInt(0, systemf("%s -x -C vcs-noexclude -f included.tar",
+ testprog));
+ assertChdir("vcs-noexclude");
+ assertFileExists("file");
+ assertIsDir("dir", 0755);
+ assertIsDir("CVS", 0755);
+ assertFileExists("CVS/fileattr");
+ assertFileExists(".cvsignore");
+ assertIsDir("RCS", 0755);
+ assertFileExists("RCS/somefile");
+ assertIsDir("SCCS", 0755);
+ assertFileExists("SCCS/somefile");
+ assertIsDir(".svn", 0755);
+ assertFileExists(".svn/format");
+ assertIsDir(".git", 0755);
+ assertFileExists(".git/config");
+ assertFileExists(".gitignore");
+ assertFileExists(".gitattributes");
+ assertFileExists(".gitmodules");
+ assertIsDir(".arch-ids", 0755);
+ assertFileExists(".arch-ids/somefile");
+ assertIsDir("{arch}", 0755);
+ assertFileExists("{arch}/somefile");
+ assertFileExists("=RELEASE-ID");
+ assertFileExists("=meta-update");
+ assertFileExists("=update");
+ assertIsDir(".bzr", 0755);
+ assertIsDir(".bzr/checkout", 0755);
+ assertFileExists(".bzrignore");
+ assertFileExists(".bzrtags");
+ assertIsDir(".hg", 0755);
+ assertFileExists(".hg/dirstate");
+ assertFileExists(".hgignore");
+ assertFileExists(".hgtags");
+ assertIsDir("_darcs", 0755);
+ assertFileExists("_darcs/format");
+ assertChdir("..");
+
+ /* --exclude-vcs, archive with vcs files */
+ assertMakeDir("vcs-exclude", 0755);
+ assertEqualInt(0,
+ systemf("%s -x --exclude-vcs -C vcs-exclude -f included.tar", testprog));
+ assertChdir("vcs-exclude");
+ assertFileExists("file");
+ assertIsDir("dir", 0755);
+ assertFileNotExists("CVS");
+ assertFileNotExists("CVS/fileattr");
+ assertFileNotExists(".cvsignore");
+ assertFileNotExists("RCS");
+ assertFileNotExists("RCS/somefile");
+ assertFileNotExists("SCCS");
+ assertFileNotExists("SCCS/somefile");
+ assertFileNotExists(".svn");
+ assertFileNotExists(".svn/format");
+ assertFileNotExists(".git");
+ assertFileNotExists(".git/config");
+ assertFileNotExists(".gitignore");
+ assertFileNotExists(".gitattributes");
+ assertFileNotExists(".gitmodules");
+ assertFileNotExists(".arch-ids");
+ assertFileNotExists(".arch-ids/somefile");
+ assertFileNotExists("{arch}");
+ assertFileNotExists("{arch}/somefile");
+ assertFileNotExists("=RELEASE-ID");
+ assertFileNotExists("=meta-update");
+ assertFileNotExists("=update");
+ assertFileNotExists(".bzr");
+ assertFileNotExists(".bzr/checkout");
+ assertFileNotExists(".bzrignore");
+ assertFileNotExists(".bzrtags");
+ assertFileNotExists(".hg");
+ assertFileNotExists(".hg/dirstate");
+ assertFileNotExists(".hgignore");
+ assertFileNotExists(".hgtags");
+ assertFileNotExists("_darcs");
+ assertFileNotExists("_darcs/format");
+ assertChdir("..");
+
+ /* --exclude-vcs, archive without vcs files */
+ assertMakeDir("novcs-exclude", 0755);
+ assertEqualInt(0,
+ systemf("%s -x --exclude-vcs -C novcs-exclude -f excluded.tar",
+ testprog));
+ assertChdir("novcs-exclude");
+ assertFileExists("file");
+ assertIsDir("dir", 0755);
+ assertFileNotExists("CVS");
+ assertFileNotExists("CVS/fileattr");
+ assertFileNotExists(".cvsignore");
+ assertFileNotExists("RCS");
+ assertFileNotExists("RCS/somefile");
+ assertFileNotExists("SCCS");
+ assertFileNotExists("SCCS/somefile");
+ assertFileNotExists(".svn");
+ assertFileNotExists(".svn/format");
+ assertFileNotExists(".git");
+ assertFileNotExists(".git/config");
+ assertFileNotExists(".gitignore");
+ assertFileNotExists(".gitattributes");
+ assertFileNotExists(".gitmodules");
+ assertFileNotExists(".arch-ids");
+ assertFileNotExists(".arch-ids/somefile");
+ assertFileNotExists("{arch}");
+ assertFileNotExists("{arch}/somefile");
+ assertFileNotExists("=RELEASE-ID");
+ assertFileNotExists("=meta-update");
+ assertFileNotExists("=update");
+ assertFileNotExists(".bzr");
+ assertFileNotExists(".bzr/checkout");
+ assertFileNotExists(".bzrignore");
+ assertFileNotExists(".bzrtags");
+ assertFileNotExists(".hg");
+ assertFileNotExists(".hg/dirstate");
+ assertFileNotExists(".hgignore");
+ assertFileNotExists(".hgtags");
+ assertFileNotExists("_darcs");
+ assertFileNotExists("_darcs/format");
+ assertChdir("..");
+
+ /* No flags, archive without vcs files */
+ assertMakeDir("novcs-noexclude", 0755);
+ assertEqualInt(0,
+ systemf("%s -x -C novcs-noexclude -f excluded.tar", testprog));
+ assertChdir("novcs-noexclude");
+ assertFileExists("file");
+ assertIsDir("dir", 0755);
+ assertFileNotExists("CVS");
+ assertFileNotExists("CVS/fileattr");
+ assertFileNotExists(".cvsignore");
+ assertFileNotExists("RCS");
+ assertFileNotExists("RCS/somefile");
+ assertFileNotExists("SCCS");
+ assertFileNotExists("SCCS/somefile");
+ assertFileNotExists(".svn");
+ assertFileNotExists(".svn/format");
+ assertFileNotExists(".git");
+ assertFileNotExists(".git/config");
+ assertFileNotExists(".gitignore");
+ assertFileNotExists(".gitattributes");
+ assertFileNotExists(".gitmodules");
+ assertFileNotExists(".arch-ids");
+ assertFileNotExists(".arch-ids/somefile");
+ assertFileNotExists("{arch}");
+ assertFileNotExists("{arch}/somefile");
+ assertFileNotExists("=RELEASE-ID");
+ assertFileNotExists("=meta-update");
+ assertFileNotExists("=update");
+ assertFileNotExists(".bzr");
+ assertFileNotExists(".bzr/checkout");
+ assertFileNotExists(".bzrignore");
+ assertFileNotExists(".bzrtags");
+ assertFileNotExists(".hg");
+ assertFileNotExists(".hg/dirstate");
+ assertFileNotExists(".hgignore");
+ assertFileNotExists(".hgtags");
+ assertFileNotExists("_darcs");
+ assertFileNotExists("_darcs/format");
+}
diff --git a/archivers/libarchive/files/tar/test/test_option_n.c b/archivers/libarchive/files/tar/test/test_option_n.c
index 18ab6142d0f..e474ac1d575 100644
--- a/archivers/libarchive/files/tar/test/test_option_n.c
+++ b/archivers/libarchive/files/tar/test/test_option_n.c
@@ -25,8 +25,14 @@
#include "test.h"
__FBSDID("$FreeBSD$");
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
DEFINE_TEST(test_option_n)
{
+ int status;
+
assertMakeDir("d1", 0755);
assertMakeFile("d1/file1", 0644, "d1/file1");
@@ -58,4 +64,79 @@ DEFINE_TEST(test_option_n)
assertIsDir("d1", umasked(0755));
assertFileNotExists("d1/file1");
assertChdir("..");
+
+ /*
+ * Create a test archive with the following content:
+ * d1/
+ * d1/file1
+ * d1/file2
+ * file3
+ * d2/file4
+ *
+ * Extracting uses the same code as listing and thus does not
+ * get tested separately. This also covers the
+ * archive_match_set_inclusion_recursion()
+ * API.
+ */
+ assertMakeFile("d1/file2", 0644, "d1/file2");
+ assertMakeFile("file3", 0644, "file3");
+ assertMakeDir("d2", 0755);
+ assertMakeFile("d2/file4", 0644, "d2/file4");
+ assertEqualInt(0,
+ systemf("%s -cnf partial-archive.tar d1 d1/file1 d1/file2 file3 "
+ "d2/file4 >c.out 2>c.err", testprog));
+
+ /* Test 3: -t without other options */
+ assertEqualInt(0,
+ systemf("%s -tf partial-archive.tar >test3.out 2>test3.err",
+ testprog));
+ assertEmptyFile("test3.err");
+ assertTextFileContents("d1/\n"
+ "d1/file1\n"
+ "d1/file2\n"
+ "file3\n"
+ "d2/file4\n",
+ "test3.out");
+
+ /* Test 4: -t without -n and some entries selected */
+ assertEqualInt(0,
+ systemf("%s -tf partial-archive.tar d1 file3 d2/file4 "
+ ">test4.out 2>test4.err", testprog));
+ assertEmptyFile("test4.err");
+ assertTextFileContents("d1/\n"
+ "d1/file1\n"
+ "d1/file2\n"
+ "file3\n"
+ "d2/file4\n",
+ "test4.out");
+
+ /* Test 5: -t with -n and some entries selected */
+ assertEqualInt(0,
+ systemf("%s -tnf partial-archive.tar d1 file3 d2/file4 "
+ ">test5.out 2>test5.err", testprog));
+ assertEmptyFile("test5.err");
+ assertTextFileContents("d1/\n"
+ "file3\n"
+ "d2/file4\n",
+ "test5.out");
+
+ /* Test 6: -t without -n and non-existant directory selected */
+ assertEqualInt(0,
+ systemf("%s -tf partial-archive.tar d2 >test6.out 2>test6.err",
+ testprog));
+ assertEmptyFile("test6.err");
+ assertTextFileContents("d2/file4\n",
+ "test6.out");
+
+ /* Test 7: -t with -n and non-existant directory selected */
+ status = systemf("%s -tnf partial-archive.tar d2 "
+ ">test7.out 2>test7.err", testprog);
+ assert(status);
+ assert(status != -1);
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ assert(WIFEXITED(status));
+ assertEqualInt(1, WEXITSTATUS(status));
+#endif
+ assertNonEmptyFile("test7.err");
+ assertEmptyFile("test7.out");
}
diff --git a/archivers/libarchive/files/tar/test/test_option_s.c b/archivers/libarchive/files/tar/test/test_option_s.c
index ee8332f34fd..09c72ee7d63 100644
--- a/archivers/libarchive/files/tar/test/test_option_s.c
+++ b/archivers/libarchive/files/tar/test/test_option_s.c
@@ -36,7 +36,7 @@ DEFINE_TEST(test_option_s)
assertMakeFile("in/d1/bar", 0644, "bar");
if (canSymlink()) {
assertMakeFile("in/d1/realfile", 0644, "realfile");
- assertMakeSymlink("in/d1/symlink", "realfile");
+ assertMakeSymlink("in/d1/symlink", "realfile", 0);
}
assertMakeFile("in/d1/hardlink1", 0644, "hardlinkedfile");
assertMakeHardlink("in/d1/hardlink2", "in/d1/hardlink1");
@@ -109,14 +109,14 @@ DEFINE_TEST(test_option_s)
testprog, testprog);
assertFileContents("realfile", 8, "test6a/in/d2/realfile");
assertFileContents("realfile", 8, "test6a/in/d2/symlink");
- assertIsSymlink("test6a/in/d2/symlink", "realfile");
+ assertIsSymlink("test6a/in/d2/symlink", "realfile", 0);
/* At creation time. */
assertMakeDir("test6b", 0755);
systemf("%s -cf - -s /d1/d2/ in/d1 | %s -xf - -C test6b",
testprog, testprog);
assertFileContents("realfile", 8, "test6b/in/d2/realfile");
assertFileContents("realfile", 8, "test6b/in/d2/symlink");
- assertIsSymlink("test6b/in/d2/symlink", "realfile");
+ assertIsSymlink("test6b/in/d2/symlink", "realfile", 0);
}
/*
@@ -129,14 +129,14 @@ DEFINE_TEST(test_option_s)
testprog, testprog);
assertFileContents("realfile", 8, "test7a/in/d1/realfile-renamed");
assertFileContents("realfile", 8, "test7a/in/d1/symlink");
- assertIsSymlink("test7a/in/d1/symlink", "realfile-renamed");
+ assertIsSymlink("test7a/in/d1/symlink", "realfile-renamed", 0);
/* At creation. */
assertMakeDir("test7b", 0755);
systemf("%s -cf - -s /realfile/realfile-renamed/ in/d1 | %s -xf - -C test7b",
testprog, testprog);
assertFileContents("realfile", 8, "test7b/in/d1/realfile-renamed");
assertFileContents("realfile", 8, "test7b/in/d1/symlink");
- assertIsSymlink("test7b/in/d1/symlink", "realfile-renamed");
+ assertIsSymlink("test7b/in/d1/symlink", "realfile-renamed", 0);
}
/*
@@ -192,7 +192,7 @@ DEFINE_TEST(test_option_s)
assertFileContents("realfile", 8, "test10a/in/d1/foo");
assertFileContents("foo", 3, "test10a/in/d1/realfile");
assertFileContents("foo", 3, "test10a/in/d1/symlink");
- assertIsSymlink("test10a/in/d1/symlink", "realfile");
+ assertIsSymlink("test10a/in/d1/symlink", "realfile", 0);
/* At creation. */
assertMakeDir("test10b", 0755);
systemf("%s -cf - -s /realfile/foo/S -s /foo/realfile/ in/d1 | %s -xf - -C test10b",
@@ -200,7 +200,7 @@ DEFINE_TEST(test_option_s)
assertFileContents("realfile", 8, "test10b/in/d1/foo");
assertFileContents("foo", 3, "test10b/in/d1/realfile");
assertFileContents("foo", 3, "test10b/in/d1/symlink");
- assertIsSymlink("test10b/in/d1/symlink", "realfile");
+ assertIsSymlink("test10b/in/d1/symlink", "realfile", 0);
}
/*
@@ -214,7 +214,7 @@ DEFINE_TEST(test_option_s)
assertFileContents("foo", 3, "test11a/in/d1/foo");
assertFileContents("realfile", 8, "test11a/in/d1/realfile");
assertFileContents("foo", 3, "test11a/in/d1/symlink");
- assertIsSymlink("test11a/in/d1/symlink", "foo");
+ assertIsSymlink("test11a/in/d1/symlink", "foo", 0);
/* At creation. */
assertMakeDir("test11b", 0755);
systemf("%s -cf - -s /realfile/foo/R in/d1 | %s -xf - -C test11b",
@@ -222,7 +222,7 @@ DEFINE_TEST(test_option_s)
assertFileContents("foo", 3, "test11b/in/d1/foo");
assertFileContents("realfile", 8, "test11b/in/d1/realfile");
assertFileContents("foo", 3, "test11b/in/d1/symlink");
- assertIsSymlink("test11b/in/d1/symlink", "foo");
+ assertIsSymlink("test11b/in/d1/symlink", "foo", 0);
}
/*
diff --git a/archivers/libarchive/files/tar/test/test_strip_components.c b/archivers/libarchive/files/tar/test/test_strip_components.c
index d195af1b352..090fb0dbf91 100644
--- a/archivers/libarchive/files/tar/test/test_strip_components.c
+++ b/archivers/libarchive/files/tar/test/test_strip_components.c
@@ -36,8 +36,8 @@ DEFINE_TEST(test_strip_components)
assertMakeHardlink("l1", "d1/d2/f1");
assertMakeHardlink("d1/l2", "d1/d2/f1");
if (canSymlink()) {
- assertMakeSymlink("s1", "d1/d2/f1");
- assertMakeSymlink("d1/s2", "d2/f1");
+ assertMakeSymlink("s1", "d1/d2/f1", 0);
+ assertMakeSymlink("d1/s2", "d2/f1", 0);
}
assertChdir("..");
@@ -64,9 +64,10 @@ DEFINE_TEST(test_strip_components)
failure("d0/d1/s2 is a symlink to something that won't be extracted");
/* If platform supports symlinks, target/s2 is a broken symlink. */
/* If platform does not support symlink, target/s2 doesn't exist. */
- assertFileNotExists("target/s2");
if (canSymlink())
- assertIsSymlink("target/s2", "d2/f1");
+ assertIsSymlink("target/s2", "d2/f1", 0);
+ else
+ assertFileNotExists("target/s2");
failure("d0/d1/d2 should be extracted");
assertIsDir("target/d2", -1);
@@ -122,7 +123,7 @@ DEFINE_TEST(test_strip_components)
/* If platform supports symlinks, target/s2 is included. */
if (canSymlink()) {
failure("d0/d1/s2 is a symlink to something included in archive");
- assertIsSymlink("target2/s2", "d2/f1");
+ assertIsSymlink("target2/s2", "d2/f1", 0);
}
failure("d0/d1/d2 should be archived");
assertIsDir("target2/d2", -1);
diff --git a/archivers/libarchive/files/tar/test/test_symlink_dir.c b/archivers/libarchive/files/tar/test/test_symlink_dir.c
index 852e00b37c6..5836647c1a2 100644
--- a/archivers/libarchive/files/tar/test/test_symlink_dir.c
+++ b/archivers/libarchive/files/tar/test/test_symlink_dir.c
@@ -66,22 +66,22 @@ DEFINE_TEST(test_symlink_dir)
/* "dir" is a symlink to an existing "dest1/real_dir" */
assertMakeDir("dest1/real_dir", 0755);
if (canSymlink()) {
- assertMakeSymlink("dest1/dir", "real_dir");
+ assertMakeSymlink("dest1/dir", "real_dir", 1);
/* "dir2" is a symlink to a non-existing "real_dir2" */
- assertMakeSymlink("dest1/dir2", "real_dir2");
+ assertMakeSymlink("dest1/dir2", "real_dir2", 1);
} else {
skipping("Symlinks are not supported on this platform");
}
/* "dir3" is a symlink to an existing "non_dir3" */
assertMakeFile("dest1/non_dir3", 0755, "abcdef");
if (canSymlink())
- assertMakeSymlink("dest1/dir3", "non_dir3");
+ assertMakeSymlink("dest1/dir3", "non_dir3", 1);
/* "file" is a symlink to existing "real_file" */
assertMakeFile("dest1/real_file", 0755, "abcdefg");
if (canSymlink()) {
- assertMakeSymlink("dest1/file", "real_file");
+ assertMakeSymlink("dest1/file", "real_file", 0);
/* "file2" is a symlink to non-existing "real_file2" */
- assertMakeSymlink("dest1/file2", "real_file2");
+ assertMakeSymlink("dest1/file2", "real_file2", 0);
}
assertEqualInt(0, systemf("%s -xf test.tar -C dest1", testprog));
@@ -108,32 +108,32 @@ DEFINE_TEST(test_symlink_dir)
/* "dir" is a symlink to existing "real_dir" */
assertMakeDir("dest2/real_dir", 0755);
if (canSymlink())
- assertMakeSymlink("dest2/dir", "real_dir");
+ assertMakeSymlink("dest2/dir", "real_dir", 1);
/* "dir2" is a symlink to a non-existing "real_dir2" */
if (canSymlink())
- assertMakeSymlink("dest2/dir2", "real_dir2");
+ assertMakeSymlink("dest2/dir2", "real_dir2", 1);
/* "dir3" is a symlink to an existing "non_dir3" */
assertMakeFile("dest2/non_dir3", 0755, "abcdefgh");
if (canSymlink())
- assertMakeSymlink("dest2/dir3", "non_dir3");
+ assertMakeSymlink("dest2/dir3", "non_dir3", 1);
/* "file" is a symlink to existing "real_file" */
assertMakeFile("dest2/real_file", 0755, "abcdefghi");
if (canSymlink())
- assertMakeSymlink("dest2/file", "real_file");
+ assertMakeSymlink("dest2/file", "real_file", 0);
/* "file2" is a symlink to non-existing "real_file2" */
if (canSymlink())
- assertMakeSymlink("dest2/file2", "real_file2");
+ assertMakeSymlink("dest2/file2", "real_file2", 0);
assertEqualInt(0, systemf("%s -xPf test.tar -C dest2", testprog));
/* "dir4" is a symlink to existing "real_dir" */
if (canSymlink())
- assertMakeSymlink("dest2/dir4", "real_dir");
+ assertMakeSymlink("dest2/dir4", "real_dir", 1);
assertEqualInt(0, systemf("%s -xPf test2.tar -C dest2", testprog));
/* dest2/dir and dest2/dir4 symlinks should be followed */
if (canSymlink()) {
- assertIsSymlink("dest2/dir", "real_dir");
- assertIsSymlink("dest2/dir4", "real_dir");
+ assertIsSymlink("dest2/dir", "real_dir", 1);
+ assertIsSymlink("dest2/dir4", "real_dir", 1);
assertIsDir("dest2/real_dir", -1);
}
diff --git a/archivers/libarchive/files/tar/write.c b/archivers/libarchive/files/tar/write.c
index e15cc06ccfc..09c44a3e747 100644
--- a/archivers/libarchive/files/tar/write.c
+++ b/archivers/libarchive/files/tar/write.c
@@ -540,8 +540,7 @@ write_archive(struct archive *a, struct bsdtar *bsdtar)
lafe_warnc(archive_errno(disk),
"%s", archive_error_string(disk));
bsdtar->return_value = 1;
- archive_entry_free(entry);
- continue;
+ goto next_entry;
}
/*
@@ -557,15 +556,14 @@ write_archive(struct archive *a, struct bsdtar *bsdtar)
"%s", archive_error_string(disk));
if (r == ARCHIVE_FATAL)
bsdtar->return_value = 1;
- else
- archive_read_close(disk);
- archive_entry_free(entry);
- continue;
+ archive_read_close(disk);
+ goto next_entry;
}
write_file(bsdtar, a, entry);
- archive_entry_free(entry);
archive_read_close(disk);
+next_entry:
+ archive_entry_free(entry);
entry = NULL;
archive_entry_linkify(bsdtar->resolver, &entry, &sparse_entry);
}