]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
tar option mac-ext can now be used to control whether mac extensions are processed...
authorTim Kientzle <kientzle@gmail.com>
Fri, 13 Dec 2013 04:24:43 +0000 (20:24 -0800)
committerTim Kientzle <kientzle@gmail.com>
Fri, 13 Dec 2013 04:24:43 +0000 (20:24 -0800)
libarchive/archive_read_set_options.3
libarchive/archive_read_support_format_tar.c

index 6fe9f90f8f38a78036b88b62bcad116cbce094bc..d400272dea7b002a5549b8bec8b8e1f0a60555ee 100644 (file)
@@ -193,6 +193,24 @@ Defaults to enabled, use
 .Cm !rockridge
 to disable.
 .El
+.It Format tar
+.Bl -tag -compact -width indent
+.It Cm compat-2x
+Libarchive 2.x incorrectly encoded Unicode filenames on
+some platforms.
+This option mimics the libarchive 2.x filename handling
+so that such archives can be read correctly.
+.It Cm hdrcharset
+The value is used as a character set name that will be
+used when translating filenames.
+.It Cm mac-ext
+Support Mac OS metadata extension that records data in special
+files beginning with a period and underscore.
+Defaults to enabled on Mac OS, disabled on other platforms.
+Use
+.Cm !mac-ext
+to disable.
+.El
 .El
 .\"
 .Sh ERRORS
index 95960a2c1833c532eb238b44a5a4d8fca997d64c..9ecedd6c81a9f4df7398a2c33bc32554e3541fb6 100644 (file)
@@ -151,6 +151,7 @@ struct tar {
        struct archive_string_conv *sconv_default;
        int                      init_default_conversion;
        int                      compat_2x;
+       int                      process_mac_extensions;
 };
 
 static int     archive_block_is_null(const char *p);
@@ -241,6 +242,10 @@ archive_read_support_format_tar(struct archive *_a)
            ARCHIVE_STATE_NEW, "archive_read_support_format_tar");
 
        tar = (struct tar *)calloc(1, sizeof(*tar));
+#ifdef HAVE_COPYFILE_H
+       /* Set this by default on Mac OS. */
+       tar->process_mac_extensions = 1;
+#endif
        if (tar == NULL) {
                archive_set_error(&a->archive, ENOMEM,
                    "Can't allocate tar data");
@@ -368,7 +373,7 @@ archive_read_format_tar_options(struct archive_read *a,
        tar = (struct tar *)(a->format->data);
        if (strcmp(key, "compat-2x")  == 0) {
                /* Handle UTF-8 filnames as libarchive 2.x */
-               tar->compat_2x = (val != NULL)?1:0;
+               tar->compat_2x = (val != NULL && val[0] != 0);
                tar->init_default_conversion = tar->compat_2x;
                return (ARCHIVE_OK);
        } else if (strcmp(key, "hdrcharset")  == 0) {
@@ -385,6 +390,9 @@ archive_read_format_tar_options(struct archive_read *a,
                                ret = ARCHIVE_FATAL;
                }
                return (ret);
+       } else if (strcmp(key, "mac-ext") == 0) {
+               tar->process_mac_extensions = (val != NULL && val[0] != 0);
+               return (ARCHIVE_OK);
        }
 
        /* Note: The "warn" return is just to inform the options
@@ -737,9 +745,9 @@ tar_read_header(struct archive_read *a, struct tar *tar,
         * extensions for both the AppleDouble extension entry and the
         * regular entry.
         */
-       /* TODO: Should this be disabled on non-Mac platforms? */
        if ((err == ARCHIVE_WARN || err == ARCHIVE_OK) &&
-           tar->header_recursion_depth == 0) {
+           tar->header_recursion_depth == 0 &&
+           tar->process_mac_extensions) {
                int err2 = read_mac_metadata_blob(a, tar, entry, h, unconsumed);
                if (err2 < err)
                        err = err2;