Commit Graph

36118 Commits

Author SHA1 Message Date
84d802ab7f journald/read: simplify walking backwards
In case Tail=N parameter is requested, we need to show N lines.
It does not make sense to walk backwards one by one if we can
do it at once. Now, if Since=T is also provided, make sure we
haven't jumped too far (before T), and if we did, move forward.

The primary motivation for this was to make the code simpler.

This also fixes a tiny bug in the "since" implementation.

Before this commit:
> $ docker logs -t --tail=6000 --since="2019-03-10T03:54:25.00" $ID | head
> 2019-03-10T03:54:24.999821000Z 95981

After:
> $ docker logs -t --tail=6000 --since="2019-03-10T03:54:25.00" $ID | head
> 2019-03-10T03:54:25.000013000Z 95982

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit ff3cd167ea4d089b7695a263ba2fc4caa0a0750c)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 2a124db7da440f1efd4c2957320d8b25d9d9ce36
Component: engine
2019-08-09 16:41:49 -07:00
6cf4b69ae9 journald/read: simplify code
Minor code simplification.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit e8f6166791c097deb15c39f8dddf6f97be65b224)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 1d336dc53bd7bf5941596ffeb253d102de609a51
Component: engine
2019-08-09 16:41:49 -07:00
baee58e4ef Small journal cleanup
Clean up a deferred function call in the journal reading logic.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
(cherry picked from commit 1ada3e85bf89201910c28f2ff6892c00cee0f137)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: e700930ca521d0c004b6a3ed8bdd35a2d538aa15
Component: engine
2019-08-09 16:41:49 -07:00
ea64a5cc52 daemon/logger/journald: simplify readers field
As in other similar drivers (jsonlog, local), use a set
(i.e. `map[whatever]struct{}`), making the code simpler.

While at it, make sure we remove the reader from the set
after calling `ProducerGone()` on it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit b2b169f13f681cd0d591ccb06d6cfff97933db77)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: fe85c72a2eac4cbf249d2c4c754684bb447eefdd
Component: engine
2019-08-09 16:41:45 -07:00
66137d693e Merge pull request #292 from thaJeztah/18.09_backport_fix_more_grpc_sizes
[18.09 backport] Fix more grpc list message sizes
Upstream-commit: ba48878e960ff906e51353d094a5a0eb12517740
Component: engine
2019-08-08 22:53:18 -07:00
60537190f7 Merge pull request #307 from thaJeztah/18.09_bump_swarmkit
[18.09] bump swarmkit to 142a73731c850daf24d32001aa2358b6ffe36eab (bump_v18.09)
Upstream-commit: af1b34f4fcc2f409207b04459aed4403c6408293
Component: engine
2019-08-08 22:53:05 -07:00
e884c7277d Merge pull request #295 from thaJeztah/18.09_backport_chroot_unsupported
[18.09 backport] Add realChroot for non linux/windows
Upstream-commit: 09431f90c89781b1a8051b1cbad563a821f470cc
Component: engine
2019-08-08 13:02:33 -07:00
2cf3e1d4d8 Add realChroot for non linux/windows
3029e765e241ea2b5249868705dbf9095bc4d529 broke compilation on
non-Linux/Windows systems.
This change fixes that.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 34d5b8867fe83403a6998d043a32a49e087f2477)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: d0808b92aec7ff1b0e790625e2e6518eb8c014a0
Component: engine
2019-08-08 18:16:28 +02:00
66b09eef75 Fix more grpc list message sizes
There are a few more places, apparently, that List operations against
Swarm exist, besides just in the List methods. This increases the max
received message size in those places.

Signed-off-by: Drew Erny <drew.erny@docker.com>
(cherry picked from commit a84a78e9767d82abd4744dad9ce4fb3f64141a8f)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 41da428d065ab15fd2d8aba1fbd0d0056136a43b
Component: engine
2019-08-08 04:14:12 +02:00
18c65b780b bump swarmkit to 142a73731c850daf24d32001aa2358b6ffe36eab (bump_v18.09)
full diff: 19e791fd6d...142a73731c

included:

