The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
Find a file
Sebastiaan van Stijn 25b709df48
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>
(cherry picked from commit 3e8fda0a70)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-13 21:58:08 +02:00
.github update to go1.20.7 2023-08-01 23:47:48 +02:00
api api/types/filters: fix errors not being matched by errors.Is() 2023-07-29 16:25:07 +02:00
builder vendor: github.com/moby/buildkit v0.11.7-dev 2023-07-24 16:14:03 +02:00
cli cli/debug: use string-literals for easier grep'ing 2023-07-15 00:49:55 +02:00
client client: Client.postHijacked: use Client.buildRequest 2023-07-17 09:41:41 +02:00
cmd windows: fix --register-service when executed from within binary directory 2023-08-13 21:58:08 +02:00
container container: split security options to a SecurityOptions struct 2023-04-29 00:03:37 +02:00
contrib Remove Upstart scripts 2023-07-21 11:00:50 -06:00
daemon Merge pull request #46095 from vvoland/c8d-refreshimage-refactor-24 2023-07-28 13:11:43 +02:00
distribution fixing consistent aliases for OCI spec imports 2023-06-01 17:22:49 +02:00
dockerversion dockerversion: DockerUserAgent(): allow custom versions to be passed 2023-06-02 11:41:09 +02:00
docs Merge pull request #45869 from thaJeztah/24.0_backport_docs_plugin_disable_force_carry 2023-07-02 23:02:35 +02:00
errdefs errdefs: FromStatusCode() don't log "FIXME" debug message 2022-12-20 16:03:46 +01:00
hack hack/test: Don't fail-fast before integration-cli 2023-08-09 14:22:09 +02:00
image docs: fix JSON format error 2023-02-03 08:16:48 +00:00
integration integration/windows: Unskip some kill tests 2023-08-09 14:29:06 +02:00
integration-cli integration-cli: use string-literals for easier grep'ing 2023-07-15 00:49:35 +02:00
internal Add reusable chroot and unshare utilities 2022-10-26 12:06:31 -04:00
layer layer: NewStoreFromOptions(): include driver-name in error message 2023-03-06 13:06:16 +01:00
libcontainerd daemon: stop setting container resources to zero 2023-06-21 22:16:22 +02:00
libnetwork libnetwork: use string-literals for easier grep'ing 2023-07-15 00:50:47 +02:00
oci daemon: ensure OCI options play nicely together 2023-06-21 22:16:28 +02:00
opts opts: use string-literals for easier grep'ing 2023-07-15 00:51:09 +02:00
pkg pkg/jsonmessage: use string-literals for easier grep'ing 2023-07-15 00:51:38 +02:00
plugin fixing consistent aliases for OCI spec imports 2023-06-01 17:22:49 +02:00
profiles seccomp: add name_to_handle_at to allowlist 2023-06-28 05:46:56 -06:00
project daemon: remove deprecated AuFS storage driver 2023-04-15 01:27:16 +02:00
quota quota: remove gotest.tools from testhelpers 2023-07-17 23:12:28 +02:00
reference reference: add test-coverage for digested references 2023-03-06 13:01:35 +01:00
registry registry/search: pass User-Agent through headers 2023-03-21 14:41:29 +01:00
reports Fix typos 2018-05-16 09:15:43 +08:00
restartmanager restartmanager: remove RestartManager interface 2022-12-28 09:36:58 +01:00
runconfig api/server: allow empty body for POST /commit again 2023-05-18 16:06:57 -04:00
testutil TestDaemonProxy: use new scanners to check logs 2023-08-01 13:24:22 +02:00
vendor vendor: gotest.tools/v3 v3.5.0 2023-07-29 20:53:54 +02:00
volume Restore active mount counts on live-restore 2023-06-28 09:45:07 +02:00
.dockerignore ignorefiles: cleanup 2022-11-21 18:43:42 -07:00
.gitattributes chore: fix linguist for Dockerfile 2022-04-27 06:38:41 +02:00
.gitignore hack: introduce validate/no-module 2022-12-12 18:39:06 -07:00
.mailmap .mailmap: cleanup and additions 2022-11-30 12:05:31 +01:00
AUTHORS regenerate AUTHORS 2023-03-06 17:11:00 +01:00
codecov.yml codecov: disable "patch" status 2022-06-07 17:24:46 +02:00
CONTRIBUTING.md CONTRIBUTING.md: drop reference to the Derek GitHub bot 2023-01-10 15:42:09 -07:00
docker-bake.hcl Dockerfile: use default apt mirrors 2023-07-17 11:23:05 -06:00
Dockerfile update to go1.20.7 2023-08-01 23:47:48 +02:00
Dockerfile.e2e hack: Rename .ensure-emptyfs to .build-empty-images 2023-05-25 09:48:58 +02:00
Dockerfile.simple update to go1.20.7 2023-08-01 23:47:48 +02:00
Dockerfile.windows update to go1.20.7 2023-08-01 23:47:48 +02:00
Jenkinsfile Dockerfile: use default apt mirrors 2023-07-17 11:23:05 -06:00
LICENSE Update LICENSE 2018-09-12 14:27:53 +01:00
MAINTAINERS Add akerouanton as curator 2023-03-28 11:01:28 +02:00
Makefile hack/integration: Add TEST_INTEGRATION_FAIL_FAST 2023-07-24 17:05:44 +02:00
NOTICE switch kr/pty to creack/pty v1.1.7 2019-07-29 16:59:08 -07:00
README.md Fix grammar in README.md 2022-11-10 19:49:41 +00:00
ROADMAP.md Fix some typos in ROADMAP.md 2019-01-25 14:27:13 +08:00
SECURITY.md Update SECURITY.md to have an option to keep name anonymous if requested. 2019-06-18 16:37:16 +00:00
TESTING.md TESTING.md: note that integration-cli is deprecated 2020-12-18 07:51:46 +01:00
vendor.mod vendor: gotest.tools/v3 v3.5.0 2023-07-29 20:53:54 +02:00
vendor.sum vendor: gotest.tools/v3 v3.5.0 2023-07-29 20:53:54 +02:00
VENDORING.md fix the bare url and the Summary of http://semver.org 2017-01-17 16:20:11 +08:00

