Commit Graph

122 Commits

Author SHA1 Message Date
haoyun
c0d07094be feat: Errorf usage
Signed-off-by: haoyun <yun.hao@daocloud.io>
2021-12-13 14:31:53 +08:00
Shiming Zhang
db124c560c Close file if permission modification fails
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2021-11-15 16:57:05 +08:00
Derek McGowan
cc5a4c8297
Merge pull request #6177 from dkkb/feature/zstd_with_skippable_frame
compression: support zstd with skippable frame
2021-11-01 10:29:05 -07:00
Da McGrady
6fa9f22fa3
compression: support zstd with skippable frame
As a matter of fact, there are two frame formats defined by Zstandard: Zstandard frames and Skippable frames.
So we should probably support zstd algorithms with skippable frames.
See https://tools.ietf.org/id/draft-kucherawy-dispatch-zstd-00.html#rfc.section.2 for more details.

Signed-off-by: Da McGrady <dabkb@aol.com>
2021-11-01 11:36:46 +08:00
Derek McGowan
63b7e5771e
Merge pull request #5973 from Juneezee/deprecate-ioutil
refactor: move from io/ioutil to io and os package
2021-10-01 10:52:06 -07:00
Artem Khramov
2bffb5f9b2
FreeBSD: fix tar headers & the nil check on getxattr
On FreeBSD + zfs, stat call seem to return garbage in RDev for regular
files & folders. The value returned is large enough not to fit into
`Devmajor` & `Devminor` fields of the tar header. Fortunately, these
fields are required just for special devices.

This change

* adds a check into `setHeaderForSpecialDevice` that the
  input header represents a special device. If it's not the case, we
  don't set the Devmajor & Devminor fields.

* fixes the nil check on `getxattr`: it never returns nils, but rather
  an empty slice instead

Signed-off-by: Artem Khramov <akhramov@pm.me>
2021-09-21 19:22:41 +03:00
Eng Zer Jun
50da673592
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-09-21 09:50:38 +08:00
Fu Wei
d9f921e4f0
Merge pull request #5906 from thaJeztah/replace_os_exec 2021-09-11 10:38:53 +08:00
Shiming Zhang
ccc5ee3038 archive: Add WriteDiff error logs
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2021-09-06 18:04:17 +08:00
Sebastiaan van Stijn
2ac9968401
replace uses of os/exec with golang.org/x/sys/execabs
Go 1.15.7 contained a security fix for CVE-2021-3115, which allowed arbitrary
code to be executed at build time when using cgo on Windows. This issue also
affects Unix users who have “.” listed explicitly in their PATH and are running
“go get” outside of a module or with module mode disabled.

This issue is not limited to the go command itself, and can also affect binaries
that use `os.Command`, `os.LookPath`, etc.

