Commit Graph

107 Commits

Author SHA1 Message Date
zhangguanzhang 74e01d6ccd Fixes: https://github.com/containers/podman/issues/7790
if they are the same and dest is a directory, should error like cp behavior

Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-10-06 11:39:51 +08:00
Giuseppe Scrivano 7b3e65ec4f
archive: preallocate a buffer for io.Copy
avoid creating a new buffer for each file in the archive but
preallocate a 1M buffer.  Another advantage of having a bigger buffer
is that we reduce the number of read and write syscalls.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-08-07 08:44:00 +02:00
yfy a8686fcb4b archive: fix the bug of ReadSecurityXattrToTarHeader
The xattr of hdr will lose when the security.ima
and security.capability both have value.

Signed-off-by: yangfeiyu <yangfeiyu20102011@163.com>
2020-07-21 09:24:26 +08:00
Daniel J Walsh 5ea5e76569
Record security.ima in container images
We have been asked to also record the security.ima attributes into
the container images.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-04 06:23:17 -04:00
Miloslav Trmač ceef38b6c6 Don't fail trying to read xattrs on platforms that don't support them
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2020-05-01 19:16:18 +02:00
Sascha Grunert b66d5a5c12
Enable goconst linter and fix lints
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-28 15:59:15 +01:00
Zac Medico 091491bbf7 pkg/archive: limit user xattr value size to math.MaxUint16 bytes
This should avoid the following panic in Lgetxattr:

    panic: runtime error: makeslice: len out of range

Fixes: 0da4bc60b3 ("pkg/archive: strictly handle errors reading xattrs")
See: https://travis-ci.org/containers/buildah/jobs/617652963
Signed-off-by: Zac Medico <zmedico@gmail.com>
2019-11-27 14:41:08 -08:00
Valentin Rothberg fae1939e83 remove pkg/system/filesys*
This API caused build regressions as golang.org/x dependencies
introduced breaking changes.  We don't have any callers in our
projects and I consider it a bug that those APIs were there,
which might prevent us from causing a major bump.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-11-27 13:31:52 +01:00
Zac Medico f39fb8370d Remove redundant if statements for nil slices
Suggested-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Zac Medico <zmedico@gmail.com>
2019-11-22 13:02:42 -08:00
Zac Medico 0da4bc60b3 pkg/archive: strictly handle errors reading xattrs
Suggested-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Zac Medico <zmedico@gmail.com>
2019-11-22 11:05:31 -08:00
Zac Medico 5fc095c06d VFS support for user.* xattrs
Preservation of user.* xattrs is supported by most (if not all) other
drivers, and it's especially useful for containers that run under a
PaX kernel where "user.pax.flags" is used to store PaX flags.

Signed-off-by: Zac Medico <zmedico@gmail.com>
2019-11-20 22:15:20 -08:00
Sascha Grunert 7f9806911a
Add excluded information to matches
We now add the information how many exclusions a match has, which is
needed for more fine-granular filepath matching.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-10-17 16:13:04 +02:00
Sascha Grunert 42086a5010
Add pure file matches indicator
The `pure` indicator for a match now returns `true` if it's the only
one. This additional information will be used by consumers to decide
more fine-granular if a match can be excluded completely or not.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-10-16 13:58:47 +02:00
Daniel J Walsh 976fe22092
Add storage options to IgnoreChownErrors
Modified patch of Kevin Pelzel.

Also changed ApplyDiff to take new ApplyDiffOpts Struct.

Signed-off-by: Kevin Pelzel <kevinpelzel22@gmail.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-07-26 06:05:27 -04:00
Giuseppe Scrivano 49190329b6
compression: add support for the zstd algorithm
zstd is a compression algorithm that has a very fast decoder, while
providing also good compression ratios.  The fast decoder makes it
suitable for container images, as decompressing the tarballs is a very
expensive operation.  This is a first step at supporting zstd as we We
don't yet generate zstd layers.

In my testing, copying the Fedora image from a local dir: repository,
the wall clock time passed from ~8s with gzip compression to ~4.5s
with zstd.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-06-19 23:04:19 +02:00
Giuseppe Scrivano 86147bc774
storage: make [l]chown errors clearer
if os.[Lc,C]hown are failing with EINVAL, it might be related to an
UID/GID not mapped in the user namespace we are currently using.

It could be possible to detect this issue by inspecting
/proc/self/uid_map or /proc/self/gid_map, but that won't be possible
when we are pulling a new image and extracting it from a chroot where
/proc is not mounted.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-11 08:56:38 +01:00
Daniel J Walsh 2ffffaf40f
Move copytar functions from buildah to storage
We want to use these functions in both podman and buildah
So move them out of buidlah into storage.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-01-31 15:26:03 +00:00
Giuseppe Scrivano fe775d42b0
vendor: use github.com/klauspost/pgzip instead of compress/gzip
from my tests, I've seen a net improvement of around 30% on the wall
clock time in decompressing layers.

