moby--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
README.md
archive.go
archive_linux.go
archive_linux_test.go
archive_other.go
archive_test.go
archive_unix.go
archive_unix_test.go
archive_windows.go
archive_windows_test.go
changes.go
changes_linux.go
changes_other.go
changes_posix_test.go
changes_test.go
changes_unix.go
changes_windows.go
copy.go pkg/archive:CopyTo(): fix for long dest filename 2019-01-24 18:10:52 -08:00
copy_unix.go
copy_unix_test.go pkg/archive:CopyTo(): fix for long dest filename 2019-01-24 18:10:52 -08:00
copy_windows.go
diff.go
diff_test.go
example_changes.go
time_linux.go
time_unsupported.go
utils_test.go
whiteouts.go
wrap.go
wrap_test.go

README.md

This code provides helper functions for dealing with archive files.