- docker/swarmkit#2872 [19.03 backport] Only update non-terminal tasks on node removal
  - backport of docker/swarmkit#2867 Only update non-terminal tasks on node removal

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 7fcfdbaab6d8c6a2d55ad7b72a851c5e92b360ac
Component: engine
2019-08-08 03:10:03 +02:00
33b4c4329e Merge pull request #308 from thaJeztah/18.09_backport_prevent_network_attach_panic
[18.09 backport] Prevent panic on network attach
Upstream-commit: f9bf841ff59e163e19182468b80d6d84736afdc2
Component: engine
2019-08-08 01:22:53 +02:00
b3a954110b Merge pull request #302 from kolyshkin/18.09-go-1.11.12
[18.09] Bump Go to  1.11.12
Upstream-commit: 3618280391a523ec762492a0c8cb58e6eae8867f
Component: engine
2019-08-07 14:12:56 -07:00
4b562b93fe Prevent panic on network attach
In situations where `container.NetworkSettings` was not nil, but
`container.NetworkSettings.Networks` was, a panic could occur:

```
2019-06-10 15:26:50.548309 I | http: panic serving @: assignment to entry in nil map
goroutine 1376 [running]:
net/http.(*conn).serve.func1(0xc4211068c0)
	/usr/local/go/src/net/http/server.go:1726 +0xd2
panic(0x558939d7e1e0, 0x55893a0c4410)
	/usr/local/go/src/runtime/panic.go:502 +0x22d
github.com/docker/docker/daemon.(*Daemon).updateNetworkSettings(0xc42090c5a0, 0xc420fb6fc0, 0x55893a101140, 0xc4210e0540, 0xc42112aa80, 0xc4217d77a0, 0x0)
	/go/src/github.com/docker/docker/daemon/container_operations.go:275 +0x40e
github.com/docker/docker/daemon.(*Daemon).updateNetworkConfig(0xc42090c5a0, 0xc420fb6fc0, 0x55893a101140, 0xc4210e0540, 0xc42112aa80, 0x55893a101101, 0xc4210e0540, 0x0)
	/go/src/github.com/docker/docker/daemon/container_operations.go:683 +0x219
github.com/docker/docker/daemon.(*Daemon).connectToNetwork(0xc42090c5a0, 0xc420fb6fc0, 0xc420e8290f, 0x40, 0xc42112aa80, 0x558937eabd01, 0x0, 0x0)
	/go/src/github.com/docker/docker/daemon/container_operations.go:728 +0x1cb
github.com/docker/docker/daemon.(*Daemon).ConnectToNetwork(0xc42090c5a0, 0xc420fb6fc0, 0xc420e8290f, 0x40, 0xc42112aa80, 0x0, 0x0)
	/go/src/github.com/docker/docker/daemon/container_operations.go:1046 +0x2b3
github.com/docker/docker/daemon.(*Daemon).ConnectContainerToNetwork(0xc42090c5a0, 0xc4214ca580, 0x40, 0xc420e8290f, 0x40, 0xc42112aa80, 0x2, 0xe600000000000001)
	/go/src/github.com/docker/docker/daemon/network.go:450 +0xa1
github.com/docker/docker/api/server/router/network.(*networkRouter).postNetworkConnect(0xc42121bbc0, 0x55893a0edee0, 0xc420de7cb0, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x5589394707cc, 0x5)
	/go/src/github.com/docker/docker/api/server/router/network/network_routes.go:278 +0x330
github.com/docker/docker/api/server/router/network.(*networkRouter).(github.com/docker/docker/api/server/router/network.postNetworkConnect)-fm(0x55893a0edee0, 0xc420de7cb0, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x558937fd89dc, 0x558939f2cec0)
	/go/src/github.com/docker/docker/api/server/router/network/network.go:37 +0x6b
github.com/docker/docker/api/server/middleware.ExperimentalMiddleware.WrapHandler.func1(0x55893a0edee0, 0xc420de7cb0, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x55893a0edee0, 0xc420de7cb0)
	/go/src/github.com/docker/docker/api/server/middleware/experimental.go:26 +0xda
github.com/docker/docker/api/server/middleware.VersionMiddleware.WrapHandler.func1(0x55893a0edee0, 0xc420de7a70, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x0, 0x0)
	/go/src/github.com/docker/docker/api/server/middleware/version.go:62 +0x401
github.com/docker/docker/pkg/authorization.(*Middleware).WrapHandler.func1(0x55893a0edee0, 0xc420de7a70, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x0, 0x558939640868)
	/go/src/github.com/docker/docker/pkg/authorization/middleware.go:59 +0x7ab
github.com/docker/docker/api/server/middleware.DebugRequestMiddleware.func1(0x55893a0edee0, 0xc420de7a70, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x55893a0edee0, 0xc420de7a70)
	/go/src/github.com/docker/docker/api/server/middleware/debug.go:53 +0x4b8
github.com/docker/docker/api/server.(*Server).makeHTTPHandler.func1(0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600)
	/go/src/github.com/docker/docker/api/server/server.go:141 +0x19a
net/http.HandlerFunc.ServeHTTP(0xc420e0c0e0, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600)
	/usr/local/go/src/net/http/server.go:1947 +0x46
github.com/docker/docker/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc420ce5950, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600)
	/go/src/github.com/docker/docker/vendor/github.com/gorilla/mux/mux.go:103 +0x228
github.com/docker/docker/api/server.(*routerSwapper).ServeHTTP(0xc421078330, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600)
	/go/src/github.com/docker/docker/api/server/router_swapper.go:29 +0x72
net/http.serverHandler.ServeHTTP(0xc420902f70, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600)
	/usr/local/go/src/net/http/server.go:2697 +0xbe
net/http.(*conn).serve(0xc4211068c0, 0x55893a0ede20, 0xc420d81440)
	/usr/local/go/src/net/http/server.go:1830 +0x653
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2798 +0x27d
```