The Moby Project

Moby Project logo

Moby is an open-source project created by Docker to enable and accelerate software containerization.

It provides a "Lego set" of toolkit components, the framework for assembling them into custom container-based systems, and a place for all container enthusiasts and professionals to experiment and exchange ideas. Components include container build tools, a container registry, orchestration tools, a runtime and more, and these can be used as building blocks in conjunction with other tools and projects.

Principles

Moby is an open project guided by strong principles, aiming to be modular, flexible and without too strong an opinion on user experience. It is open to the community to help set its direction.

  • Modular: the project includes lots of components that have well-defined functions and APIs that work together.
  • Batteries included but swappable: Moby includes enough components to build fully featured container systems, but its modular architecture ensures that most of the components can be swapped by different implementations.
  • Usable security: Moby provides secure defaults without compromising usability.
  • Developer focused: The APIs are intended to be functional and useful to build powerful tools. They are not necessarily intended as end user tools but as components aimed at developers. Documentation and UX is aimed at developers not end users.

Audience

The Moby Project is intended for engineers, integrators and enthusiasts looking to modify, hack, fix, experiment, invent and build systems based on containers. It is not for people looking for a commercially supported system, but for people who want to work and learn with open source code.

Relationship with Docker

The components and tools in the Moby Project are initially the open source components that Docker and the community have built for the Docker Project. New projects can be added if they fit with the community goals. Docker is committed to using Moby as the upstream for the Docker Product. However, other projects are also encouraged to use Moby as an upstream, and to reuse the components in diverse ways, and all these uses will be treated in the same way. External maintainers and contributors are welcomed.

The Moby project is not intended as a location for support or feature requests for Docker products, but as a place for contributors to work on open source code, fix bugs, and make the code more useful. The releases are supported by the maintainers, community and users, on a best efforts basis only, and are not intended for customers who want enterprise or commercial support; Docker EE is the appropriate product for these use cases.


Legal

Brought to you courtesy of our legal counsel. For more context, please see the NOTICE document in this repo.

Use and transfer of Moby may be subject to certain restrictions by the United States and other governments.

It is your responsibility to ensure that your use and/or transfer does not violate applicable laws.

For more information, please see https://www.bis.doc.gov

Licensing

Moby is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.