These additional packages will need to be re-vendored:

github.com/klauspost/pgzip v1.2.1
github.com/klauspost/compress v1.4.1
github.com/klauspost/cpuid v1.2.0

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-12-13 16:14:54 +01:00
Giuseppe Scrivano 664eddc8b4
archive: ignore setxattr EPERM in a user namespace
old kernels, such as 4.9 used by Debian 9 do not support extended
attributes in a user namespace.  In this case, ignore the error and
print a warning.  This should be fine, as we are already doing it for
file systems that do not support xattrs.

Closes: https://github.com/containers/libpod/issues/1941

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-12-12 10:19:49 +01:00
Nalin Dahyabhai 15e07f8272 pkg/archive: truncate ModTime when we'd otherwise round it
When writing a header with no format explicitly specified, the first
thing archive/tar 1.10 does is round the header's ModTime field,
possibly up, which confuses our change-detection logic when we later go
to check if the result of untarring the archive matches the source
content.  Truncate the timestamp before that can happen.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-12-06 13:50:38 -05:00
Giuseppe Scrivano 9066262bf6
archive: set InUserNS
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-12-01 20:16:41 +01:00
Nalin Dahyabhai 38ce897d7c pkg/archive: use subsecond timestamps in Copy...WithTar
When we know we're going to extract the contents of a tar archive as
part of a copying process, set the desired format in the tar header to
PAX so that we get subsecond precision in timestamps, so that the
timestamps on the copies that we create aren't rounded off.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-05-29 17:28:00 -04:00
Nalin Dahyabhai 9d1f351db5 CopyFileWithTar: do mapping in two steps
Have CopyFileWithTar do mapping in two steps, because it's easier to
debug that way.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-04-30 18:04:02 -04:00
Nalin Dahyabhai 77b0b0dff0 Use mapped IDs when passing chown IDpairs to createTarFile
When we call createTarFile with a non-nil IDPair indicating that the
newly-created file should have its ownership changed, pass in IDs that
we've mapped back to host-level IDs.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-04-30 11:30:28 -04:00
Nalin Dahyabhai 97326e1d2f Support for per-container uid/gid mapping: lower
Expose reading and writing ID mapping in the archive and chrootarchive
packages, and in the driver interface.  Generally this means that
when computing or applying diffs, we need to have ID mappings passed in
that are specific to the layers we're using.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-04-03 10:34:32 -04:00
Nalin Dahyabhai 3063635862 archive.Tar: don't trust the "trusted.overlay.opaque" xattr
If the overlay filesystem implements an optimization that landed in
97c684cc911060ba7f97c0925eaf842f159a39e8, and in the mainline kernel in
4.10, directories created in merged directories are marked as opaque by
the kernel to let the kernel know that it needn't bother looking at
other layers when reading the contents of that directory.

This means that, when generating a diff for an upper directory, we can't
treat the presence of an opaque attribute as enough of an indication
that a layer diff needs to include whiteout for a directory of the same
name from a lower layer.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-02-23 16:00:48 -05:00
Daniel J Walsh d3761825a9 Add interfaces that were removed from upstream but containers/image uses
Add back in these interfaces since containers/image is using.
archive.UntartPath
archive.IsArchive

Also add back this constant for containers/image.
archive.HeaderSize

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-13 14:30:53 +00:00
Daniel J Walsh f39066fe1b Update packages to match latest code in moby/pkg
Had to vendor in a new version of golang.org/x/net to build
Also had to make some changes to drivers to handle
archive.Reader -> io.Reader
archive.Archive -> io.ReadCloser

Also update .gitingore to ignore emacs files, containers-storage.*
and generated man pages.