I have not been able to reproduce the situation, but preventing a panic should
not hurt.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 651e694508563e6fb3e8f5d7037641cc136b2c44)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 2af0647e9735873e096241e361836c49b963667e
Component: engine
2019-08-07 20:45:19 +02:00
148e98951f Merge pull request #311 from kolyshkin/18.09-quota-map
[18.09 backport] projectquota: protect concurrent map access (ENGCORE-920)
Upstream-commit: ebb8bfca60f19348401b9be8510d5c3d89aeaf02
Component: engine
2019-08-07 20:43:13 +02:00
91c3416349 Pin Dockerfile to -stretch variant
The Golang base images switch to buster, which causes some breakage
in networking and packages that are no  longer available; (`btrfs-tools`
is now an empty package, and `libprotobuf-c0-dev` is gone).

Some of out tests also start faiilng on stretch, and will have to be
investigated further;

```
15:13:06 --- FAIL: TestRenameAnonymousContainer (3.37s)
15:13:06     rename_test.go:168: assertion failed: 0 (int) != 1 (inspect.State.ExitCode int): container a7fe866d588d65f353f42ffc5ea5288e52700384e1d90850e9c3d4dce8657666 exited with the wrong exitcode:

15:13:38 --- FAIL: TestHostnameDnsResolution (2.23s)
15:13:38     run_linux_test.go:128: assertion failed:
15:13:38         --- ←
15:13:38         +++ →
15:13:38         @@ -1 +1,2 @@
15:13:38         +ping: bad address 'foobar'
15:13:38
15:13:38
15:13:38     run_linux_test.go:129: assertion failed: 0 (int) != 1 (res.ExitCode int)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
 (cherry picked from commit ed672bb523cb255d0b2b79837d9c45a7c3255000)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 3c1bc29b2c372d0f1e37dc8aac33cdc01b623aa0
Component: engine
2019-08-06 23:03:49 -07:00
2c36982642 Windows: fix Golang version checks for GO_VERSION build-arg
This check was used to make sure we don't bump Go versions independently
(Linux/Windows). The Dockerfile switched to using a build-arg to allow
overriding the Go version, which rendered this check non-functional.

It also fails if Linux versions use a specific variant of the image;

08:41:31 ERROR: Failed 'ERROR: Mismatched GO versions between Dockerfile and Dockerfile.windows. Update your PR to ensure that both files are updated and in sync. ${GO_VERSION}-stretch ${GO_VERSION}' at 07/20/2019 08:41:31
08:41:31 At C:\gopath\src\github.com\docker\docker\hack\ci\windows.ps1:448 char:9
08:41:31 +         Throw "ERROR: Mismatched GO versions between Dockerfile and D ...
08:41:31 +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This patch fixes the check by looking for the value of `GO_VERSION` instead
of looking at the `FROM` line (which is harder to parse).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 4fa57a8191b1d23c6466725b688519f83c0ac5dd)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: a2d32c5654a206954fd0d9a5fd08abd8c03d4523
Component: engine
2019-08-06 23:03:49 -07:00
c0f1e37bd9 Dockerfile.windows: trim .0 from Go versions
This was an oversight when changing the Dockerfile to use a build-arg;
the Windows Dockerfile downloads the Go binaries, which never have a
trailing `.0`.

This patch makes sure that the trailing zero (if any) is removed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit c5bd6e3dc7680d6c683496f63dafb1f30f87eaa7)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 8f1a27c51f93698b5fe17f0fb043f47794e11cca
Component: engine
2019-08-06 23:03:49 -07:00
05c0875eab Dockerfile: use GO_VERSION build-arg for overriding Go version
This allows overriding the version of Go without making modifications in the
source code, which can be useful to test against multiple versions.

For example:

    make GO_VERSION=1.13beta1 shell

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit c6281bc4383b7f9eab617fd73601e8594c93365b)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>

Conflicts:
 * Dockerfile, Dockerfile.e2e, Dockerfile.simple, Dockerfile.windows:
   (due to Go version difference, missing CROSS etc.)
Upstream-commit: d9ba337adb0c3880acd34ffe9b0a15717990876b
Component: engine
2019-08-06 23:03:22 -07:00
018dd5e3eb projectquota: protect concurrent map access
Protect access to q.quotas map, and lock around changing nextProjectID.

Techinically, the lock in findNextProjectID() is not needed as it is
only called during initialization, but one can never be too careful.

Fixes: 52897d1c092 ("projectquota: utility class for project quota controls")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 1ac0a66a64a906911d0708cd0e5fa397a2f0b595)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 7027bb9bedae63879c1e41894739ba0ea2deedc1
Component: engine
2019-08-06 12:04:23 -07:00
542fc26354 stats: avoid cgo in collector
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit cf104d85c35947c25dcd86cef19aa97fe31e4bbd)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: a83a1dcbeaa1aef3f99c71a0b2d88552d45ac444
Component: engine
2019-08-01 15:09:40 -07:00
920f2a46aa copy: allow non-cgo build
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 230a55d337f67a2850fd3206500c5c2a89f9e2e7)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 1da22d7201f5fdedf3c6732163819d56a7571414
Component: engine
2019-08-01 15:09:40 -07:00
36678eaf72 quota: add noncgo build tag
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 186cd7cf4a4d3a02ca7e7a18d6d923245f3187b0)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 0dd47afda5c3d7e83f6b7b8766634e8bcacb041a
Component: engine
2019-08-01 15:09:40 -07:00
f8da0365c2 Merge pull request #305 from tonistiigi/cve-2019-14271-1809
[18.09] Initialize nss libraries in Glibc so that the dynamic libraries are l…
Upstream-commit: 8ff992ae26ecedb7b80ee71be902d0fbc0879861
Component: engine
2019-07-26 19:54:17 -07:00
fbde297068 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>
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit a316b10dab79d9298b02c7930958ed52e0ccf4e4)
Upstream-commit: 706204124878a97142be511c0c46bcc16b43b0bd
Component: engine
2019-07-26 13:34:35 -07:00
20fccac6f6 Dockerfile: Use APT_MIRROR for security.debian.org as well
The fastly cdn mirror we're using also mirrors the debian security
repository;

```
Welcome to deb.debian.org (fastly instance)!

