Commit graph

46867 commits

Author SHA1 Message Date
Sebastiaan van Stijn
3e8fda0a70
windows: fix --register-service when executed from within binary directory
Go 1.15.7 contained a security fix for CVE-2021-3115, which allowed arbitrary
code to be executed at build time when using cgo on Windows.

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

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

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

At time of the go1.15 release, the Go team considered changing the behavior of
`os.LookPath()` and `exec.LookPath()` to be a breaking change, and made the
behavior "opt-in" by providing the `golang.org/x/sys/execabs` package as a
replacement.

However, for the go1.19 release, this changed, and the default behavior of
`os.LookPath()` and `exec.LookPath()` was changed. From the release notes:
https://go.dev/doc/go1.19#os-exec-path

> Command and LookPath no longer allow results from a PATH search to be found
> relative to the current directory. This removes a common source of security
> problems but may also break existing programs that depend on using, say,
> exec.Command("prog") to run a binary named prog (or, on Windows, prog.exe)
> in the current directory. See the os/exec package documentation for information
> about how best to update such programs.
>
> On Windows, Command and LookPath now respect the NoDefaultCurrentDirectoryInExePath
> environment variable, making it possible to disable the default implicit search
> of “.” in PATH lookups on Windows systems.

A result of this change was that registering the daemon as a Windows service
no longer worked when done from within the directory of the binary itself:

    C:\> cd "Program Files\Docker\Docker\resources"
    C:\Program Files\Docker\Docker\resources> dockerd --register-service
    exec: "dockerd": cannot run executable found relative to current directory

Note that using an absolute path would work around the issue:

    C:\Program Files\Docker\Docker>resources\dockerd.exe --register-service

This patch changes `registerService()` to use `os.Executable()`, instead of
depending on `os.Args[0]` and `exec.LookPath()` for resolving the absolute
path of the binary.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-27 16:20:49 +02:00
Sebastiaan van Stijn
10aff57b26
Merge pull request #46037 from AkihiroSuda/rro-remove-short
volume: remove the short RRO forms in favor of the long forms
2023-07-27 14:11:30 +02:00
Sebastiaan van Stijn
198ba185c7
Merge pull request #46081 from vvoland/c8d-refreshimage-refactor
daemon/list: Refactor refreshImage and make `readConfig` return errdefs
2023-07-27 13:52:51 +02:00
Sebastiaan van Stijn
c30c3f94c7
Merge pull request #46041 from thaJeztah/datastore_remove_libkv
libnetwork: remove most of kvstore
2023-07-26 22:27:28 +02:00
Paweł Gronowski
13180c1c49
daemon/list: Drop unused arg from containerReducer
refreshImage is the only function used as a reducer and it doesn't use
the `filter *listContext`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-07-26 17:28:12 +02:00
Paweł Gronowski
68991ae240
daemon/list: Refactor refreshImage
Add context comments and make it a bit more readable.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-07-26 17:28:10 +02:00
Sebastiaan van Stijn
7a44e4cde0
Merge pull request #46034 from rumpl/c8d-image-list
c8d: Various images/json API fixes
2023-07-26 16:50:27 +02:00
Djordje Lukic
e5cffc07b3
c8d: Fix TestImagesFilterMultiReference
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-07-26 14:34:42 +02:00
Djordje Lukic
1d8108b009
c8d: images/json, add image labels to the response
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-07-26 14:33:22 +02:00
Djordje Lukic
a0bba26919
c8d: Populate RepoTags instead of adding a new image to the list
Aggregate same images into one object and add the list of tags pointing
to it to the RepoTags array

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-07-26 14:33:20 +02:00
Djordje Lukic
ad2760ec80
integration: Move image filter tests to integration
- use assert.Check to continue the test even if a check fails
- assert the total number of images returned, not only their RepoTags
- use subtests

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-07-26 14:33:16 +02:00
Bjorn Neergaard
427f95c4e6
Merge pull request #45978 from thaJeztah/client_docs_touch_up
client: touch-up docs, cleanup some tests, and minor refactoring
2023-07-26 05:55:46 -06:00
Paweł Gronowski
5a39bee635
daemon/list: Replace ErrImageDoesNotExist check
Check for generic `errdefs.NotFound` rather than specific error helper
struct when checking if the error is caused by the image not being
present.
It still works for `ErrImageDoesNotExist` because it
implements the NotFound errdefs interface too.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-07-26 13:40:04 +02:00
Paweł Gronowski
7379d18018
c8d/readConfig: Translate c8d NotFound to errdefs
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-07-26 13:40:02 +02:00
Sebastiaan van Stijn
536e3692c6
Merge pull request #46017 from thaJeztah/pkg_plugin_cleanup
pkg/plugins: some cleaning up (step 1)
2023-07-26 02:10:36 +02:00
Sebastiaan van Stijn
5fe05d3eeb
Merge pull request #46053 from thaJeztah/network_backend_remove_FindNetwork
api/server/router/network: remove unused Backend.FindNetwork
2023-07-25 23:16:02 +02:00
Sebastiaan van Stijn
02dc5ea720
libnetwork/datastore: remove Store.KVStore()
It's no longer used, so we can remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:42:17 +02:00
Sebastiaan van Stijn
0f7bf67f83
pkg/plugins: TestGet(): use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:38:38 +02:00
Sebastiaan van Stijn
e1ad4aa002
pkg/plugins: make package-level socketsPath var a LocalRegistry field
This variable was only accessed from within LocalRegistry methods, but
due to being a package-level variable, tests had to deal with setting
and resetting it.