Also no longer test travis against golang 1.7, cri-o, moby have also
done this.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-12 18:00:29 +00:00
Mrunal Patel 59da502256 Update deps to github.com/sirupsen/logrus v1.0.0
Also updates github.com/Microsoft/hcsshim
and github.com/docker/go-connections so they work
with the newer version of logrus.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2017-08-01 07:25:56 -07:00
Daniel J Walsh 850e2bcf3b Remove "docker" strings from container storage
We want to make sure that content created out of container storage
does not refer to docker.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-01-26 09:47:23 +01:00
Nalin Dahyabhai 60ff079996 Rename: cow/cowman -> storage/oci-storage
Rename the library module and CLI wrapper.
Rename daemon/graphdriver to drivers.
Catch up vendoring to match modules we've pruned.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2016-07-18 17:35:50 -04:00
Vincent Demeester 37fe4bdb59 Merge pull request #23912 from dmcgowan/fix-overlay2-whiteout-exclusion
Fix overlay2 ignoring whiteout files
2016-06-24 01:06:38 +02:00
Derek McGowan bd13c53f8d Fix overlay2 ignoring whiteout files
Currently when overlay creates a whiteout file then the overlay2 layer is archived,
the correct tar header will be created for the whiteout file, but the tar logic will then attempt to open the file causing a failure.
When tar encounters such failures the file is skipped and excluded for the archive, causing the whiteout to be ignored.
By skipping the copy of empty files, no open attempt will be made on whiteout files.

Fixes #23863

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2016-06-23 13:34:38 -07:00
bin liu 950073aabb fix some typos
Signed-off-by: bin liu <liubin0329@gmail.com>
2016-06-21 15:29:25 +08:00
Michael Crosby 8a2f9a249c Merge pull request #22126 from dmcgowan/overlay-native-diff
Overlay multiple lower directory support
2016-06-13 13:15:39 -07:00
Yong Tang a72b45dbec Fix logrus formatting
This fix tries to fix logrus formatting by removing `f` from
`logrus.[Error|Warn|Debug|Fatal|Panic|Info]f` when formatting string
is not present.

This fix fixes #23459.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-06-11 13:16:55 -07:00
Aleksa Sarai e6d856df43 pkg: archive: only ignore ENOTSUP when xattr fails
There might be other (valid) reasons for setxattr(2) to fail, so only
ignore it when it's a not supported error (ENOTSUP). Otherwise, bail.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-06-10 00:56:40 +10:00
Derek McGowan 8222c86360 Update archive package to support overlay whiteouts
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2016-06-08 00:10:16 -07:00
Viktor Stanchev b03d3232d1 aufs compatibility
Signed-off-by: Viktor Stanchev <me@viktorstanchev.com>
2016-06-08 00:10:16 -07:00
allencloud 3f77baf2ce fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-05-06 18:23:11 +08:00
Alexander Morozov 9b2c3aa894 pkg/archive: use more narrow interface for CompressStream
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-04-07 13:21:05 -07:00
Tõnis Tiigi 553edd1d19 Merge pull request #21251 from cyphar/refactor-copyonbuild
pkg: archive: don't fail Untar if xattrs are not supported
2016-03-28 16:15:18 -07:00
Dmitri Logvinenko 6dede879fd Fix misspellings
Signed-off-by: Dmitri Logvinenko <dmitri.logvinenko@gmail.com>
2016-03-28 16:21:02 +03:00
Aleksa Sarai 75a271603c pkg: archive: don't fail Untar if xattrs are not supported
Since certain filesystems don't support extended attributes, ignore
errors produced (emitting a warning) when attempting to apply extended
attributes to file.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-03-24 02:05:36 +11:00
Phil Estes 06d95003b3 Fix CopyWithTar creation of new destination dir as remapped root
If the destination does not exist, it needs to be created with ownership
mapping to the remapped uid/gid ranges if user namespaces are enabled.
This fixes ADD operations, similar to the prior fixes for COPY and WORKDIR.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-03-12 23:05:45 -05:00
Doug Davis 842b8d8784 Optimize .dockerignore when there are exclusions
Closes #20470

Before this PR we used to scan the entire build context when there were
exclusions in the .dockerignore file (paths that started with !). Now we
only traverse into subdirs when one of the exclusions starts with that dir
path.

Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-03-03 05:46:24 -08:00
Sebastiaan van Stijn 67b16c7381 Merge pull request #20782 from estesp/new-parent-dir-ownership
Fix ownership of non-existing parent dir
2016-03-01 01:45:38 +01:00
Phil Estes 7a61b9ae42 Fix ownership of non-existing parent dir
During "COPY" or other tar unpack operations, a target/destination
parent dir might not exist and should be created with ownership of the
root in the right context (including remapped root when user namespaces
are enabled)

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-02-29 09:14:23 -05:00
Zhang Wei 439433099e Clean redundant error message for export
When execute `docker export -o path xxx` and path is a directory docker
has no privilege to write to, daemon will print lots of error logs that
most of them are duplicated and redundant.

This will remove unnecessary error logs and print only once.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-02-19 18:50:11 +08:00
Justas Brazauskas 927b334ebf Fix typos found across repository
Signed-off-by: Justas Brazauskas <brazauskasjustas@gmail.com>
2015-12-13 18:04:12 +02:00