From the related blogpost (ttps://blog.golang.org/path-security):

> Are your own programs affected?
>
> If you use exec.LookPath or exec.Command in your own programs, you only need to
> be concerned if you (or your users) run your program in a directory with untrusted
> contents. If so, then a subprocess could be started using an executable from dot
> instead of from a system directory. (Again, using an executable from dot happens
> always on Windows and only with uncommon PATH settings on Unix.)
>
> If you are concerned, then we’ve published the more restricted variant of os/exec
> as golang.org/x/sys/execabs. You can use it in your program by simply replacing

This patch replaces all uses of `os/exec` with `golang.org/x/sys/execabs`. While
some uses of `os/exec` should not be problematic (e.g. part of tests), it is
probably good to be consistent, in case code gets moved around.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-25 18:11:09 +02:00
Akihiro Suda
d3aa7ee9f0
Run go fmt with Go 1.17
The new `go fmt` adds `//go:build` lines (https://golang.org/doc/go1.17#tools).

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-08-22 09:31:50 +09:00
Kazuyoshi Kato
bc4cea4e44 docs: rename main to master
containerd and opencontainers/image-spec have renamed its main branch
from "master" to "main"

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-08-10 09:42:16 -07:00
Derek McGowan
6f027e38a8
Remove redundant build tags
Remove build tags which are already implied by the name of the file.
Ensures build tags are used consistently

Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-08-05 22:27:46 -07:00
Derek McGowan
bc4e416c88
Add test for archive breakout test for lchmod
Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-07-12 11:10:45 -07:00
Derek McGowan
53835221f6
Cleanup lchmod logic in archive
Move to single lchmod interface mirroring other implementations.
Separate logic for freebsd which supports symlink no follow flag.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-07-08 13:44:28 -07:00
ktock
4a46ea2f4b archive: Expose ChangeWriter to allow customized diff computing
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-06-21 18:48:00 +09:00
Paul "TBBle" Hampson
c7504987e6 Implement windowsDiff.Compare via hcsshim/pkg/ociwclayer
This parallels the implementation of windowsDiff.Apply, including
bouncing very briefly though archive.WriteDiff and then straight back
out into Windows-specific code.

It's mostly pulling existing mechanisms from non-Windows Compare or
Windows Apply, and highlights that there's probably a lot of scope for
refactoring on top of this.

Now the export-related integration tests pass CI on Windows.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-04-10 02:02:33 +10:00
Paul "TBBle" Hampson
a64a76846c Replace inline applyWindowsLayer using hcsshim
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-04-10 02:02:33 +10:00
Maksym Pavlenko
4674ad7beb Ignore some tests on darwin
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-03-24 22:40:22 -07:00
Sebastiaan van Stijn
708299ca40
Move RunningInUserNS() to its own package
This allows using the utility without bringing whole of "sys" with it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-03-23 11:29:53 +01:00
Sebastiaan van Stijn
4e76bcf061
gofmt -s -w all the things
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-03-16 21:29:41 +01:00
Sebastiaan van Stijn
ba8f9845ec
move overlay-checks to an overlayutils package
This allows using the utilities without importing the whole
snapshotter.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-03-15 19:18:50 +01:00
Samuel Karp
b459209188
Compile for FreeBSD
Signed-off-by: Samuel Karp <me@samuelkarp.com>
2020-12-09 00:30:29 -08:00
Giuseppe Scrivano
30802fac73
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.

https://github.com/opencontainers/image-spec/pull/788 added support
for zstd to the OCI image specs.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-12-07 09:56:30 +01:00
Paul "TBBle" Hampson
78f31afb45 Reorder to separate generic from windows-specific code
Specifically, all the functions above applyWindowsLayer are actually
used by the (generic) applyNaive code, while the functions below this
point are specific to applyWindowsLayer.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2020-12-03 02:43:37 +11:00
Paul "TBBle" Hampson
3e47cdf70f Use go-winio tar-application code instead of our own
applyFunc now takes an io.Reader instead of a tar.Reader because I'm
trying to mirror the API of the not-yet-exposed implementation of this
same behaviour in github.com/Microsoft/hcsshim/internal/ociwclayer,
with an eye to later moving to that implementation it is ever exposed.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2020-12-03 02:42:54 +11:00
Sebastiaan van Stijn
dc92ad6520
Replace errors.Cause() with errors.Is()
Dependencies may be switching to use the new `%w` formatting
option to wrap errors; switching to use `errors.Is()` makes
sure that we are still able to unwrap the error and detect the
underlying cause.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-05-08 14:36:45 +02:00
Sebastiaan van Stijn
0088c2de80
sys: RunningInUserNS(): use sync.Once
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-05-04 18:57:02 +02:00
Sebastiaan van Stijn
6a9b94927f
Remove remaining uses of libcontainer/system package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-05-04 18:56:57 +02:00
Mikko Ylinen
e2269f2ae0 archive: skip chmod IsNotExist error
handleLChmod() does not properly check that files behind the handlinks exist
before calling os.Chmod(). We've seen base images where this results in
"no such file or directory" error from os.Chmod() when unpacking the image.

To keep the existing logic but fix the problem, this commit simply skips
IsNotExist error.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2020-03-23 20:58:28 +02:00
Shengjing Zhu
465c11dc87 Fix build with gccgo
+ archive: don't convert syscall.Timespec to unix.Timespec
  archive/tar_unix.go:179:76: error: invalid type conversion (cannot use type syscall.Timespec as type unix.Timespec)
    179 |  timespec := []unix.Timespec{unix.Timespec(fs.StatAtime(st)), unix.Timespec(fs.StatMtime(st))}
+ gccgo has no plugin support
  https://github.com/golang/go/issues/36403
+ update github.com/containerd/continuity
  to include same fix for Timespec

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2020-01-07 19:28:26 +08:00
Tonis Tiigi
372472b5f6 archive: truncate modification time
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2019-08-27 17:42:32 -07:00
Derek McGowan
bcc4a146e4
Support applying with parent directories
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-08-16 15:49:47 -07:00
Lantao Liu
81386df917
Add direct unpack support for overlay and aufs
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-08-15 12:09:32 -07:00
dzzg
612628c2f9 fix wrong spells in compression.go
Signed-off-by: zhengguang zhu <zhengguang.zhu@daocloud.io>
2019-07-29 12:47:17 +00:00
Wei Fu
9da7d30362 archive: return chtimes error with path information
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-07-25 16:33:19 +08:00
Lantao Liu
14f7e52725 Unpack should set 0755 when the parent directory doesn't exist.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-02-14 13:38:12 -08:00
Justin Cormack
7db5697719
unix.UtimesNanoAt now supported on Darwin
unix.UtimesNanoAt now supported on Darwin and sets nanosecond precision if the filesystems does.
This call is now generally supported. Note that os.Chtimes also sets nanosecond precision,
but will always follow symlinks so not appropriate.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2019-01-23 17:57:09 +00:00
Wei Fu
132ee9b826 fix: linter issue
megacheck, gosimple and unused has been deprecated and subsumed by
staticcheck. And staticcheck also has been upgraded. we need to update
code for the linter issue.

close: #2945

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-01-23 22:54:51 +08:00
Derek McGowan
e6879c498b
Merge pull request #2882 from JoeWrightss/patch-1
Fix annotation typo error
2018-12-14 11:25:04 -08:00
JoeWrightss
903abf33cf Fix annotation typo error
Signed-off-by: JoeWrightss <zhoulin.xie@daocloud.io>
2018-12-14 23:18:42 +08:00
Ace-Tang
6f944e4190 fix: SCHILY.xattrs should be SCHILY.xattr
from golang code
bad6b6fa91/src/archive/tar/common.go (L110)

add unit test for tar xattr

Fixes: #2863

Signed-off-by: Ace-Tang <aceapril@126.com>
2018-12-13 09:56:26 +08:00
zhangyue
996c60616a fix: fix error info start capitalized
Signed-off-by: zhangyue <zy675793960@yeah.net>
2018-11-28 15:26:16 +08:00
Ivan Markin
a20603090f archive: add support for OpenBSD
Signed-off-by: Ivan Markin <sw@nogoegst.net>
2018-10-12 22:29:24 +00:00
Phil Estes
90b7b88e10
Merge pull request #2696 from dmcgowan/import-docker-tar-test
Content store fix and import integration test
2018-10-03 09:57:25 +02:00
Derek McGowan
b6107dca86
Add import integration test
Move tar creation test utilities to separate package
Test all supported formats for import

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-10-01 11:47:10 -07:00
Derek McGowan
db358a9fd2
Fix panic when bufio Reader called in 2 goroutines
A panic was seen related to the buffer being reset in
one goroutine while being read in another. In the case
of pigz an early cancellation will cause the reader to
close, resetting the buffer and signaling the process
to shut down, but races since the process must stop
reading before the reset otherwise the a panic may occur.
This fix guarantees that the bufio is always reset and
returned to the pool on the same goroutine that is
doing the read. If a buffer is not fully read the
buffered reader should just be discarded and not
returned back to the pool.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-09-26 18:11:30 -07:00
Maksym Pavlenko
e8fac24e7b
Remove decompression benchmark, use sync.Once for initialization
Benchmark gist: https://git.io/fASMy

Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
2018-09-18 17:09:12 -07:00
Maksym Pavlenko
003b27eff4
Move compression benchmark test data to gist
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
2018-09-17 13:41:04 -07:00
Maksym Pavlenko
4d7d63f390
Improve layer decompression speed by using pigz
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
2018-09-17 13:41:04 -07:00