Commit graph

3141 commits

Author SHA1 Message Date
Sebastiaan van Stijn
f7d5d70e44
pkg/archive: use containerd/sys to detect UserNamespaces
The implementation in libcontainer/system is quite complicated,
and we only use it to detect if user-namespaces are enabled.

In addition, the implementation in containerd uses a sync.Once,
so that detection (and reading/parsing `/proc/self/uid_map`) is
only performed once.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-06-15 13:06:47 +02:00
Sebastiaan van Stijn
3aac5f0bbb
Merge pull request #41018 from akhilerm/identity-mapping
remove group name from identity mapping
2020-06-08 15:15:05 +02:00
Akhil Mohan
7ad0da7051
remove group name from identity mapping
NewIdentityMapping took group name as an argument, and used
the group name also to parse the /etc/sub{uid,gui}. But as per
linux man pages, the sub{uid,gid} file maps username or uid,
not a group name.

Therefore, all occurrences where mapping is used need to
consider only username and uid. Code trying to map using gid
and group name in the daemon is also removed.

Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
2020-06-03 20:04:42 +05:30
Akihiro Suda
41ac6bef8d
Merge pull request #41026 from XiaodongLoong/master
fix "stat.Rdev" invalid operation mismatched types on mips64el
2020-05-26 16:51:31 +09:00
Xiaodong Liu
a366fe41cb fix "stat.Rdev" invalid operation mismatched types on mips64el
compile error the "stat.Rdev" variable and "s.Rdev" mismatched types on mips64el
convert "stat.Rdev" type to uint64 explicitly

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
2020-05-26 14:50:06 +08:00
Kir Kolyshkin
d5da7e5330 pkg/sysinfo/sysinfo_linux.go: fix some comments
Some were misleading or vague, some were plain wrong.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-05-22 13:13:27 -07:00
Kir Kolyshkin
f02a53d6b9 pkg/sysinfo.applyPIDSCgroupInfo: optimize
For some reason, commit 69cf03700f chose not to use information
already fetched, and called cgroups.FindCgroupMountpoint() instead.
This is not a cheap call, as it has to parse the whole nine yards
of /proc/self/mountinfo, and the info which it tries to get (whether
the pids controller is present) is already available from cgMounts map.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-05-22 13:13:27 -07:00
Gaurav Singh
2a331a5ef7 rm_test: fix goroutine leak
Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
2020-05-18 20:58:26 -04:00
Akihiro Suda
6a5e3547fb pkg/archive: escape ":" symbol in overlay lowerdir
lowerdir needs escaping:
https://github.com/torvalds/linux/blob/v5.4/fs/overlayfs/super.c#L835-L853

Fix #40939

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-05-12 13:28:04 +09:00
Brian Goff
35bf4f87d9 Don't use ini() to set unpigz path
`func init()` is evil here, and the logrus calls are being made before
the logger is even setup.
It also means in order to use pigz you have to restart the daemon.

Instead this takes a small hit and resolves pigz on each extraction.
In the grand scheme of decompressing this is a very small hit.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-05-09 09:51:30 -07:00
Tibor Vass
751d5f879a
Merge pull request #40646 from thaJeztah/builder_use_pkg_sys_windows
pkg/system: deprecate SetNamedSecurityInfo, GetSecurityDescriptorDacl
2020-05-08 08:21:17 -07:00
Brian Goff
232ebf7fa4
Merge pull request #40868 from thaJeztah/what_is_the_cause
Replace errors.Cause() with errors.Is() / errors.As()
2020-05-07 11:33:26 -07:00
Brian Goff
f6163d3f7a
Merge pull request #40673 from kolyshkin/scan
Simplify daemon.overlaySupportsSelinux(), fix use of bufio.Scanner.Err()
2020-04-29 17:18:37 -07:00
Sebastiaan van Stijn
c3b3aedfa4
Merge pull request #40662 from AkihiroSuda/cgroup2-dockerinfo
cgroup2: implement `docker info`
2020-04-29 22:57:00 +02:00
Sebastiaan van Stijn
07d60bc257
Replace errors.Cause() with errors.Is() / errors.As()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-29 00:28:41 +02:00
Sebastiaan van Stijn
8312004f41
remove uses of deprecated pkg/term
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-21 16:29:27 +02:00
Sebastiaan van Stijn
41d4112e89
pkg/term: vendor moby/term and make pkg/term an alias
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-21 16:29:19 +02:00
Sebastiaan van Stijn
701b39f5f0
pkg/term: deprecate package in favor of moby/term
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-21 16:24:18 +02:00
Brian Goff
71626b7bdf
Merge pull request #40766 from thaJeztah/lcow_build_tag
LCOW: add "no_lcow" build tag to allow disabling lcow
2020-04-20 10:43:53 -07:00
Akihiro Suda
f350b53241 cgroup2: implement docker info
ref: https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-04-17 07:20:01 +09:00
Brian Goff
620bce847d
Merge pull request #40749 from DanielQujun/zombie_check_for_container
add zombie check for container when killing it
2020-04-16 12:01:58 -07:00
Sebastiaan van Stijn
7d0e9399a3
Merge pull request #39728 from bamarni/term-proxy-pty
Support reading multiple bytes in escapeProxy
2020-04-16 09:21:40 +02:00
Sebastiaan van Stijn
33e8670ae0
Merge pull request #40786 from alanhoyle/master
Fixed typo in inventor comments.
2020-04-15 16:27:32 +02:00
屈骏
f3c1eec99e add zombie check for container when killing it, alernative fix for #40735.
Signed-off-by: 屈骏 <qujun@tiduyun.com>
2020-04-10 16:46:31 +08:00
Roman Mazur
f2c432636b
pkg/authorization: Fix test failures on macOS
On macOS, unit tests were failing with

root@c4101a75c792:/go/src/github.com/docker/docker/pkg/authorization# go test .
--- FAIL: TestAuthZRequestPluginError (0.00s)
    authz_unix_test.go:295: listen unix authz-test-plugin.sock: bind: file name too long
--- FAIL: TestAuthZRequestPlugin (0.00s)
    authz_unix_test.go:295: listen unix authz-test-plugin.sock: bind: file name too long
--- FAIL: TestAuthZResponsePlugin (0.00s)
    authz_unix_test.go:295: listen unix authz-test-plugin.sock: bind: file name too long
time="2020-04-07T10:07:04Z" level=warning msg="Request body is larger than: '1048576' skipping body"
--- FAIL: TestMiddlewareWrapHandler (0.00s)
    authz_unix_test.go:295: listen unix authz-test-plugin.sock: bind: file name too long
FAIL
FAIL	github.com/docker/docker/pkg/authorization	0.120s

This change moves the socket creation from a working test directory to a tmp directory,
so the path is shorter.

Change-type: patch
Signed-off-by: Roman Mazur <roman@balena.io>
2020-04-08 13:06:50 +03:00
Alan Hoyle
06ca1606e1 Fixed typo in inventor comments.
Kirby and Noyce worked with "silicon" not "silicone"

Signed-off-by: Alan Hoyle <alan@alanhoyle.com>
2020-04-07 09:03:56 -04:00
Akihiro Suda
ff9fa7b43a
Merge pull request #40496 from thaJeztah/locally_scope_variable
TestCatchAll, TestStopCatch: remove unneeded goroutine
2020-04-07 09:54:25 +09:00
Kir Kolyshkin
85dc0fb7d5 pkg/mount: make standalone golint happy
We do our CI via golangci-lint, which understands nolint: annotations.

A standalone linter tool, golint, does not, and it insists on
documenting these:

> pkg/mount/deprecated.go:47:1: comment on exported var MergeTmpfsOptions should be of the form "MergeTmpfsOptions ..."
> pkg/mount/deprecated.go:51:1: comment on exported type FilterFunc should be of the form "FilterFunc ..." (with optional leading article)
> pkg/mount/deprecated.go:51:1: comment on exported type Info should be of the form "Info ..." (with optional leading article)

For `MergeTmpfsOptions`, the workaround is to put it inside a
`var ( ... )` block.

For the other two warnings, we have to provide the "actual"
documentation (or something that looks like it).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-04-02 11:32:27 -07:00
Sebastiaan van Stijn
0d3b400ab5
LCOW: add "no_lcow" build tag to allow disabling lcow
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-02 19:54:16 +02:00
Kir Kolyshkin
745ed9686b pkg/idtools: fix use of bufio.Scanner.Err
The Err() method should be called after the Scan() loop,
not inside it.

Fixes: 9a3ab0358e
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-31 14:32:49 -07:00
Kir Kolyshkin
99beb2ca02 pkg/mount: deprecate
Add a deprecation/removal notice, pointing out to appropriate
replacement packages.

I was not sure if a package-level deprecation is enough, so
I also added notices around each block.

Note that `nolint:golint` annotations are left as is, otherwise
golint complains like this:

> pkg/mount/deprecated.go:45:1: comment on exported var `MergeTmpfsOptions` should be of the form `MergeTmpfsOptions ...` (golint)
> // Deprecated: use github.com/moby/sys/mount instead.
> ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-20 09:46:25 -07:00
Kir Kolyshkin
39048cf656 Really switch to moby/sys/mount*
Switch to moby/sys/mount and mountinfo. Keep the pkg/mount for potential
outside users.

This commit was generated by the following bash script:

```
set -e -u -o pipefail

for file in $(git grep -l 'docker/docker/pkg/mount"' | grep -v ^pkg/mount); do
	sed -i -e 's#/docker/docker/pkg/mount"#/moby/sys/mount"#' \
		-e 's#mount\.\(GetMounts\|Mounted\|Info\|[A-Za-z]*Filter\)#mountinfo.\1#g' \
		$file
	goimports -w $file
done
```

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-20 09:46:25 -07:00
Kir Kolyshkin
59c0495409 pkg/mount: make it shallow
Make pkg/mount a shallow package, relying on
github.com/moby/sys/mount and github.com/moby/sys/mountinfo

The plan is to
 - switch the rest of this repo to use moby/sys directly
 - add deprecation notice to pkg/mount
 - (eventually) remove pkg/mount

The nolint:golint annotation is added to suppress warnings like
"exported XXX should have comment or be unexported".