This is deb.debian.org. This service provides mirrors for the following Debian archive repositories:

/debian/
/debian-debug/
/debian-ports/
/debian-security/
The server deb.debian.org does not have packages itself, but the name has SRV records in DNS that let apt in stretch and later find places.
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit c8f43b5f6f7c83cfb5570f7f013c7efaa430d285)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>

Conflicts:
 * Dockerfile (GO_VERSION value differs, and CROSS (#39010) is absent)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 6e603e957eec3a46db4d8d69c3a7946c4d2e9c59
Component: engine
2019-07-26 12:40:28 -07:00
b74e2311ef Merge pull request #301 from thaJeztah/18.09_bump_libnetwork2
[18.09] bump libnetwork 55685ba49593e67f5e1c8180539379b16736c25e (18.09 branch)
Upstream-commit: e8c623b37e1bd82c9affd149427e892906549fd1
Component: engine
2019-07-25 12:53:04 -07:00
3cef44a1c0 Dockerfile.e2e: simplify apk calls
As of Alpine Linux 3.3 (or 3.2?) there exists a new --no-cache
option for apk. It allows users to install packages with an index
that is updated and used on-the-fly and not cached locally.

This avoids the need to use --update and remove /var/cache/apk/*
when done installing packages.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 3b44dd66a4b316049df86521c491b50466d9b55d)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: a4ae2af0e59018a309d4bc71ced729b34e906564
Component: engine
2019-07-25 09:22:10 -07:00
2c0e36c7d9 Bump Go to 1.11.12
go1.11.12 (released 2019/07/08) includes fixes to the compiler and the linker.
See the Go 1.11.12 milestone on our issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.11.12

Full diff: https://github.com/golang/go/compare/go1.11.11...go1.11.12

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: bad2df59f4b949549bc5591c17dee477e83adfad
Component: engine
2019-07-23 15:39:57 -07:00
379d3f1f44 Merge pull request #168 from thaJeztah/18.09_backport_bump_golang_1.11
[18.09 backport] Bump Golang to 1.11.11
Upstream-commit: 241a7fc265f97989fa8cd9054f40acc1f066dd4d
Component: engine
2019-07-23 15:22:23 -07:00
c9d036b71b bump libnetwork 55685ba49593e67f5e1c8180539379b16736c25e (18.09 branch)
full diff: e7933d41e7...55685ba495

changes included:

- docker/libnetwork#2382 Backporting PR 2069 to bump_18.09
  - backport of https://github.com/docker/libnetwork#2069 Rolling back the port configs if failed to programIngress()
- docker/libnetwork#2363 [18.09] align dependencies with engine 18.09
- docker/libnetwork#2400 [18.09 backport] Fix TestValidRemoteDriver GetCapabilities errors
- docker/libnetwork#2391 [18.09 backport] Correctly clean up --config-only networks
  - backport of docker/libnetwork#2373
  - fixes moby/moby#35101
- docker/libnetwork#2392 [18.09 backport] remove gosimple - package is gone and it's not important

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 0a3767c7e9803f0a595a07b0548e99d60e861062
Component: engine
2019-07-23 15:16:58 -07:00
67476cf36f Merge pull request #298 from thaJeztah/18.09_backport_scrub
[18.09 backport] DebugRequestMiddleware: unconditionally scrub data field
Upstream-commit: 456712c5b8d9d92c047f6a7d7cff270527ecac28
Component: engine
2019-07-17 09:09:51 -07:00
b48ef8cdca DebugRequestMiddleware: Remove path handling
Path-specific rules were removed, so this is no longer used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 530e63c1a61b105a6f7fc143c5acb9b5cd87f958)
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit f8a0f26843bc5aff33cf9201b75bd4bdbb48a3ad)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: a11c3098a3d5106b2d7c90d971c9300099556a49
Component: engine
2019-07-17 17:24:44 +02:00
3b1e458374 DebugRequestMiddleware: unconditionally scrub data field
Commit 77b8465d7e68ca102d7aae839c7b3fe0ecd28398 added a secret update
endpoint to allow updating labels on existing secrets. However, when
implementing the endpoint, the DebugRequestMiddleware was not updated
to scrub the Data field (as is being done when creating a secret).

When updating a secret (to set labels), the Data field should be either
`nil` (not set), or contain the same value as the existing secret. In
situations where the Data field is set, and the `dockerd` daemon is
running with debugging enabled / log-level debug, the base64-encoded
value of the secret is printed to the daemon logs.

The docker cli does not have a `docker secret update` command, but
when using `docker stack deploy`, the docker cli sends the secret
data both when _creating_ a stack, and when _updating_ a stack, thus
leaking the secret data if the daemon runs with debug enabled:

1. Start the daemon in debug-mode

        dockerd --debug

2. Initialize swarm

        docker swarm init

3. Create a file containing a secret

        echo secret > my_secret.txt

4. Create a docker-compose file using that secret

        cat > docker-compose.yml <<'EOF'
        version: "3.3"
        services:
          web:
            image: nginx:alpine
            secrets:
              - my_secret
        secrets:
          my_secret:
            file: ./my_secret.txt
        EOF

5. Deploy the stack

        docker stack deploy -c docker-compose.yml test

6. Verify that the secret is scrubbed in the daemon logs

        DEBU[2019-07-01T22:36:08.170617400Z] Calling POST /v1.30/secrets/create
        DEBU[2019-07-01T22:36:08.171364900Z] form data: {"Data":"*****","Labels":{"com.docker.stack.namespace":"test"},"Name":"test_my_secret"}

7. Re-deploy the stack to trigger an "update"

        docker stack deploy -c docker-compose.yml test

8. Notice that this time, the Data field is not scrubbed, and the base64-encoded secret is logged

        DEBU[2019-07-01T22:37:35.828819400Z] Calling POST /v1.30/secrets/w3hgvwpzl8yooq5ctnyp71v52/update?version=34
        DEBU[2019-07-01T22:37:35.829993700Z] form data: {"Data":"c2VjcmV0Cg==","Labels":{"com.docker.stack.namespace":"test"},"Name":"test_my_secret"}

This patch modifies `maskSecretKeys` to unconditionally scrub `Data` fields.
Currently, only the `secrets` and `configs` endpoints use a field with this
name, and no other POST API endpoints use a data field, so scrubbing this
field unconditionally will only scrub requests for those endpoints.

If a new endpoint is added in future where this field should not be scrubbed,
we can re-introduce more fine-grained (path-specific) handling.

This patch introduces some change in behavior:

- In addition to secrets, requests to create or update _configs_ will
  now have their `Data` field scrubbed. Generally, the actual data should
  not be interesting for debugging, so likely will not be problematic.
  In addition, scrubbing this data for configs may actually be desirable,
  because (even though they are not explicitely designed for this purpose)
  configs may contain sensitive data (credentials inside a configuration
  file, e.g.).
- Requests that send key/value pairs as a "map" and that contain a
  key named "data", will see the value of that field scrubbed. This
  means that (e.g.) setting a `label` named `data` on a config, will
  scrub/mask the value of that label.
- Note that this is already the case for any label named `jointoken`,
  `password`, `secret`, `signingcakey`, or `unlockkey`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit c7ce4be93ae8edd2da62a588e01c67313a4aba0c)
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit 73db8c77bfb2d0cbdf71ce491f3d3e66c9dd5be6)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 32b40c53662e733b4627b0b303c71b52484a31f4
Component: engine
2019-07-17 17:24:35 +02:00
2294bf630c TestMaskSecretKeys: use subtests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 32d70c7e21631224674cd60021d3ec908c2d888c)
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit ebb542b3f88d7f5551f6b6e1d8d2774a2c166409)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 1371b11749854515289abe6bcc0c1b0759ea7a5b
Component: engine
2019-07-17 17:24:23 +02:00
16da52903d TestMaskSecretKeys: add more test-cases
Add tests for

- case-insensitive matching of fields
- recursive masking

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit db5f811216e70bcb4a10e477c1558d6c68f618c5)
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit 18dac2cf32faeaada3bd4e8e2bffa576ad4329fe)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 310770b6deae3ff2f244654b8e84c14576e38493
Component: engine
2019-07-17 17:24:14 +02:00
30a5b4621e Bump golang 1.11.11
go1.11.11 (released 2019/06/11) includes a fix to the crypto/x509 package.
See the Go 1.11.11 milestone on the issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.11.11

full diff: https://github.com/golang/go/compare/go1.11.10...go1.11.11

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: a14e6cafbc02cfd82c97dc517ac15db5677065bb
Component: engine
2019-06-20 11:24:36 +02:00
b1062d6c8f Bump Golang 1.11.10
go1.11.10 (released 2019/05/06) includes fixes to the runtime and the linker.
See the Go 1.11.10 milestone on our issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.11.10

Full diff: https://github.com/golang/go/compare/go1.11.9...go1.11.10

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 79ae84c43b8d6a49aae29b804c3945ae4791f887
Component: engine
2019-06-20 11:24:31 +02:00
d33dcb4a15 Dockerfile.e2e bump alpine 3.9
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: eaa4fa999257ab37e988d38d35a2c6433e614de2
Component: engine
2019-06-20 11:24:28 +02:00
b972fd2f05 Bump Golang 1.11.9
Full diff: https://github.com/golang/go/compare/go1.11.5...go1.11.9

go1.11.6 (released 2019/03/14) includes fixes to cgo, the compiler, linker,
runtime, go command, and the crypto/x509, encoding/json, net, and net/url
packages. See the Go 1.11.6 milestone on our issue tracker for details.

https://github.com/golang/go/issues?q=milestone%3AGo1.11.6

go1.11.7 (released 2019/04/05) includes fixes to the runtime and the net
packages. See the Go 1.11.7 milestone on our issue tracker for details.

https://github.com/golang/go/issues?q=milestone%3AGo1.11.7

go1.11.8 (released 2019/04/08) was accidentally released without its
intended fix. It is identical to go1.11.7, except for its version number.
The intended fix is in go1.11.9.

go1.11.9 (released 2019/04/11) fixes an issue where using the prebuilt
binary releases on older versions of GNU/Linux led to failures when linking
programs that used cgo. Only Linux users who hit this issue need to update.

See golang/go#31293 for details

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 2cc1df06ee264ab5d1769bd4aae9e417feda9402
Component: engine
2019-06-20 11:24:25 +02:00
bd129e88cf Bump Golang 1.11.5 (CVE-2019-6486)
See the milestone for details;
https://github.com/golang/go/issues?q=milestone%3AGo1.11.5+label%3ACherryPickApproved

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 20b34412dc8a3099f658545e8504e1fc1326b3cb)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 4add22cc49057ec58284ba12afbf5a7c3c290805
Component: engine
2019-06-20 11:24:22 +02:00
3835dde0f7 Switch Dockerfile.e2e to alpine 3.8
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 7c8dcebd300262c9f98d92777dd9aab6d4e26f10)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 15148160ec0e63a7e7faab01bfbe99f6951ba313
Component: engine
2019-06-20 11:24:20 +02:00
b4d88fd07d Bump Golang 1.11.4
go1.11.4 (released 2018/12/14) includes fixes to cgo, the compiler, linker,
runtime, documentation, go command, and the net/http and go/types packages. It
includes a fix to a bug introduced in Go 1.11.3 that broke go get for import
path patterns containing "...".

See the Go 1.11.4 milestone for details:
https://github.com/golang/go/issues?q=milestone%3AGo1.11.4+label%3ACherryPickApproved

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 3770f386477e5eea4e6ba02516393a1edd5cd28b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: e05367a1ba3cbf2cd7f99fef73908b900b57b929
Component: engine
2019-06-20 11:24:17 +02:00
b71651c1b7 Bump Golang 1.11.3 (CVE-2018-16875)
go1.11.13 (released 2018/12/14)

- crypto/x509: CPU denial of service in chain validation golang/go#29233
- cmd/go: directory traversal in "go get" via curly braces in import paths golang/go#29231
- cmd/go: remote command execution during "go get -u" golang/go#29230

See the Go 1.11.3 milestone on the issue tracker for details:
https://github.com/golang/go/issues?q=milestone%3AGo1.11.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 6b7c093b0de21d574ce120aee891e60187749174)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 19d37c9a337e82e0e8ce0ff28271739e8ec78e83
Component: engine
2019-06-20 11:24:14 +02:00
5da3533485 Bump Golang to 1.11.2
Includes fixes to the compiler, linker, documentation, go command, and the
database/sql and go/types packages. See the Go 1.11.2 milestone on the issue
tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.11.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit e80ee5206e6e62521c8149381d06bbb0bea88169)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: f9a71f917f0979742b1d7ee606fb596e873d773c
Component: engine
2019-06-20 11:24:11 +02:00
5a61d5bd74 Bump Golang 1.11.1
go1.11.1 (released 2018/10/01) includes fixes to the compiler,
documentation, go command, runtime, and the crypto/x509, encoding/json,
go/types, net, net/http, and reflect packages.

See the Go 1.11.1 milestone on our issue tracker for details:
https://github.com/golang/go/issues?q=milestone%3AGo1.11.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 0347751117513312be72e8b0d03f32319027f145)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 6b397d155bf464a94fa05620a485d969edf42393
Component: engine
2019-06-20 11:24:09 +02:00
28b6a8ea45 vendor: bump etcd deps
As per https://github.com/etcd-io/etcd/blob/fa57f7fbc787b4/Gopkg.lock

List of packages required by subset of etcd used is provided by:

go list -f '{{join .Deps "\n"}}' \
 github.com/docker/docker/vendor/github.com/coreos/etcd/... \
 | grep -F . | grep -v coreos/etcd | sort | uniq

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 7008ac01fa4dbde9a069cc647a09c982f3648fc3)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: c4bf0803154de1b26ee3437c7fd9307722e2a5e4
Component: engine
2019-06-20 11:24:06 +02:00
f8bdbb2a11 vendor: bump etcd to v3.3.9
...and use ugorji/go 1.1.1

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit a77a2a406cd3303a4fd5ccbfbeccde8a9014dbcb)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: a1e8eee6ff19078c94727a57296c6ae8f94c2be6
Component: engine
2019-06-20 11:24:03 +02:00
8764c9c9c4 Bump vndr
We can do that now as we're no longer carrying archive/tar.
Note that latest vndr removes vendor/ subdir so we don't have to,
thus the change in hack/validate/vendor.

While at it, re-run a new vndr version to make sure everything
that should be there is.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit ce858feb6ac124b3a42400b857e480ef98710164)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 2f2588f137f642b0c1520e8a41ec731040d0b336
Component: engine
2019-06-20 11:24:00 +02:00
abcb9e9f1f Bump golang to 1.11.0
It's that time of year again! Go 1.11 is released, time to use it.

This commit also

* removes our archive/tar fork, since upstream archive/tar
  is fixed for static builds, and osusergo build tag is set.

* removes ENV GO_VERSION from Dockerfile as it's not needed
  anymore since PR #37592 is merged.

[v2: switch to beta2]
[v3: switch to beta3]
[v4: rc1]
[v5: remove ENV GO_VERSION as PR #37592 is now merged]
[v6: rc2]
[v7: final!]
[v8: use 1.11.0]
[v9: back to 1.11]
[v8: use 1.11.0]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 10fd0516b9f9f04d0f0e2c0755e704303f1a487f)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: ebf396050d6e977df2669d5e7d3f38098719f7c2
Component: engine
2019-06-20 11:23:57 +02:00
bad43bbc06 hack/make.ps1: remove the .0 suffix from go version
We would like to use a version with .0 suffix (like 1.11.0) in
Dockerfile, so that once a .1 version is out (like 1.11.1) we
won't accidentally switch to it.

Unfortunately it's not possible to use .0 suffix currently
as it breaks the check in make.ps1. This patch fixes that.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 8ad648b59a2993156586458cc9ff8dcbc89b86e4)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: dc5371b4134dd6474a467308da85daaa27914a64
Component: engine
2019-06-20 11:23:54 +02:00