moby/pkg/archive
Kir Kolyshkin f55a4176fe pkg/archive:CopyTo(): fix for long dest filename
As reported in docker/for-linux/issues/484, since Docker 18.06
docker cp with a destination file name fails with the following error:

> archive/tar: cannot encode header: Format specifies USTAR; and USTAR cannot encode Name="a_very_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_long_filename_that_is_101_characters"

The problem is caused by changes in Go 1.10 archive/tar, which
mis-guesses the tar stream format as USTAR (rather than PAX),
which, in turn, leads to inability to specify file names
longer than 100 characters.

This tar stream is sent by TarWithOptions() (which, since we switched to
Go 1.10, explicitly sets format=PAX for every file, see FileInfoHeader(),
and before Go 1.10 it was PAX by default). Unfortunately, the receiving
side, RebaseArchiveEntries(), which calls tar.Next(), mistakenly guesses
header format as USTAR, which leads to the above error.

The fix is easy: set the format to PAX in RebaseArchiveEntries()
where we read the tar stream and change the file name.

A unit test is added to prevent future regressions.

NOTE this code is not used by dockerd, but rather but docker cli
(also possibly other clients), so this needs to be re-vendored
to cli in order to take effect.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-01-24 18:10:52 -08:00
..
testdata Move archive package into pkg/archive 2014-09-29 23:23:36 -07:00
archive.go pkg/archive: support overlayfs in userns (Ubuntu kernel only) 2018-12-11 07:18:37 +09:00
archive_linux.go pkg/archive: support overlayfs in userns (Ubuntu kernel only) 2018-12-11 07:18:37 +09:00
archive_linux_test.go pkg/archive: add TestReexecUserNSOverlayWhiteoutConverter 2018-12-11 07:18:37 +09:00
archive_other.go pkg/archive: support overlayfs in userns (Ubuntu kernel only) 2018-12-11 07:18:37 +09:00
archive_test.go pkg/archive: annotate tests that requires initial userns 2018-12-11 07:18:37 +09:00
archive_unix.go Add ADD/COPY --chown flag support to Windows 2018-08-13 21:59:11 -07:00
archive_unix_test.go pkg/archive: annotate tests that requires initial userns 2018-12-11 07:18:37 +09:00
archive_windows.go Add ADD/COPY --chown flag support to Windows 2018-08-13 21:59:11 -07:00
archive_windows_test.go LCOW: lazycontext: Use correct lstat, fix archive check 2018-06-27 13:29:21 -07:00
changes.go pkg/archive fixes, and port most unit tests to Windows 2018-11-26 10:20:40 -08:00
changes_linux.go Update overlay2 to use naive diff for changes 2018-06-20 11:07:36 -07:00
changes_other.go Add canonical import comment 2018-02-05 16:51:57 -05:00
changes_posix_test.go Various code-cleanup 2018-05-23 17:50:54 +02:00
changes_test.go pkg/archive fixes, and port most unit tests to Windows 2018-11-26 10:20:40 -08:00
changes_unix.go pkg/archive fixes, and port most unit tests to Windows 2018-11-26 10:20:40 -08:00
changes_windows.go pkg/archive fixes, and port most unit tests to Windows 2018-11-26 10:20:40 -08:00
copy.go pkg/archive:CopyTo(): fix for long dest filename 2019-01-24 18:10:52 -08:00
copy_unix.go Add canonical import comment 2018-02-05 16:51:57 -05:00
copy_unix_test.go pkg/archive:CopyTo(): fix for long dest filename 2019-01-24 18:10:52 -08:00
copy_windows.go Add canonical import comment 2018-02-05 16:51:57 -05:00
diff.go pkg/archive fixes, and port most unit tests to Windows 2018-11-26 10:20:40 -08:00
diff_test.go pkg/archive fixes, and port most unit tests to Windows 2018-11-26 10:20:40 -08:00
example_changes.go Update logrus to v1.0.1 2017-07-31 13:16:46 -07:00
README.md Move archive package into pkg/archive 2014-09-29 23:23:36 -07:00
time_linux.go Various code-cleanup 2018-05-23 17:50:54 +02:00
time_unsupported.go Add canonical import comment 2018-02-05 16:51:57 -05:00
utils_test.go Add canonical import comment 2018-02-05 16:51:57 -05:00
whiteouts.go Add canonical import comment 2018-02-05 16:51:57 -05:00
wrap.go Add canonical import comment 2018-02-05 16:51:57 -05:00
wrap_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00

This code provides helper functions for dealing with archive files.