The ForceMount function is deprecated (and is identical to Mount),
so let's not use it (but still provide an alias for those who do).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-20 09:46:25 -07:00
Bilal Amarni
8dd1490473 Support reading multiple bytes in escapeProxy
Currently, the escapeProxy works under the assumption that the
underlying reader will always return 1 byte at a time. Even though this
is usually true, it is not always the case, for example when using a pty
and writing multiple bytes to the master before flushing it.

In such cases the proxy reader doesn't work properly. For example with
an escape sequence being `ctrl-p,ctrl-q`, when the underlying reader
returns `ctrl-p,ctrl-q` at once, the escape sequence isn't detected.

This updates the reader to support this use-case and adds unit tests.

Signed-off-by: Bilal Amarni <bilal.amarni@gmail.com>
2020-03-18 00:19:53 +04:00
liuxiaodong
25d6047ec0 unit test on TestParseSignal failed within pkg/signal package on mips64el
error log :
signal_test.go:20: assertion failed: error is not nil: Invalid signal: SIGEMT
signal_test.go:22: assertion failed:
When "ParseSignal" function parse sigStr from SignalMap, it find the signal object with key ("SIG"+sigStr). But  EMT signal named "SIGEMT" in SignalMap structrue, so the real key is "SIGSIGEMT" , and cannot find the target signal.
modify "SIGEMT" to "EMT" in SignalMap structrue.

Signed-off-by: liuxiaodong <liuxiaodong@loongson.cn>
2020-03-12 20:45:02 +08:00
Sebastiaan van Stijn
5d86e4a840
Merge pull request #40670 from thaJeztah/fix_linting
fix linting in pkg/mount
2020-03-11 20:04:49 +01:00
Kir Kolyshkin
26f8c7de91
Merge pull request #40647 from thaJeztah/simplify_is_abs
pkg/system: minor linting issues and refactor
2020-03-11 10:52:49 -07:00
Sebastiaan van Stijn
6c0eb9e849
fix linting in pkg/mount
We recently updated golangci-lint, which is checking for some
additional linting rules, causing a failure in code that was
just merged to master; 5bd02b8a86

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-11 18:45:50 +01:00
Sebastiaan van Stijn
8bbba72499
Merge pull request #40637 from kolyshkin/ensure-remove-all
EnsureRemoveAll, RecursiveUnmount: don't call Mounted around Unmount
2020-03-11 18:05:36 +01:00
Sebastiaan van Stijn
d93860bd8d
Merge pull request #40656 from kolyshkin/mount-faster
Make mount.Mount() faster^W great again
2020-03-11 17:58:59 +01:00
Kir Kolyshkin
b890c20555 pkg/archive: use mount pkg
It makes sense to use mount package here because
 - it no longer requires /proc to be mounted
 - it provides verbose errors so the caller doesn't have to

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-10 18:23:53 -07:00
Kir Kolyshkin
83ed668688 pkg/mount.Mount: speedup (remove Mounted check)
This was added in PR #6669 (commit f87afda123) because it was
otherwise impossible to do a re-mount of already mounted file system.

It is way better to just remove the Mounted() check altogether.

This change might potentially lead to multiple mounts to the same
mount point, so I audited all the users (except tests) and it looks
like no one is doing that:

 * volume/local maintains 'mounted' flag for every volume
 * pkg/chrootarchive already calls Mounted() before Mount()
   (so it actually parsed /proc/self/mountinfo twice, oops!)
 * daemon.mountVolumes() is called for docker cp only, and
   it is called once
 * daemon/graphdriver/zfs keeps track of 'mounted' status
 * daemon/graphdriver/devmapper: ditto
 * daemon.createSecretsDir() is only called once during container start

Surely I might have easily missed something so this needs a careful
review.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-10 17:06:26 -07:00
Brian Goff
389ddfd07c
Merge pull request #40649 from thaJeztah/deprecate_CommandLineToArgv
pkg/system: remove unused CommandLineToArgv
2020-03-10 15:46:01 -07:00
Brian Goff
4634ce647c
Merge pull request #40648 from thaJeztah/standalone_symlink
pkg/symlink: don't depend on pkg/system and pkg/longpath
2020-03-10 09:37:18 -07:00
Kir Kolyshkin
5bd02b8a86 pkg/mount.RecursiveUnmount(): don't call Mounted()
Calling mount.Mounted() after an error from Unmount() is
questionable -- if umount failed, the mount is probably
still there anyway, it doesn't make sense to check it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-09 13:08:57 -07:00
Kir Kolyshkin
f8dbc31b78 pkg/system.EnsureRemoveAll: don't call Mounted
1. Call to mount.Mounted() is very expensive and it's redundant
   to call it before Unmount().

2. Calling mount.Mounted() after an error from Unmount() is
   questionable -- if umount failed, the mount is probably
   still there anyway, it doesn't make sense to check it.

This should result in faster code with no change in functionality.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-09 13:08:57 -07:00
Sebastiaan van Stijn
bd2e288e56
pkg/system: remove unused CommandLineToArgv
This function was added in 9c4570a958,
but appears to never have been used.

Removing it, as it's not used in the codebase and, from a quick
search on GitHub, also doesn't look to be used by other projects.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-09 17:02:53 +01:00
Sebastiaan van Stijn
a48c6e3005
pkg/symlink: don't depend on pkg/system and pkg/longpath
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-09 16:41:54 +01:00
Sebastiaan van Stijn
f2d49cb7ee
pkg/system: fix minor linting issues
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-09 16:40:05 +01:00
Sebastiaan van Stijn
dec7a1befb
pkg/system: simplify IsAbs()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-09 16:35:12 +01:00
Sebastiaan van Stijn
079fb80657
pkg/system: replace more uses of "syscall"
follow-up to 069fdc8a08, replacing
more uses of the syscall package in favor of their "windows"
equivalents in golang.org/x/sys.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-09 15:50:43 +01:00
Sebastiaan van Stijn
3bba43b894
pkg/system: deprecate SetNamedSecurityInfo, GetSecurityDescriptorDacl
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-09 12:41:31 +01:00
Kir Kolyshkin
669056f93d pkg/system.getxattr: handle changed size case
lgetxattr(2) man page says:

> If size is specified as zero, these calls return the  current  size  of
> the  named extended attribute (and leave value unchanged).  This can be
> used to determine the size of the buffer that should be supplied  in  a
> subsequent  call.   (But, bear in mind that there is a possibility that
> the attribute value may change between the two calls,  so  that  it  is
> still necessary to check the return status from the second call.)

The current code does not handle the case when the size changes between
the two calls, and the new size is larger.

Fix the above problem, and slightly simplify the code.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-02-26 07:56:12 -08:00
Sebastiaan van Stijn
af2a11f316
TestCatchAll, TestStopCatch: remove unneeded goroutine
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-15 00:41:28 +01:00
Akihiro Suda
7270d7eb94 fix goimports
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-02-11 22:16:54 +09:00
Sebastiaan van Stijn
9f0b3f5609
bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 00:06:42 +01:00
Hsing-Hui Hsu
c90254c746 Add George Washington Carver to name generator
Signed-off-by: Hsing-Hui Hsu <hsinghui@amazon.com>
2020-01-20 14:59:36 -08:00
Hsing-Hui Hsu
ac1d8bc760 Add Mae Jemison to name generator
Signed-off-by: Hsing-Hui Hsu <hsinghui@amazon.com>
2020-01-20 14:57:32 -08:00
Akihiro Suda
409bbdc321 cgroup2: enable resource limitation
enable resource limitation by disabling cgroup v1 warnings

resource limitation still doesn't work with rootless mode (even with systemd mode)

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-01-01 02:58:40 +09:00
Brian Goff
8d2456d1e6
Merge pull request #40246 from thaJeztah/system_windows_cleanup
pkg/system: minor cleanups and remove use of deprecated system.GetOSVersion()
2019-12-19 11:36:29 -08:00
Brian Goff
db85ef598b
Merge pull request #40247 from thaJeztah/pkg_system_consts
pkg/system: deprecate constants in favor of golang.org/x/sys/windows
2019-12-19 11:35:00 -08:00
Brian Goff
b95fad8e51
Merge pull request #40263 from thaJeztah/normalize_comments
Normalize comment formatting
2019-12-12 12:06:22 -08:00
Sascha Grunert
4138cd22ab
Fix possible runtime panic in Lgetxattr
If `unix.Lgetxattr` returns an error, then `sz == -1` which will cause a
runtime panic if `errno == unix.ERANGE`.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-12-04 14:26:02 +01:00
Sebastiaan van Stijn
5331e6ab2d
pkg/tailfile: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:42:07 +01:00
Sebastiaan van Stijn
b95fbe7630
pkg/signal: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:41:47 +01:00
Sebastiaan van Stijn
1d97da61a2
pkg/progress: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:41:23 +01:00
Sebastiaan van Stijn
e2addf46bf
pkg/mount: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:40:58 +01:00
Sebastiaan van Stijn
0b155db389
pkg/jsonmessage: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:40:39 +01:00
Sebastiaan van Stijn
a45b3a92f6
pkg/idtools: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:40:23 +01:00
Sebastiaan van Stijn
14cad10cea
pkg/containerfs: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:39:57 +01:00
Sebastiaan van Stijn
9de5d3da89
pkg/chrootarchive: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:39:12 +01:00
Sebastiaan van Stijn
ecb898dcb9
pkg/archive: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:38:49 +01:00
Sebastiaan van Stijn
0fb5630784
pkg/system: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:38:17 +01:00
Sebastiaan van Stijn
f572df7c22
pkg/system: deprecate constants in favor of golang.org/x/sys/windows
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-25 15:39:34 +01:00
Sebastiaan van Stijn
81f9edc7b0
pkg/parsers: remove use of deprecated system.GetOSVersion()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-25 13:39:25 +01:00
Sebastiaan van Stijn
33d8492ce4
pkg/system/windows: remove unnecessary conversions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-25 13:35:00 +01:00
Sebastiaan van Stijn
4cdb796b54
pkg/system/windows: remove obsolete comment
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-25 13:31:09 +01:00
Brian Goff
8840071c26
Merge pull request #40135 from thaJeztah/nitfix_galore
pkg/system: make OSVersion an alias for hcsshim OSVersion
2019-11-24 07:36:05 -08:00
Tõnis Tiigi
d1d5f64766
Merge pull request #40021 from thaJeztah/carry_40017
Use newer x/sys/windows SecurityAttributes struct (carry 40017)
2019-11-21 08:57:22 -08:00
Ziheng Liu
d7bc994a08 awslogs & archive: prevent 2 goroutine leaks in test functions
Signed-off-by: Ziheng Liu <lzhfromustc@gmail.com>
2019-10-29 17:03:38 -04:00
Tibor Vass
a09e6e323e
Merge pull request #40134 from kolyshkin/homedir-osusergo
Revert "homedir: add cgo or osusergo buildtag constraints for unix"
2019-10-25 15:55:06 -07:00
Kir Kolyshkin
7ef475fc16 pkg/homedir: clarify Get() docs wrt static linking
This clarifies comments about static linking made in commit a8608b5b67.