Move it to be a field scoped to the LocalRegistry. This simplifies the
tests, and to make this more transparent, also removing the "Setup()"
helper (which, wasn't marked as a t.Helper()).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:38:37 +02:00
Sebastiaan van Stijn
5bd44cf3c4
pkg/plugins: remove "load()" function
It was used in a single place and was abstracting "loadWithRetry";
let's just inline it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:38:37 +02:00
Sebastiaan van Stijn
77c03221c9
pkg/plugins/transport: remove RequestFactory interface
The client's transport can only be set by newClientWithTransport, which
is not exported, and always uses a transport.HTTPTransport.

However, requestFactory is mocked in one of the tests, so keep the interface,
but make it a local, non-exported one.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:38:37 +02:00
Sebastiaan van Stijn
d12ec5f796
pkg/plugins/transport: remove unused Transport interface
The interface is not consumed anywhere, and only non-exported functions
produced one, so we can remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:38:37 +02:00
Sebastiaan van Stijn
dfd331b2c8
pkg/plugins/transport: export httpTransport, and return concrete type
Make NewHTTPTransport return a concrete type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:38:37 +02:00
Sebastiaan van Stijn
77103c7c03
pkg/plugins/transport: inline newHTTPRequest
It was only used in a single location; just inline the code

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:38:37 +02:00
Sebastiaan van Stijn
4af4adc7ba
pkg/plugins: remove LocalRegistry.SpecsPaths()
This field was exported, but never mutated outside of the package, and
effectively a rather "creative" way to define a method on LocalRegistry.

While un-exporting also store these paths in a field, instead of constructing
them on every call, as the results won't change during the lifecycle of the
LocalRegistry.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:38:36 +02:00
Sebastiaan van Stijn
a44c25c2f1
pkg/plugins: split exported from implementation
Split the exported SpecsPaths from the platform-specific implementations,
so that documentation can be maintained in a single location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:38:11 +02:00
Sebastiaan van Stijn
954d50b88a
plg/plugins: rename vars that collided, or poorly cased
Reduce some noise while reading the code in my IDE :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:35:43 +02:00
Sebastiaan van Stijn
20889dbac6
pkg/plugins: move Plugin.ScopedPath to platform-agnostic file
Since 0e5eaf8ee3, these implementations
were fully identical, so removing the duplicate, and move it to a
platform-agnostic file.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:35:40 +02:00
Sebastiaan van Stijn
a5ee0d6af8
libnetwork: don't access KVStore directly in tests
Test the datastore, not the KVStore backing it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:21:03 +02:00
Sebastiaan van Stijn
b378669836
libnetwork/datastore: don't access KVStore directly in tests
Test the datastore, not the KVStore backing it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:20:21 +02:00
Sebastiaan van Stijn
65978e6982
libnetwork/datastore: cleanup tests
- use gotest.tools assertions
- use consts and struct-literals where possible
- use assert.Check instead of t.Fatal() where possible
- fix some unhandled errors

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:20:21 +02:00
Sebastiaan van Stijn
478f4aed63
libnetwork/datastore: ScopeCfg.IsValid(): un-wrap conditions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:20:21 +02:00
Sebastiaan van Stijn
37cbdeb1f2
libnetwork: remove most of kvstore
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:20:18 +02:00
Sebastiaan van Stijn
e4134d5c0d
Merge pull request #46048 from thaJeztah/libnetwork_test
libnetwork: refactor TestErrorInterfaces into a test
2023-07-25 17:12:59 +02:00
Sebastiaan van Stijn
d713b7ed45
api/server/router/network: remove unused Backend.FindNetwork
This function was used by the postNetworkConnect() handler, but is handled
by the backend itself, starting with d63a5a1ff5.
Since that commit, this function was no longer used, so we can remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 16:33:57 +02:00
Akihiro Suda
8291893239
Merge pull request #46070 from thaJeztah/bump_runtime_spec
vendor: github.com/opencontainers/runtime-spec v1.1.0
2023-07-25 23:33:48 +09:00
Sebastiaan van Stijn
7e4ffa3fa9
Merge pull request #46050 from thaJeztah/libnetwork_remove_interface
libnetwork: remove Network interface
2023-07-25 16:02:19 +02:00
Sebastiaan van Stijn
b3ed92d88b
Merge pull request #46040 from thaJeztah/datastore_no_interfaces
libnetwork/datastore: remove DataStore interface, and rename constructor
2023-07-25 10:41:43 +02:00
Sebastiaan van Stijn
08815cb1b9
Merge pull request #46071 from thaJeztah/fix_comment
daemon/containerd: ImageService. LoadImage fix stray slash in comment
2023-07-25 10:39:53 +02:00
Sebastiaan van Stijn
1bc7a2aacd
daemon/containerd: ImageService. LoadImage fix stray slash in comment
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 09:24:31 +02:00
Sebastiaan van Stijn
126a089382
vendor: github.com/opencontainers/runtime-spec v1.1.0
- Add I/O Priority Configuration for Process Group in Linux Containers
- spec: add scheduler entity (based on the Linux sched_setattr(2) syscall).

full diff: https://github.com/opencontainers/runtime-spec/compare/v1.1.0-rc.2...v1.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 09:19:44 +02:00
Sebastiaan van Stijn
d4d645d32a
Merge pull request #46060 from vvoland/integration-no-fail-fast
ci/integration: Don't fail fast
2023-07-24 20:53:34 +02:00
Sebastiaan van Stijn
7ced56b356
Merge pull request #46065 from corhere/libn/defuse-datastore-key-latent-race
libnetwork/datastore: prevent data races in Key()
2023-07-24 19:53:24 +02:00
Cory Snider
5ef9e2632f libnetwork/datastore: prevent data races in Key()
The rootChain variable that the Key function references is a
package-global slice. As the append() built-in may append to the slice's
backing array in place, it is theoretically possible for the temporary
slices in concurrent Key() calls to share the same backing array, which
would be a data race. Thankfully in my tests (on Go 1.20.6)

    cap(rootChain) == len(rootChain)

held true, so in practice a new slice is always allocated and there is
no race. But that is a very brittle assumption to depend upon, which
could blow up in our faces at any time without warning. Rewrite the
implementation in a way which cannot lead to data races.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-07-24 12:18:04 -04:00
Paweł Gronowski
48cc28e4ef
hack/integration: Add TEST_INTEGRATION_FAIL_FAST
Before this change, integration test would fail fast and not execute all
test suites when one suite fails.
Change this behavior into opt-in enabled by TEST_INTEGRATION_FAIL_FAST
variable.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-07-24 16:54:31 +02:00
Sebastiaan van Stijn
96b473a0bd
Merge pull request #45992 from jedevc/registry-hosts-use-service-config
daemon: use the registry service config for getting registry hosts
2023-07-24 16:45:09 +02:00
Sebastiaan van Stijn
f70e1b315f
libnetwork/datastore: remove unused ParseKey() utility
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-24 16:01:43 +02:00
Sebastiaan van Stijn
704a19b25d
libnetwork/datastore: remove DataStore interface
It only had a single implementation, so let's remove the interface.

While changing, also renaming;

- datastore.DataStore -> datastore.Store
- datastore.NewDataStore -> datastore.New
- datastore.NewDataStoreFromConfig -> datastore.FromConfig

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-24 15:54:05 +02:00
Sebastiaan van Stijn
d5b1e43b8f
libnetwork/datastore: move MockData to a _test file
It's only used in tests, and only within this package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-24 15:28:07 +02:00
Bjorn Neergaard
d16579971e
Merge pull request #45981 from thaJeztah/bump_buildkit_0.11
vendor: github.com/moby/buildkit v0.11.7-dev
2023-07-24 07:13:40 -06:00