1. There are two ways to create a static binary, one is to disable
cgo, the other is to set linker flags. When cgo is disabled,
there is no need to use osusergo build tag.

2. osusergo only needs to be set when linking against glibc.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-10-24 16:39:24 -07:00
Sebastiaan van Stijn
9d12bc2573
pkg/system: make OSVersion an alias for hcsshim OSVersion
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-25 00:31:36 +02:00
Kir Kolyshkin
80e338a18d Revert "homedir: add cgo or osusergo buildtag constraints for unix"
TL;DR: there is no way to do this right.

We do know that in some combination of build tags set (or unset),
linker flags, environment variables, and libc implementation,
this package won't work right. In fact, there is one specific
combination:

1. `CGO_ENABLED=1` (or unset)
2. static binary is being built (e.g. `go build` is run with `-extldflags -static`)
3. `go build` links the binary against glibc
4. `osusergo` is not set

This particular combination results in the following legitimate linker warning:

> cgo_lookup_unix.go: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

If this warning is ignored and the resulting binary is used on a system
with files from a different glibc version (or without those files), it
could result in a segfault.

The commit being reverted tried to guard against such possibility,
but the problem is, we can only use build tags to account for items
1 and 4 from the above list, while items 2 and 3 do not result in
any build tags being set or unset, making this guard excessive.

Remove it.

This reverts commit 023b072288.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-10-24 13:13:09 -07:00
Sebastiaan van Stijn
86b3703182
Deprecate pkg/system.GetOSVersion() in favor of hcsshim/osversion.Get()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-22 02:53:09 +02:00
Sebastiaan van Stijn
6b91ceff74
Use hcsshim osversion package for Windows versions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-22 02:53:00 +02:00
Tibor Vass
c4cf72bad3
Merge pull request #39964 from thaJeztah/bump_golangci_lint
bump golangci-lint v1.20.0
2019-10-21 10:57:02 -07:00
trace-andreason
ddb64c14e1 fixed typo, changed "perfectd to perfected"
Signed-off-by: Trace <tandreason@gmail.com>
2019-10-19 12:43:59 -07:00
Sebastiaan van Stijn
4840fd8953
pkg/mount: SA4011: ineffective break statement (staticcheck)
```
pkg/mount/mountinfo_linux.go:93:5: SA4011: ineffective break statement. Did you mean to break out of the outer loop? (staticcheck)
				break
				^
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-18 00:46:02 +02:00
Sebastiaan van Stijn
04fcb6cfbf
pkg/jsonmessage: fix SA1006: printf-style function with no arguments
Also fixed some incorrectly formatted comments

```
pkg/jsonmessage/jsonmessage.go:180:20: SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)
		fmt.Fprintf(out, endl)
		                 ^
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-18 00:45:37 +02:00
Sebastiaan van Stijn
aa655a4d73
pkg/plugins: use constants for http methods
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-13 19:11:30 +02:00
Sebastiaan van Stijn
5ba167ce8a
pkg/authorization: use constants for http methods
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-13 19:11:28 +02:00
Jason A. Donenfeld
c3a0a37446
Use newer x/sys/windows SecurityAttributes struct
This struct now has a properly typed member, so use the properly typed
functions with it.

Also update the vendor directory and hope nothing explodes.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-02 21:12:23 +02:00
Sebastiaan van Stijn
0b5140dd66
Merge pull request #39994 from tiborvass/homedir-buildtags
homedir: add cgo or osusergo buildtag constraints for unix
2019-09-30 20:18:36 +02:00
HuanHuan Ye
8498ee7514 Fix pkg/pools staticcheck SA6002
change bufferPool use pointer instead byte slice

Signed-off-by: HuanHuan Ye <logindaveye@gmail.com>
2019-09-30 12:19:03 +08:00
Tibor Vass
023b072288 homedir: add cgo or osusergo buildtag constraints for unix
This is to ensure that users of the homedir package cannot
compile statically (CGO_ENABLED=0) without also setting the osusergo
build tag.

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-26 21:09:36 +00:00
Sebastiaan van Stijn
2c6d368992
Merge pull request #39975 from tiborvass/homedir-less-deps
homedir: remove idtools and libcontainer's user package dependencies
2019-09-26 20:49:39 +02:00
hn3000
77d3c68f97 Remove minsky and stallman
Their inclusion is no longer defensible.
closes #39981

Signed-off-by: Harald Niesche <harald@niesche.de>
2019-09-24 23:47:31 +02:00
Tibor Vass
a8608b5b67 homedir: remove idtools and libcontainer's user package dependencies
About github.com/opencontainers/runc/libcontainer/user:

According to 195d8d544a
this package has two functions:
- Have a static implementation of user lookup, which is now supported in the
  os/user stdlib package with the osusergo build tag, but wasn't at the time.
- Have extra functions that os/user doesn't have, but none of those are used
  in homedir.

Since https://github.com/moby/moby/pull/11287, homedir depended directly on
libcontainer's user package for CurrentUser().
This is being replaced with os/user.Current(), because all of our static
binaries are compiled with the osusergo tag, and for dynamic libraries it
is more correct to use libc's implementation than parsing /etc/passwd.

About github.com/docker/docker/pkg/idtools:

Only dependency was from GetStatic() which uses idtools.LookupUID(uid).
The implementation of idtools.LookupUID just calls to
github.com/opencontainers/runc/libcontainer/user.LookupUid or fallbacks
to exec-ing to getent (since https://github.com/moby/moby/pull/27599).

This patch replaces calls to homedir.GetStatic by homedir.Get(), opting out
of supporting nss lookups in static binaries via exec-ing to getent for
the homedir package.

If homedir package users need to support nss lookups, they are advised
to compile dynamically instead.

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-24 00:32:13 +00:00
Justen Martin
23ab331979 Removed deprecated CloseNotifier logic
Signed-off-by: Justen Martin <jmart@the-coder.com>
2019-09-18 16:14:30 -05:00
Sebastiaan van Stijn
e92e0d358a
TestPollerEvent: fix filemode (staticcheck)
Staticcheck reported:

    SA9002: file mode '600' evaluates to 01130; did you mean '0600'? (staticcheck)

But fixing that caused the test to fail:

    === Failed
    === FAIL: pkg/filenotify TestPollerEvent (0.80s)
        poller_test.go:75: timeout waiting for event CHMOD

The problem turned out to be that the file was created with `0644`. However,
after umask, the file created actually had `0600` filemode. Running the `os.Chmod`
with `0600` therefore was a no-op, causing the test to fail (because no
CHMOD event would fire).

This patch changes the test to;

- create the file with mode `0600`
- assert that the file has the expected mode
- change the chmod to `0644`
- assert that it has the correct mode, before testing the event.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:56 +02:00
Sebastiaan van Stijn
805452a59a
pkg/devicemapper ignore SA4000 false positive (staticcheck)
```
pkg/devicemapper/devmapper_wrapper.go:209:206: SA4000: identical expressions on the left and right side of the '==' operator (staticcheck)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:52 +02:00
Sebastiaan van Stijn
9faf565453
pkg/devicemapper: disable unused and varcheck linters
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:51 +02:00
Sebastiaan van Stijn
9419024554
gosec: add ignore comments for reported issues that can be ignored
```
builder/remotecontext/remote.go:48:        G107: Potential HTTP request made with variable url (gosec)
builder/remotecontext/git/gitutils.go:145: G107: Potential HTTP request made with variable url (gosec)
builder/remotecontext/git/gitutils.go:147: G107: Potential HTTP request made with variable url (gosec)
pkg/fileutils/fileutils_test.go:185:       G303: File creation in shared tmp directory without using ioutil.Tempfile (gosec)
pkg/tarsum/tarsum_test.go:7:               G501: Blacklisted import `crypto/md5`: weak cryptographic primitive (gosec)
pkg/tarsum/tarsum_test.go:9:               G505: Blacklisted import `crypto/sha1`: weak cryptographic primitive (gosec)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:43 +02:00
Sebastiaan van Stijn
323ac07901
pkg/containerfs: rename output variable to prevent shadowing (govet)
```
pkg/containerfs/archiver.go:121:6: shadow: declaration of "err" shadows declaration at line 92 (govet)
	if err := dstDriver.MkdirAll(dstDriver.Dir(dst), 0700); err != nil {
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:41 +02:00
Sebastiaan van Stijn
739b7b44aa
pkg/term/windows: add missing build-tag
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:36 +02:00
Sebastiaan van Stijn
4215492120
pkg/ioutils use sha256 instead of sha1 in tests
Not really important as it's just test-code, but prevents
gosec linting from producing warnings

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:35 +02:00
Sebastiaan van Stijn
2c31edbbb6
unconvert: remove unnescessary conversions
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:33 +02:00
Sebastiaan van Stijn
3a16c7246a
pkg/signal: remove unnescessary conversion (unconvert)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:32 +02:00
Kir Kolyshkin
d8f2b47432
TestDisplayJSONMessagesStreamInvalidJSON: fix error check
As pointed out by govet,

> pkg/jsonmessage/jsonmessage_test.go:231:94: nilness: nil dereference in dynamic method call (govet)
> 	if err := DisplayJSONMessagesStream(reader, data, inFd, false, nil); err == nil && err.Error()[:17] != "invalid character" {
>	                                                                                            ^

The nil deref never happened as err was always non-nil, and so the check
for error message text was not performed.

Fix this, and while at it, refactor the code a bit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-18 12:57:26 +02:00
Kir Kolyshkin
b5695b8663
pkg/term/term_linux_test: check returned error before deferring tty.Close() (staticcheck)
Fix the following warnings from staticcheck linter:

```
pkg/term/term_linux_test.go:34:2: SA5001: should check returned error before deferring tty.Close() (staticcheck)
	defer tty.Close()
	^
pkg/term/term_linux_test.go:52:2: SA5001: should check returned error before deferring tty.Close() (staticcheck)
 	defer tty.Close()
	^
pkg/term/term_linux_test.go:67:2: SA5001: should check returned error before deferring tty.Close() (staticcheck)
	defer tty.Close()
	^
....
```

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:14 +02:00
Sebastiaan van Stijn
744f1c261c
Remove unused functions, variables, fields
opts/env_test: suppress a linter warning

this one:

> opts/env_test.go:95:4: U1000: field `err` is unused (unused)
> 			err      error
>			^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:12 +02:00
Sebastiaan van Stijn
07ff4f1de8
goimports: fix imports
Format the source according to latest goimports.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:56:54 +02:00
Sebastiaan van Stijn
e334eeeed8
TestMoveToSubdir: use sort.Strings() (gosimple)
```
13:06:14 pkg/directory/directory_test.go:182:2: S1032: should use sort.Strings(...) instead of sort.Sort(sort.StringSlice(...)) (gosimple)
13:06:14 	sort.Sort(sort.StringSlice(results))
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:55:45 +02:00
Sebastiaan van Stijn
ab599b5cdc
pkg/pools/pools.go: suppress SA6002: argument should be pointer-like for now
```
13:06:14 pkg/pools/pools.go:75:13: SA6002: argument should be pointer-like to avoid allocations (staticcheck)
13:06:14 	bp.pool.Put(b)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:55:44 +02:00
Sebastiaan van Stijn
178af761b7
TestParseRelease: fix missing assert
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:55:44 +02:00
Brian Goff
0c099fa91e
Merge pull request #39860 from stbenjam/cmd-race
archive: fix race condition in cmdStream
2019-09-12 11:52:56 -07:00
Kirill Kolyshkin
7bcffeef6e
Merge pull request #39901 from thaJeztah/remove_docker_cli_autogen
hack/make: remove autogen resources for Docker CLI
2019-09-12 20:21:51 +03:00
Sebastiaan van Stijn
871994ce2a
Merge pull request #39849 from tklauser/uname-unix-no-exec
Use unix.Uname instead of shelling out to uname on darwin/freebsd
2019-09-11 20:52:23 +02:00
Sebastiaan van Stijn
a9aeda8343
Rename some references to docker.exe to dockerd.exe
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-11 15:16:27 +02:00
Stephen Benjamin
89dd10b06e archive: fix race condition in cmdStream
There is a race condition in pkg/archive when using `cmd.Start` for pigz
and xz where the `*bufio.Reader` could be returned to the pool while the
command is still writing to it, and then picked up and used by a new
command.

The command is wrapped in a `CommandContext` where the process will be
killed when the context is cancelled, however this is not instantaneous,
so there's a brief window while the command is still running but the
`*bufio.Reader` was already returned to the pool.

wrapReadCloser calls `cancel()`, and then `readBuf.Close()` which
eventually returns the buffer to the pool. However, because cmdStream
runs `cmd.Wait` in a go routine that we never wait for to finish, it is
not safe to return the reader to the pool yet.  We need to ensure we
wait for `cmd.Wait` to finish!

Signed-off-by: Stephen Benjamin <stephen@redhat.com>
2019-09-11 07:37:14 -04:00
Tibor Vass
086ac1e022
Merge pull request #39883 from thaJeztah/gofmt_pkg_parsers
pkg/parsers/kernel: gofmt hex value (preparation for Go 1.13+)
2019-09-10 14:23:36 -07:00
Sebastiaan van Stijn
1fd0107d7f
Merge pull request #39799 from tiborvass/bye-bye-gocheck
Remove go-check
2019-09-10 22:58:57 +02:00
Brian Goff
415f8ecb65
Merge pull request #39873 from jonjohnsonjr/undep-graphdriver
Narrow dependencies of pkg/system
2019-09-10 11:15:29 -07:00
Sebastiaan van Stijn
7663aebc12
pkg/parsers/kernel: gofmt hex value (preparation for Go 1.13+)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-10 11:44:51 +02:00
Tibor Vass
8b40da168b Setup tests
Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:09:57 +00:00
Tibor Vass
40f1950e8e fix remaining issues with checker.Not
Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:09:57 +00:00
Tibor Vass
59e55dcdd0 rm-gocheck: run goimports to compile successfully
goimports -w \
-- "./integration-cli/daemon" "./pkg/discovery" "./pkg/discovery/file" "./pkg/discovery/kv" "./pkg/discovery/memory" "./pkg/discovery/nodes" "./integration-cli" \
&& \
 gofmt -w -s \
-- "./integration-cli/daemon" "./pkg/discovery" "./pkg/discovery/file" "./pkg/discovery/kv" "./pkg/discovery/memory" "./pkg/discovery/nodes" "./integration-cli"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:06:12 +00:00
Tibor Vass
eb67bb9fb5 rm-gocheck: comment out check.TestingT
sed -E -i 's#([^*])(check\.TestingT\([^\)]+\))#\1/*\2*/#g' \
-- "integration-cli/check_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/memory/memory_test.go" "pkg/discovery/nodes/nodes_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:58 +00:00
Tibor Vass
81d2a0c389 rm-gocheck: comment out check.Suite calls
sed -E -i 's#^([^*])+?((var .*)?check\.Suite\(.*\))#\1/*\2*/#g' \
-- "integration-cli/check_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_hub_pull_suite_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/memory/memory_test.go" "pkg/discovery/nodes/nodes_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:58 +00:00
Tibor Vass
64a161aa3e rm-gocheck: NotNil
sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.NotNil\b#assert.Assert(c, \1 != nil#g' \
-- "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_volume_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/nodes/nodes_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:57 +00:00
Tibor Vass
2743e2d8bc rm-gocheck: IsNil
sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.IsNil\b#assert.Assert(c, \1 == nil#g' \
-- "integration-cli/docker_api_containers_test.go" "integration-cli/docker_cli_attach_test.go" "integration-cli/docker_cli_attach_unix_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_build_unix_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_cp_from_container_test.go" "integration-cli/docker_cli_cp_to_container_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_health_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_userns_test.go" "integration-cli/docker_cli_volume_test.go" "integration-cli/docker_hub_pull_suite_test.go" "integration-cli/docker_utils_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/memory/memory_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:57 +00:00
Tibor Vass
491ef7b901 rm-gocheck: HasLen -> assert.Equal + len()
sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.HasLen, (.*)#assert.Equal(c, len(\1), \2#g' \
-- "integration-cli/docker_api_containers_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_userns_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/kv/kv_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:57 +00:00
Tibor Vass
dd9d28669f rm-gocheck: DeepEquals -> assert.DeepEqual
sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.DeepEquals, (.*)#assert.DeepEqual(c, \1, \2#g' \
-- "integration-cli/docker_cli_daemon_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/memory/memory_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:57 +00:00
Tibor Vass
6dc7f4c167 rm-gocheck: Equals -> assert.Equal
sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.Equals, (.*)#assert.Equal(c, \1, \2#g' \
-- "integration-cli/docker_api_containers_test.go" "integration-cli/docker_api_swarm_node_test.go" "integration-cli/docker_cli_attach_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_build_unix_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_commit_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_health_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_info_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_rmi_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_userns_test.go" "integration-cli/docker_cli_volume_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/generator_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/nodes/nodes_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:56 +00:00
Tibor Vass
230f7bcc02 rm-gocheck: normalize to use checker
sed -E -i 's#\bcheck\.(Equals|DeepEquals|HasLen|IsNil|Matches|Not|NotNil)\b#checker.\1#g' \
-- "integration-cli/docker_api_containers_test.go" "integration-cli/docker_cli_attach_test.go" "integration-cli/docker_cli_attach_unix_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_build_unix_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_health_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_volume_test.go" "integration-cli/docker_utils_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/generator_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/memory/memory_test.go" "pkg/discovery/nodes/nodes_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:56 +00:00
Tibor Vass
a7d144fb34 rm-gocheck: ErrorMatches -> assert.ErrorContains
sed -E -i 's#\bassert\.Assert\(c, (.*), check\.ErrorMatches,#assert.ErrorContains(c, \1,#g' \
-- "pkg/discovery/kv/kv_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:55 +00:00
Tibor Vass
1d92789b4f rm-gocheck: check.C -> testing.T
sed -E -i 's#\bcheck\.C\b#testing.T#g' \
-- "integration-cli/check_test.go" "integration-cli/daemon/daemon.go" "integration-cli/daemon/daemon_swarm.go" "integration-cli/daemon_swarm_hack_test.go" "integration-cli/docker_api_attach_test.go" "integration-cli/docker_api_build_test.go" "integration-cli/docker_api_build_windows_test.go" "integration-cli/docker_api_containers_test.go" "integration-cli/docker_api_containers_windows_test.go" "integration-cli/docker_api_exec_resize_test.go" "integration-cli/docker_api_exec_test.go" "integration-cli/docker_api_images_test.go" "integration-cli/docker_api_inspect_test.go" "integration-cli/docker_api_logs_test.go" "integration-cli/docker_api_network_test.go" "integration-cli/docker_api_stats_test.go" "integration-cli/docker_api_swarm_node_test.go" "integration-cli/docker_api_swarm_service_test.go" "integration-cli/docker_api_swarm_test.go" "integration-cli/docker_api_test.go" "integration-cli/docker_cli_attach_test.go" "integration-cli/docker_cli_attach_unix_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_build_unix_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_commit_test.go" "integration-cli/docker_cli_cp_from_container_test.go" "integration-cli/docker_cli_cp_test.go" "integration-cli/docker_cli_cp_to_container_test.go" "integration-cli/docker_cli_cp_to_container_unix_test.go" "integration-cli/docker_cli_cp_utils_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_plugins_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_events_test.go" "integration-cli/docker_cli_events_unix_test.go" "integration-cli/docker_cli_exec_test.go" "integration-cli/docker_cli_exec_unix_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_health_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_info_test.go" "integration-cli/docker_cli_info_unix_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_login_test.go" "integration-cli/docker_cli_logout_test.go" "integration-cli/docker_cli_logs_test.go" "integration-cli/docker_cli_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_logdriver_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_proxy_test.go" "integration-cli/docker_cli_prune_unix_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_pull_test.go" "integration-cli/docker_cli_push_test.go" "integration-cli/docker_cli_registry_user_agent_test.go" "integration-cli/docker_cli_restart_test.go" "integration-cli/docker_cli_rmi_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_save_load_unix_test.go" "integration-cli/docker_cli_search_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_service_logs_test.go" "integration-cli/docker_cli_service_scale_test.go" "integration-cli/docker_cli_sni_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_stats_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_swarm_unix_test.go" "integration-cli/docker_cli_top_test.go" "integration-cli/docker_cli_update_unix_test.go" "integration-cli/docker_cli_userns_test.go" "integration-cli/docker_cli_v2_only_test.go" "integration-cli/docker_cli_volume_test.go" "integration-cli/docker_deprecated_api_v124_test.go" "integration-cli/docker_deprecated_api_v124_unix_test.go" "integration-cli/docker_hub_pull_suite_test.go" "integration-cli/docker_utils_test.go" "integration-cli/events_utils_test.go" "integration-cli/fixtures_linux_daemon_test.go" "integration-cli/utils_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/generator_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/memory/memory_test.go" "pkg/discovery/nodes/nodes_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:55 +00:00
Tibor Vass
1f69c62540 rm-gocheck: c.Assert(...) -> assert.Assert(c, ...)
sed -E -i 's#\bc\.Assert\(#assert.Assert(c, #g' \
-- "integration-cli/docker_api_containers_test.go" "integration-cli/docker_api_swarm_node_test.go" "integration-cli/docker_cli_attach_test.go" "integration-cli/docker_cli_attach_unix_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_build_unix_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_commit_test.go" "integration-cli/docker_cli_cp_from_container_test.go" "integration-cli/docker_cli_cp_to_container_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_health_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_info_test.go" "integration-cli/docker_cli_info_unix_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_prune_unix_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_rmi_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_userns_test.go" "integration-cli/docker_cli_volume_test.go" "integration-cli/docker_hub_pull_suite_test.go" "integration-cli/docker_utils_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/generator_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/memory/memory_test.go" "pkg/discovery/nodes/nodes_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:05:55 +00:00
Tibor Vass
931edfe5e9 prepare for rm-gocheck script
Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 20:49:53 +00:00
Jon Johnson
57ade2652a Narrow dependencies of pkg/system
CheckSystemDriveAndRemoveDriveLetter depends on pathdriver.PathDriver
unnecessarily. This depends on the minimal interface that it actually
needs, to avoid callers from unnecessarily bringing in a
containerd/continuity dependency.

Signed-off-by: Jon Johnson <jonjohnson@google.com>
2019-09-06 16:25:14 -07:00
Tibor Vass
4ce040289a
Merge pull request #39800 from thaJeztah/refactor_TestEscapeProxyRead
pkg/term: refactor TestEscapeProxyRead
2019-09-06 13:51:06 -07:00
Tobias Klauser
7aeb3efcb4 Use unix.Uname instead of shelling out to uname on darwin/freebsd
Reuse the linux implementation based on Uname from golang.org/x/sys/unix
for darwin and freebsd.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-09-03 22:43:16 +02:00
Tobias Klauser
6751718196 Remove *_solaris.go files
Support for GOOS=solaris was removed in PR #35373. Remove two leftover
*_solaris.go files missed in this PR.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-09-02 10:15:15 +02:00
Sebastiaan van Stijn
339dd0a2e5
Merge pull request #39801 from kolyshkin/loopback-idx
Use correct `LOOP_CTL_GET_FREE` API in `pkg/loopback`
2019-08-30 21:49:52 +02:00
Sebastiaan van Stijn
1cfc3060a8
Merge pull request #39825 from secrethub/fix/os-darwin
Fix getting the operating system on Darwin
2019-08-30 15:38:47 +02:00
Simon Barendse
fa29ff2212
Fix compiling pkg/parsers/operatingsystem on unix
fmt.Error does not exist. I've replaced it with errors.New.

Signed-off-by: Simon Barendse <simon.barendse@gmail.com>
2019-08-29 18:46:17 +02:00
Simon Barendse
ea65f0bca2
Fix getting the operating system on Darwin
This used to return "Darwin\n", but now returns "Darwin"

Signed-off-by: Simon Barendse <simon.barendse@gmail.com>
2019-08-29 18:39:04 +02:00
Tibor Vass
32688a47f3
Merge pull request #39699 from thaJeztah/mkdirall_dropin
Allow system.MkDirAll() to be used as drop-in for os.MkDirAll()
2019-08-27 16:27:53 -07:00
Daniel Sweet
db2bc43017 Use correct LOOP_CTL_GET_FREE API in pkg/loopback
The `ioctl` interface for the `LOOP_CTL_GET_FREE` request on
`/dev/loop-control` is a little different from what `unix.IoctlGetInt`
expects: the first index is the returned status in `r1`, not an `int`
pointer as the first parameter.

Unfortunately we have to go a little lower level to get the appropriate
loop device index out, using `unix.Syscall` directly to read from
`r1`. Internally, the index is returned as a signed integer to match the
internal `ioctl` expectations of interpreting a negative signed integer
as an error at the userspace ABI boundary, so the direct interface of
`ioctlLoopCtlGetFree` can remain as-is.

[@kolyshkin: it still worked before this fix because of
/dev scan fallback in ioctlLoopCtlGetFree()]

Signed-off-by: Daniel Sweet <danieljsweet@icloud.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-08-27 06:22:10 -07:00
Sebastiaan van Stijn
556d26c07d
pkg/term: refactor TestEscapeProxyRead
- use subtests to make it clearer what the individual test-cases
  are, and to prevent tests from depending on values set by the
  previous test(s).
- remove redundant messages in assert (gotest.tools already prints
  a useful message if assertions fail).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-27 15:07:02 +02:00
Tobias Klauser
2841b05b71 Use Klogctl from x/sys/unix to read Linux kernel log
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-08-22 08:25:13 +02:00
Tobias Klauser
e551e5a73d Use UtimesNano from x/sys/unix to implement LUtimesNano
This allows to merge the implementation for Linux and FreeBSD.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-08-22 08:25:13 +02:00
Tobias Klauser
919d08347a Use loopback types and constants from x/sys/unix to implement pkg/loopback without cgo
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-08-22 08:25:13 +02:00
Louis Delossantos
9c5f3adbf5 add options.NoLchown option to createTar call
Signed-off-by: Louis Delossantos <ldelossa.ld@gmail.com>
2019-08-15 18:08:43 -04:00
Sebastiaan van Stijn
e554ab5589
Allow system.MkDirAll() to be used as drop-in for os.MkDirAll()
also renamed the non-windows variant of this file to be
consistent with other files in this package

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-08 15:05:49 +02:00
Sebastiaan van Stijn
13ea237234
devicemapper: remove unused errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-07 12:27:44 +02:00
Sebastiaan van Stijn
5b2f8e9103
devicemapper: remove unused task.setRo()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-07 12:25:26 +02:00
Dominic
5f0231bca1
cast Dev and Rdev of Stat_t to uint64 for mips
Signed-off-by: Dominic <yindongchao@inspur.com>
Signed-off-by: Dominic Yin <yindongchao@inspur.com>
2019-08-01 20:22:49 +08:00
Justin Cormack
a316b10dab Initialize nss libraries in Glibc so that the dynamic libraries are loaded in the host
environment not in the chroot from untrusted files.

See also OpenVZ a3f732ef75/src/enter.c (L227-L234)

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
(cherry picked from commit cea6dca993c2b4cfa99b1e7a19ca134c8ebc236b)
Signed-off-by: Tibor Vass <tibor@docker.com>
2019-07-26 01:27:57 +00:00
Brian Goff
e6091b28c5
Merge pull request #39422 from lemrouch/35876-workaround
Don't try to load plugin without name
2019-07-22 10:21:50 -07:00
Brian Goff
ffabf0d542
Merge pull request #38020 from thaJeztah/remove_iot_check
Remove skip evaluation of symlinks to data root on IoT Core
2019-07-15 11:13:19 -07:00
Sebastiaan van Stijn
763454e1e4
Remove unused pkg/system.IsIoTCore()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-13 23:45:08 +02:00
Sebastiaan van Stijn
bad0b4e604
Remove skip evaluation of symlinks to data root on IoT Core
This fix was added in 8e71b1e210 to work around
a go issue (https://github.com/golang/go/issues/20506).

That issue was fixed in
66c03d39f3,
which is part of Go 1.10 and up. This reverts the changes that were made in
8e71b1e210, and are no longer needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-13 23:44:51 +02:00
Sebastiaan van Stijn
44a3267912
Merge pull request #39481 from KentaTada/use-memavailable
Use MemAvailable instead of MemFree to estimate actual available memory
2019-07-13 19:59:43 +02:00
Sebastiaan van Stijn
c7816c5323
Harden TestClientWithRequestTimeout
DeadlineExceeded now implements a TimeOut() function,
since dc4427f372

Check for this interface, to prevent possibly incorrect failures;

```
00:16:41 --- FAIL: TestClientWithRequestTimeout (0.00s)
00:16:41     client_test.go:259: assertion failed:
00:16:41         --- context.DeadlineExceeded
00:16:41         +++ err
00:16:41         :
00:16:41         	-: context.deadlineExceededError{}
00:16:41         	+: &net.OpError{Op: "dial", Net: "tcp", Addr: s"127.0.0.1:49294", Err: &poll.TimeoutError{}}
00:16:41
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-12 12:31:51 +02:00
Kenta Tada
65177a72c5 Use MemAvailable instead of MemFree to estimate actual available memory
Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
2019-07-10 17:43:03 +09:00
Robert Wang
2f9e62611e Enhance container detection on some corner cases.
Not really bullet-proof, users can still create cgroups with name like
"foo:/init.scope" or "\nfoo" to bypass the detection. However, solving
these cases will require kernel to provide a better interface.

Signed-off-by: Robert Wang <robert@arctic.tw>
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-07-08 15:31:41 -04:00
Pavel Matěja
ee09f5a4af Don't try to load plugin without name
This can happen when you have --config-only network
Such attempt will fail anyway and it will create 15s delay in container
startup

Signed-off-by: Pavel Matěja <pavel@verotel.cz>
2019-07-08 14:52:45 +02:00
Brian Goff
34d5b8867f Add realChroot for non linux/windows
3029e765e2 broke compilation on
non-Linux/Windows systems.
This change fixes that.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2019-07-03 14:36:48 -07:00
Yong Tang
b2b2de3699
Merge pull request #39455 from seemethere/remove_cocky
Remove cocky from names-generator
2019-07-03 16:36:51 +08:00
Eli Uriegas
8be39cd277 Remove cocky from names-generator
Could be misinterpreted as something not too kosher

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2019-07-02 16:51:11 +00:00
lzhfromutsc
c2479f6ebf Fixed the inconsistence and also a potential data race in pkg/ioutils/bytespipe.go: bp.closeErr is read/write 8 times; 7 out of 8 times it is protected by bp.mu.Lock(); 1 out of 8 times it is read without a Lock
Signed-off-by: lzhfromutsc <lzhfromustc@gmail.com>
2019-07-01 11:38:38 -07:00
Tobias Klauser
ba8a15694a Use functions from x/sys/unix to get number of CPUs on Linux
Use Getpid and SchedGetaffinity from golang.org/x/sys/unix to get the
number of CPUs in numCPU on Linux.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-06-18 19:26:56 +02:00
Tibor Vass
7410f1a859 pkg/archive: keep walkRoot clean if source is /
Previously, getWalkRoot("/", "foo") would return "//foo"
Now it returns "/foo"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-06-14 03:57:58 +00:00
Sebastiaan van Stijn
e511b3be89
Merge pull request #39336 from justincormack/entropy-cannot-be-saved
Entropy cannot be saved
2019-06-11 18:40:19 +02:00
Sebastiaan van Stijn
28678f2226
Merge pull request #38349 from wk8/wk8/os_version
Adding OS version info to nodes' `Info` struct and to the system info's API
2019-06-07 14:54:51 +02:00
Sebastiaan van Stijn
c85fe2d224
Merge pull request #38522 from cpuguy83/fix_timers
Make sure timers are stopped after use.
2019-06-07 13:16:46 +02:00
Justin Cormack
2df693e533
Entropy cannot be saved
Remove non cryptographic randomness.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2019-06-07 11:54:45 +01:00
Jean Rouge
d363a1881e Adding OS version info to the nodes' Info struct
This is needed so that we can add OS version constraints in Swarmkit, which
does require the engine to report its host's OS version (see
https://github.com/docker/swarmkit/issues/2770).

The OS version is parsed from the `os-release` file on Linux, and from the
`ReleaseId` string value of the `SOFTWARE\Microsoft\Windows NT\CurrentVersion`
registry key on Windows.

Added unit tests when possible, as well as Prometheus metrics.

Signed-off-by: Jean Rouge <rougej+github@gmail.com>
2019-06-06 22:40:10 +00:00
Sebastiaan van Stijn
bd89b3f553
Merge pull request #39288 from dohse/do-not-order-uid-gid-mappings
Stop sorting uid and gid ranges in id maps
2019-06-04 20:12:30 +02:00
Brian Goff
3029e765e2 Add chroot for tar packing operations
Previously only unpack operations were supported with chroot.
This adds chroot support for packing operations.
This prevents potential breakouts when copying data from a container.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2019-06-03 09:45:29 -07:00
Brian Goff
d089b63937 Pass root to chroot to for chroot Untar
This is useful for preventing CVE-2018-15664 where a malicious container
process can take advantage of a race on symlink resolution/sanitization.

Before this change chrootarchive would chroot to the destination
directory which is attacker controlled. With this patch we always chroot
to the container's root which is not attacker controlled.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2019-06-03 09:45:21 -07:00
Jonas Dohse
c4628d79d2 Stop sorting uid and gid ranges in id maps
Moby currently sorts uid and gid ranges in id maps. This causes subuid
and subgid files to be interpreted wrongly.

The subuid file

```
> cat /etc/subuid
jonas:100000:1000
jonas:1000:1
```

configures that the container uids 0-999 are mapped to the host uids
100000-100999 and uid 1000 in the container is mapped to uid 1000 on the
host. The expected uid_map is:

```
> docker run ubuntu cat /proc/self/uid_map
         0     100000       1000
      1000       1000          1
```

Moby currently sorts the ranges by the first id in the range. Therefore
with the subuid file above the uid 0 in the container is mapped to uid
100000 on host and the uids 1-1000 in container are mapped to the uids
1-1000 on the host. The resulting uid_map is:

```
> docker run ubuntu cat /proc/self/uid_map
         0       1000          1
         1     100000       1000
```

The ordering was implemented to work around a limitation in Linux 3.8.
This is fixed since Linux 3.9 as stated on the user namespaces manpage
[1]:

> In the initial implementation (Linux 3.8), this requirement was
> satisfied by a simplistic implementation that imposed the further
> requirement that the values in both field 1 and field 2 of successive
> lines must be in ascending numerical order, which prevented some
> otherwise valid maps from being created.  Linux 3.9 and later fix this
> limitation, allowing any valid set of nonoverlapping maps.

This fix changes the interpretation of subuid and subgid files which do
not have the ids of in the numerical order for each individual user.
This breaks users that rely on the current behaviour.

The desired mapping above - map low user ids in the container to high
user ids on the host and some higher user ids in the container to lower
user on host - can unfortunately not archived with the current
behaviour.

[1] http://man7.org/linux/man-pages/man7/user_namespaces.7.html

Signed-off-by: Jonas Dohse <jonas@dohse.ch>
2019-06-03 15:50:26 +02:00
Olli Janatuinen
14280fdc62 Fix to gofmt/goimports errors
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
2019-05-28 20:32:27 +03:00
Kirill Kolyshkin
6899fc094e
Merge pull request #39203 from slar/master
fixes #39145: Correct copy paste mistage in pkg/mount/mountinfo_freebsd.go that cau…
2019-05-26 11:36:24 -07:00
Sebastiaan van Stijn
19008faf03
Merge pull request #38992 from kolyshkin/mnt
pkg/mount: optimizations
2019-05-20 14:12:42 +02:00
Stig Larsson
6205fcf60d Correct copy paste mistage in pkg/mount/mountinfo_freebsd.go that caused compile errors.
Signed-off-by: Stig Larsson <stig@larsson.dev>
2019-05-11 14:04:02 +00:00
Rob Gulewich
256eb04d69 Start containers in their own cgroup namespaces
This is enabled for all containers that are not run with --privileged,
if the kernel supports it.

Fixes #38332

Signed-off-by: Rob Gulewich <rgulewich@netflix.com>
2019-05-07 10:22:16 -07:00
Sebastiaan van Stijn
79b5b19439
Merge pull request #39103 from lsilvs/master
Add Satoshi Nakamoto to names generator
2019-04-24 08:29:39 +02:00
Lucas Silvestre
4bfd23b7ee
Add Satoshi Nakamoto to names generator
Signed-off-by: Lucas Silvestre <lukas.silvestre@gmail.com>
2019-04-23 10:32:53 +02:00
John Howard
e0b528fe08 LCOW: (Experimental) Require RS5+ builds
Signed-off-by: John Howard <jhoward@microsoft.com>
2019-04-18 09:43:37 -07:00
Yong Tang
bfe6a05d5c
Merge pull request #39052 from thaJeztah/more_import_comments
Add more import comments
2019-04-11 09:29:43 -07:00
Sebastiaan van Stijn
191c0fec8c
Add Katie Bouman to names generator
Katherine Louise Bouman is an imaging scientist and Assistant Professor
of Computer Science at the California Institute of Technology. She
researches computational methods for imaging, and developed an algorithm
that made possible the picture first visualization of a black hole
using the Event Horizon Telescope. - https://en.wikipedia.org/wiki/Katie_Bouman

Thank you for being amazing!

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-11 12:43:30 +02:00
Sebastiaan van Stijn
c725eff3e2
Add more import comments
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-10 16:59:33 +02:00
Kir Kolyshkin
ec248fe61d pkg/mount/Make*: optimize
The only option we supply is either BIND or a mount propagation flag,
so it makes sense to specify the flag value directly, rather than using
parseOptions() every time.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-04-09 13:00:11 -07:00
Kir Kolyshkin
80fce834ad pkg/mount: Mount: minor optimization
Eliminate double call to parseOptions() from Mount()

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-04-09 12:58:07 -07:00
Kir Kolyshkin
aa60541877 pkg/mount: MakeMount: minor optimization
Current code in MakeMount parses /proc/self/mountinfo twice:
first in call to Mounted(), then in call to Mount(). Use
ForceMount() to eliminate such double parsing.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-04-09 12:57:59 -07:00
Sebastiaan van Stijn
58d862574c
fix parseInfoFile does not handle spaces in filenames
`/proc/self/mountinfo` uses `\040` for spaces, however, `parseInfoFile()`
did not decode those spaces in paths, therefore attempting to use `\040`
as a literal part of the path.

This patch un-quotes the `root` and `mount point` fields to fix
situations where paths contain spaces.

Note that the `mount source` field is not modified, given that
this field is documented (man `PROC(5)`) as:

    filesystem-specific information or "none"

Which I interpreted as "the format in this field is undefined".

Reported-by: Daniil Yaroslavtsev <daniilyar@users.noreply.github.com>
Reported-by: Nathan Ringo <remexre@gmail.com>
Based-on-patch-by: Diego Becciolini <itizir@users.noreply.github.com>
Based-on-patch-by: Sergei Utinski <sergei-utinski@users.noreply.github.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-02 13:09:26 +02:00
Tibor Vass
739adb46e4 daemon: fix bug in nvidia device registration
Signed-off-by: Tibor Vass <tibor@docker.com>
2019-03-29 16:07:01 -07:00
Sebastiaan van Stijn
e4cc3adf81
Merge pull request #38922 from Microsoft/jjh/grantvmgroupaccess
LCOW: Add VMGroup SID to layer.vhd; fix layer folder perm
2019-03-23 12:02:19 +01:00
Dmitry Sharshakov
88ce14ca1a Add new adjectives to the names generator (#38624)
* Add new adjectives to the names generator

Signed-off-by: sh7dm <d3dx12.xx@gmail.com>

* Add some more adjectives to the names generator

Signed-off-by: sh7dm <d3dx12.xx@gmail.com>
2019-03-21 13:48:59 -07:00
John Howard
b4db78be5a LCOW: Add SIDs to layer.vhd at creation
Signed-off-by: John Howard <jhoward@microsoft.com>

Some permissions corrections here. Also needs re-vendor of go-winio.

 - Create the layer folder directory as standard, not with SDDL. It will inherit permissions from the data-root correctly.
 - Apply the VM Group SID access to layer.vhd

Permissions after this changes

Data root:

```
PS C:\> icacls test
test BUILTIN\Administrators:(OI)(CI)(F)
     NT AUTHORITY\SYSTEM:(OI)(CI)(F)
```

lcow subdirectory under dataroot
```
PS C:\> icacls test\lcow
test\lcow BUILTIN\Administrators:(I)(OI)(CI)(F)
          NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
```

layer.vhd in a layer folder for LCOW
```
.\test\lcow\c33923d21c9621fea2f990a8778f469ecdbdc57fd9ca682565d1fa86fadd5d95\layer.vhd NT VIRTUAL MACHINE\Virtual Machines:(R)
                                                                                       BUILTIN\Administrators:(I)(F)
                                                                                       NT AUTHORITY\SYSTEM:(I)(F)
```

And showing working

```
PS C:\> docker-ci-zap -folder=c:\test
INFO: Zapped successfully
PS C:\> docker run --rm alpine echo hello
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
8e402f1a9c57: Pull complete
Digest: sha256:644fcb1a676b5165371437feaa922943aaf7afcfa8bfee4472f6860aad1ef2a0
Status: Downloaded newer image for alpine:latest
hello
```
2019-03-21 13:12:17 -07:00
John Howard
a3eda72f71
Merge pull request #38541 from Microsoft/jjh/containerd
Windows: Experimental: ContainerD runtime
2019-03-19 21:09:19 -07:00
Tibor Vass
8f936ae8cf Add DeviceRequests to HostConfig to support NVIDIA GPUs
This patch hard-codes support for NVIDIA GPUs.
In a future patch it should move out into its own Device Plugin.

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-03-18 17:19:45 +00:00
John Howard
20833b06a0 Windows: (WCOW) Generate OCI spec that remote runtime can escape
Signed-off-by: John Howard <jhoward@microsoft.com>

Also fixes https://github.com/moby/moby/issues/22874

This commit is a pre-requisite to moving moby/moby on Windows to using
Containerd for its runtime.

The reason for this is that the interface between moby and containerd
for the runtime is an OCI spec which must be unambigious.

It is the responsibility of the runtime (runhcs in the case of
containerd on Windows) to ensure that arguments are escaped prior
to calling into HCS and onwards to the Win32 CreateProcess call.

Previously, the builder was always escaping arguments which has
led to several bugs in moby. Because the local runtime in
libcontainerd had context of whether or not arguments were escaped,
it was possible to hack around in daemon/oci_windows.go with
knowledge of the context of the call (from builder or not).

With a remote runtime, this is not possible as there's rightly
no context of the caller passed across in the OCI spec. Put another
way, as I put above, the OCI spec must be unambigious.

The other previous limitation (which leads to various subtle bugs)
is that moby is coded entirely from a Linux-centric point of view.

Unfortunately, Windows != Linux. Windows CreateProcess uses a
command line, not an array of arguments. And it has very specific
rules about how to escape a command line. Some interesting reading
links about this are:

https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
https://stackoverflow.com/questions/31838469/how-do-i-convert-argv-to-lpcommandline-parameter-of-createprocess
https://docs.microsoft.com/en-us/cpp/cpp/parsing-cpp-command-line-arguments?view=vs-2017

For this reason, the OCI spec has recently been updated to cater
for more natural syntax by including a CommandLine option in
Process.

What does this commit do?

Primary objective is to ensure that the built OCI spec is unambigious.

It changes the builder so that `ArgsEscaped` as commited in a
layer is only controlled by the use of CMD or ENTRYPOINT.

Subsequently, when calling in to create a container from the builder,
if follows a different path to both `docker run` and `docker create`
using the added `ContainerCreateIgnoreImagesArgsEscaped`. This allows
a RUN from the builder to control how to escape in the OCI spec.

It changes the builder so that when shell form is used for RUN,
CMD or ENTRYPOINT, it builds (for WCOW) a more natural command line
using the original as put by the user in the dockerfile, not
the parsed version as a set of args which loses fidelity.
This command line is put into args[0] and `ArgsEscaped` is set
to true for CMD or ENTRYPOINT. A RUN statement does not commit
`ArgsEscaped` to the commited layer regardless or whether shell
or exec form were used.
2019-03-12 18:41:55 -07:00
John Howard
85ad4b16c1 Windows: Experimental: Allow containerd for runtime
Signed-off-by: John Howard <jhoward@microsoft.com>

This is the first step in refactoring moby (dockerd) to use containerd on Windows.
Similar to the current model in Linux, this adds the option to enable it for runtime.
It does not switch the graphdriver to containerd snapshotters.

 - Refactors libcontainerd to a series of subpackages so that either a
  "local" containerd (1) or a "remote" (2) containerd can be loaded as opposed
  to conditional compile as "local" for Windows and "remote" for Linux.

 - Updates libcontainerd such that Windows has an option to allow the use of a
   "remote" containerd. Here, it communicates over a named pipe using GRPC.
   This is currently guarded behind the experimental flag, an environment variable,
   and the providing of a pipename to connect to containerd.

 - Infrastructure pieces such as under pkg/system to have helper functions for
   determining whether containerd is being used.

(1) "local" containerd is what the daemon on Windows has used since inception.
It's not really containerd at all - it's simply local invocation of HCS APIs
directly in-process from the daemon through the Microsoft/hcsshim library.

(2) "remote" containerd is what docker on Linux uses for it's runtime. It means
that there is a separate containerd service running, and docker communicates over
GRPC to it.

To try this out, you will need to start with something like the following:

Window 1:
	containerd --log-level debug

Window 2:
	$env:DOCKER_WINDOWS_CONTAINERD=1
	dockerd --experimental -D --containerd \\.\pipe\containerd-containerd

You will need the following binary from github.com/containerd/containerd in your path:
 - containerd.exe

You will need the following binaries from github.com/Microsoft/hcsshim in your path:
 - runhcs.exe
 - containerd-shim-runhcs-v1.exe

For LCOW, it will require and initrd.img and kernel in `C:\Program Files\Linux Containers`.
This is no different to the current requirements. However, you may need updated binaries,
particularly initrd.img built from Microsoft/opengcs as (at the time of writing), Linuxkit
binaries are somewhat out of date.

Note that containerd and hcsshim for HCS v2 APIs do not yet support all the required
functionality needed for docker. This will come in time - this is a baby (although large)
step to migrating Docker on Windows to containerd.

Note that the HCS v2 APIs are only called on RS5+ builds. RS1..RS4 will still use
HCS v1 APIs as the v2 APIs were not fully developed enough on these builds to be usable.
This abstraction is done in HCSShim. (Referring specifically to runtime)

Note the LCOW graphdriver still uses HCS v1 APIs regardless.

Note also that this does not migrate docker to use containerd snapshotters
rather than graphdrivers. This needs to be done in conjunction with Linux also
doing the same switch.
2019-03-12 18:41:55 -07:00
Yong Tang
6e86b1198f
Merge pull request #38780 from thaJeztah/remove_parse_tmpfs_options
pkg/mount: remove unused ParseTmpfsOptions
2019-03-04 10:01:41 -08:00
Sebastiaan van Stijn
144c95029c
pkg/mount: remove unused ParseTmpfsOptions
This function was previously used on the client to validate
tmpfs options, but is no longer used since
b9b8d8b364, as this validation
is platform-specific, so should be handled by the daemon.

Removing this function as it's no longer used anywhere.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-02-22 12:55:33 +01:00
Sebastiaan van Stijn
53460047e4
Refactor pkg/sysinfo
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-02-04 00:38:12 +01:00
Akihiro Suda
ec87479b7e allow running dockerd in an unprivileged user namespace (rootless mode)
Please refer to `docs/rootless.md`.

TLDR:
 * Make sure `/etc/subuid` and `/etc/subgid` contain the entry for you
 * `dockerd-rootless.sh --experimental`
 * `docker -H unix://$XDG_RUNTIME_DIR/docker.sock run ...`

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2019-02-04 00:24:27 +09:00
Sebastiaan van Stijn
44af96c0fc
Merge pull request #38634 from kolyshkin/cp-longname
pkg/archive:CopyTo(): fix for long dest filename
2019-01-31 00:16:11 +01:00
Yong Tang
0cde75e2ea
Merge pull request #38398 from RaviTezu/replace_gotty_with_aec
replace gotty with aec, since gotty hasn't been updated since very lo…
2019-01-26 16:45:15 -08:00
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
Lorenzo Fontana
0ecba1523d
Merge pull request #38422 from debayande/even-more-names-redux
Makes a few modifications to the name generator.
2019-01-23 02:09:52 +01:00
Sebastiaan van Stijn
3449b12cc7
Use assert.NilError() instead of assert.Assert()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-21 13:16:02 +01:00
Brian Goff
eaad3ee3cf Make sure timers are stopped after use.
`time.After` keeps a timer running until the specified duration is
completed. It also allocates a new timer on each call. This can wind up
leaving lots of uneccessary timers running in the background that are
not needed and consume resources.

Instead of `time.After`, use `time.NewTimer` so the timer can actually
be stopped.
In some of these cases it's not a big deal since the duraiton is really
short, but in others it is much worse.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2019-01-16 14:32:53 -08:00
RaviTeja Pothana
1990a3e409 replace gotty with aec, since gotty hasn't been updated since very long time and aec can drop in for gotty
Signed-off-by: RaviTeja Pothana <ravi-teja@live.com>
2019-01-16 22:10:39 +05:30
Sebastiaan van Stijn
8f158db4ed
pkg/signal.TestTrap: use a subtest
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-12 18:04:44 +01:00
Sebastiaan van Stijn
c855d411bf
testing: pkg/signal; remove redundant fmt.Sprintf()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-12 17:51:59 +01:00
Sebastiaan van Stijn
1e1156cf67
Skip kernel-memory tests on RHEL/CentOS daemons
RHEL/CentOS 3.10 kernels report that kernel-memory accounting is supported,
but it actually does not work.

Runc (when compiled for those kernels) will be compiled without kernel-memory
support, so even though the daemon may be reporting that it's supported,
it actually is not.

This cause tests to fail when testing against a daemon that's using a runc
version without kmem support.

For now, skip these tests based on the kernel version reported by the daemon.

This should fix failures such as:

```
FAIL: /go/src/github.com/docker/docker/integration-cli/docker_cli_run_unix_test.go:499: DockerSuite.TestRunWithKernelMemory

assertion failed:
Command:  /usr/bin/docker run --kernel-memory 50M --name test1 busybox cat /sys/fs/cgroup/memory/memory.kmem.limit_in_bytes
ExitCode: 0
Error:    <nil>
Stdout:   9223372036854771712

Stderr:   WARNING: You specified a kernel memory limit on a kernel older than 4.0. Kernel memory limits are experimental on older kernels, it won't work as expected and can cause your system to be unstable.

Failures:
Expected stdout to contain "52428800"

FAIL: /go/src/github.com/docker/docker/integration-cli/docker_cli_update_unix_test.go:125: DockerSuite.TestUpdateKernelMemory

/go/src/github.com/docker/docker/integration-cli/docker_cli_update_unix_test.go:136:
    ...open /go/src/github.com/docker/docker/integration-cli/docker_cli_update_unix_test.go: no such file or directory
... obtained string = "9223372036854771712"
... expected string = "104857600"

----------------------------------------------------------------------
FAIL: /go/src/github.com/docker/docker/integration-cli/docker_cli_update_unix_test.go:139: DockerSuite.TestUpdateKernelMemoryUninitialized

/go/src/github.com/docker/docker/integration-cli/docker_cli_update_unix_test.go:149:
    ...open /go/src/github.com/docker/docker/integration-cli/docker_cli_update_unix_test.go: no such file or directory
... value = nil
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-04 13:27:46 +01:00
Vincent Demeester
de640c9f49
Merge pull request #38038 from AkihiroSuda/ubuntu-overlayfs
pkg/archive: support overlayfs in userns (Ubuntu kernel only)
2019-01-04 09:50:15 +01:00
Debayan De
e50f791d42 Makes a few modifications to the name generator.
* Replaces `cocks` with `cerf` as the former might be perceived as
offensive by some people (as pointed out by @jeking3
[here](https://github.com/moby/moby/pull/37157#commitcomment-31758059))
* Removes a duplicate entry for `burnell`
* Re-arranges the entry for `sutherland` to ensure that the names are in
sorted order
* Adds entries for `shamir` and `wilbur`

Signed-off-by: Debayan De <debayande@users.noreply.github.com>
2018-12-23 10:22:28 +00:00
Sebastiaan van Stijn
9c83124302
Fix some go_vet issues
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-12-19 23:57:06 +01:00
Fabian Kramm
eea4977d02 Fix unmount redeclaration on darwin in github.com/docker/docker/pkg/mount
Signed-off-by: Fabian Kramm <kramm@covexo.com>
2018-12-14 11:10:52 +01:00
Kir Kolyshkin
6533136961 pkg/mount: wrap mount/umount errors
The errors returned from Mount and Unmount functions are raw
syscall.Errno errors (like EPERM or EINVAL), which provides
no context about what has happened and why.

Similar to os.PathError type, introduce mount.Error type
with some context. The error messages will now look like this:

> mount /tmp/mount-tests/source:/tmp/mount-tests/target, flags: 0x1001: operation not permitted

or

> mount tmpfs:/tmp/mount-test-source-516297835: operation not permitted

Before this patch, it was just

> operation not permitted

[v2: add Cause()]
[v3: rename MountError to Error, document Cause()]
[v4: fixes; audited all users]
[v5: make Error type private; changes after @cpuguy83 reviews]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-12-10 20:07:02 -08:00
Kir Kolyshkin
90be078fe5 pkg/mount: refactor Unmount()
It has been pointed out that we're ignoring EINVAL from umount(2)
everywhere, so let's move it to a lower-level function. Also, its
implementation should be the same for any UNIX incarnation, so
let's consolidate it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-12-10 20:06:10 -08:00
Kir Kolyshkin
8072e62d83 pkg/system/stat_unix: wrap errors in PathError
syscall.Stat (and Lstat), unlike functions from os pkg,
return "raw" errors (like EPERM or EINVAL), and those are
propagated up the function call stack unchanged, and gets
logged and/or returned to the user as is.

Wrap those into os.PathError{} so the error message will
at least have function name and file name.

Note we use Capitalized function names to distinguish
between functions in os and ours.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-12-10 20:06:10 -08:00
Akihiro Suda
ec153ccfc8 pkg/archive: add TestReexecUserNSOverlayWhiteoutConverter
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-12-11 07:18:37 +09:00
Akihiro Suda
037e370de1 pkg/archive: annotate tests that requires initial userns
`rootlesskit go test ./pkg/archive` now succeeds

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-12-11 07:18:37 +09:00
Akihiro Suda
f8ed19c8b4 pkg/archive: support overlayfs in userns (Ubuntu kernel only)
Ubuntu kernel supports overlayfs in user namespaces.

However, Docker had previously crafting overlay opaques directly
using mknod(2) and setxattr(2), which are not supported in userns.

Tested with LXD, Ubuntu 18.04, kernel 4.15.0-36-generic #39-Ubuntu.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-12-11 07:18:37 +09:00
Tibor Vass
6e3113f700
Merge pull request #38327 from andrewhsu/ctrd
update containerd to v1.2.1
2018-12-10 17:28:50 +01:00
Andrew Hsu
78045a5419
use empty string as cgroup path to grab first find
Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-12-07 18:44:00 +01:00
Akihiro Suda
9ddd6e47a9 pkg/archive: fix TestTarUntarWithXattr failure on recent kernel
Recent kernel has strict check for security.capability value.
Fix #38289

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-11-29 16:14:35 +09:00
Yong Tang
f023816608 Add memory.kernelTCP support for linux
This fix tries to address the issue raised in 37038 where
there were no memory.kernelTCP support for linux.

This fix add MemoryKernelTCP to HostConfig, and pass
the config to runtime-spec.

Additional test case has been added.

This fix fixes 37038.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-11-26 21:03:08 +00:00
Yong Tang
ea3ac621e3
Merge pull request #37982 from Microsoft/jjh/archive
pkg/archive fixes, and port most unit tests to Windows
2018-11-27 05:49:39 +09:00
John Howard
56b732058e pkg/archive fixes, and port most unit tests to Windows
Signed-off-by: John Howard <jhoward@microsoft.com>

If fixes an error in sameFsTime which was using `==` to compare two times. The correct way is to use go's built-in timea.Equals(timeb).

In changes_windows, it uses sameFsTime to compare mTim of a `system.StatT` to allow TestChangesDirsMutated to operate correctly now.

Note there is slight different between the Linux and Windows implementations of detecting changes. Due to https://github.com/moby/moby/issues/9874,
and the fix at https://github.com/moby/moby/pull/11422, Linux does not consider a change to the directory time as a change. Windows on NTFS
does. See https://github.com/moby/moby/pull/37982 for more information. The result in `TestChangesDirsMutated`, `dir3` is NOT considered a change
in Linux, but IS considered a change on Windows. The test mutates dir3 to have a mtime of +1 second.

With a handful of tests still outstanding, this change ports most of the unit tests under pkg/archive to Windows.

It provides an implementation of `copyDir` in tests for Windows. To make a copy similar to Linux's `cp -a` while preserving timestamps
and links to both valid and invalid targets, xcopy isn't sufficient. So I used robocopy, but had to circumvent certain exit codes that
robocopy exits with which are warnings. Link to article describing this is in the code.
2018-11-26 10:20:40 -08:00
Kir Kolyshkin
8abadb36fa pkg/mount: add MakeMount()
This function ensures the argument is the mount point
(i.e. if it's not, it bind mounts it to itself).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-10-11 23:30:52 -07:00
Kir Kolyshkin
f01297d1ae pkg/mount: simplify ensureMountedAs
1. There is no need to specify rw argument -- bind mounts are
   read-write by default.

2. There is no point in parsing /proc/self/mountinfo after performing
   a mount, especially if we don't check whether the fs is mounted or
   not -- the only outcome from it could be an error from our mountinfo
   parser, which makes no sense in this context.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-10-11 23:16:10 -07:00
Yong Tang
ffaa0b7b3f
Merge pull request #37936 from benny-gold/master
Added two new scientists to the namesgenerator
2018-10-08 23:40:51 +00:00
Yong Tang
2cc338c100
Merge pull request #37967 from thaJeztah/upstream_dos_fix
Fix denial of service with large numbers in cpuset-cpus and cpuset-mems
2018-10-08 13:23:03 +00:00
Vincent Demeester
a3f54d4570
Merge pull request #37977 from mooncak/remove_duplicated_word
Remove duplicated words in pkg files
2018-10-08 11:40:10 +02:00
Vincent Demeester
5f6aca784f
Merge pull request #37491 from poizan42/fix-mips-signals
SIGSKTFLT does not exist on MIPS, instead SIGEMT does. SIGRTMAX is also 127 on MIPS
2018-10-08 09:28:20 +02:00
mooncake
35739fd290 Remove duplicated words in pkg files
Signed-off-by: mooncake <xcoder@tenxcloud.com>
2018-10-05 22:32:14 +08:00
Justin Cormack
f8e876d761
Fix denial of service with large numbers in cpuset-cpus and cpuset-mems
Using a value such as `--cpuset-mems=1-9223372036854775807` would cause
`dockerd` to run out of memory allocating a map of the values in the
validation code. Set limits to the normal limit of the number of CPUs,
and improve the error handling.

Reported by Huawei PSIRT.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-10-05 15:09:02 +02:00
David P Hilton
272759f268 make xattr EPERM non-fatal in createTarFile
Signed-off-by: David P Hilton <david.hilton.p@gmail.com>
2018-10-04 00:00:23 -06:00
Ben Gould
733d777bc0 added an adjective to kick off another build!
Signed-off-by: Ben Gould <ben@bengould.co.uk>
2018-09-30 21:00:09 +01:00
Ben Gould
13c36d00fd Added two new scientists to the namesgenerator
Signed-off-by: Ben Gould <ben@bengould.co.uk>
2018-09-29 20:26:24 +01:00
Lifubang
00eb3480dc fixes display text in Multiple IDs found with provided prefix
Signed-off-by: Lifubang <lifubang@acmcoder.com>
2018-09-24 12:17:31 +08:00
Tibor Vass
11841b70d0
Merge pull request #37780 from tiborvass/fix-progress-panic
pkg/progress: work around closing closed channel panic
2018-09-13 14:45:15 -07:00