dockerinit has been around for a very long time. It was originally used
as a way for us to do configuration for LXC containers once the
container had started. LXC is no longer supported, and /.dockerinit has
been dead code for quite a while. This removes all code and references
in code to dockerinit.
Signed-off-by: Aleksa Sarai <asarai@suse.com>
| ... | ... |
@@ -96,8 +96,7 @@ RUN set -x \ |
| 96 | 96 |
ENV PATH /osxcross/target/bin:$PATH |
| 97 | 97 |
|
| 98 | 98 |
# install seccomp |
| 99 |
-# this can be changed to the ubuntu package libseccomp-dev if dockerinit is removed, |
|
| 100 |
-# we need libseccomp.a (which the package does not provide) for dockerinit |
|
| 99 |
+# TODO: switch to libseccomp-dev since dockerinit is gone |
|
| 101 | 100 |
ENV SECCOMP_VERSION 2.2.3 |
| 102 | 101 |
RUN set -x \ |
| 103 | 102 |
&& export SECCOMP_PATH="$(mktemp -d)" \ |
| ... | ... |
@@ -114,7 +113,7 @@ RUN set -x \ |
| 114 | 114 |
|
| 115 | 115 |
# Install Go |
| 116 | 116 |
# IMPORTANT: If the version of Go is updated, the Windows to Linux CI machines |
| 117 |
-# will need updating, to avoid errors. Ping #docker-maintainers on IRC |
|
| 117 |
+# will need updating, to avoid errors. Ping #docker-maintainers on IRC |
|
| 118 | 118 |
# with a heads-up. |
| 119 | 119 |
ENV GO_VERSION 1.5.3 |
| 120 | 120 |
RUN curl -fsSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" \
|
| ... | ... |
@@ -111,8 +111,7 @@ RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint |
| 111 | 111 |
&& go install -v github.com/golang/lint/golint |
| 112 | 112 |
|
| 113 | 113 |
# install seccomp |
| 114 |
-# this can be changed to the ubuntu package libseccomp-dev if dockerinit is removed, |
|
| 115 |
-# we need libseccomp.a (which the package does not provide) for dockerinit |
|
| 114 |
+# TODO: switch to libseccomp-dev since dockerinit is gone |
|
| 116 | 115 |
ENV SECCOMP_VERSION 2.2.3 |
| 117 | 116 |
RUN set -x \ |
| 118 | 117 |
&& export SECCOMP_PATH="$(mktemp -d)" \ |
| ... | ... |
@@ -42,8 +42,7 @@ RUN cd /usr/local/lvm2 \ |
| 42 | 42 |
# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL |
| 43 | 43 |
|
| 44 | 44 |
# install seccomp |
| 45 |
-# this can be changed to the ubuntu package libseccomp-dev if dockerinit is removed, |
|
| 46 |
-# we need libseccomp.a (which the package does not provide) for dockerinit |
|
| 45 |
+# TODO: switch to libseccomp-dev since dockerinit is gone |
|
| 47 | 46 |
ENV SECCOMP_VERSION v2.2.3 |
| 48 | 47 |
RUN set -x \ |
| 49 | 48 |
&& export SECCOMP_PATH=$(mktemp -d) \ |
| ... | ... |
@@ -74,8 +74,6 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
| 74 | 74 |
fmt.Fprintf(cli.out, " Goroutines: %d\n", info.NGoroutines) |
| 75 | 75 |
fmt.Fprintf(cli.out, " System Time: %s\n", info.SystemTime) |
| 76 | 76 |
fmt.Fprintf(cli.out, " EventsListeners: %d\n", info.NEventsListener) |
| 77 |
- fmt.Fprintf(cli.out, " Init SHA1: %s\n", info.InitSha1) |
|
| 78 |
- fmt.Fprintf(cli.out, " Init Path: %s\n", info.InitPath) |
|
| 79 | 77 |
fmt.Fprintf(cli.out, " Docker Root Dir: %s\n", info.DockerRootDir) |
| 80 | 78 |
} |
| 81 | 79 |
|
| ... | ... |
@@ -63,10 +63,6 @@ func (container *Container) CreateDaemonEnvironment(linkedEnv []string) []string |
| 63 | 63 |
env := []string{
|
| 64 | 64 |
"PATH=" + system.DefaultPathEnv, |
| 65 | 65 |
"HOSTNAME=" + fullHostname, |
| 66 |
- // Note: we don't set HOME here because it'll get autoset intelligently |
|
| 67 |
- // based on the value of USER inside dockerinit, but only if it isn't |
|
| 68 |
- // set already (ie, that can be overridden by setting HOME via -e or ENV |
|
| 69 |
- // in a Dockerfile). |
|
| 70 | 66 |
} |
| 71 | 67 |
if container.Config.Tty {
|
| 72 | 68 |
env = append(env, "TERM=xterm") |
| ... | ... |
@@ -118,9 +118,7 @@ for version in "${versions[@]}"; do
|
| 118 | 118 |
|
| 119 | 119 |
echo >> "$version/Dockerfile" |
| 120 | 120 |
|
| 121 |
- # fedora does not have a libseccomp.a for compiling static dockerinit |
|
| 122 |
- # ONLY install libseccomp.a from source, this can be removed once dockerinit is removed |
|
| 123 |
- # TODO remove this manual seccomp compilation once dockerinit is gone or no longer needs to be statically compiled |
|
| 121 |
+ # TODO remove this since dockerinit is finally gone |
|
| 124 | 122 |
case "$from" in |
| 125 | 123 |
fedora:*) |
| 126 | 124 |
awk '$1 == "ENV" && $2 == "SECCOMP_VERSION" { print; exit }' ../../../Dockerfile >> "$version/Dockerfile"
|
| ... | ... |
@@ -254,7 +254,6 @@ func (daemon *Daemon) populateCommand(c *container.Container, env []string) erro |
| 254 | 254 |
c.Command = &execdriver.Command{
|
| 255 | 255 |
CommonCommand: execdriver.CommonCommand{
|
| 256 | 256 |
ID: c.ID, |
| 257 |
- InitPath: "/.dockerinit", |
|
| 258 | 257 |
MountLabel: c.GetMountLabel(), |
| 259 | 258 |
Network: en, |
| 260 | 259 |
ProcessConfig: processConfig, |
| ... | ... |
@@ -124,7 +124,6 @@ func (daemon *Daemon) populateCommand(c *container.Container, env []string) erro |
| 124 | 124 |
CommonCommand: execdriver.CommonCommand{
|
| 125 | 125 |
ID: c.ID, |
| 126 | 126 |
Rootfs: c.BaseFS, |
| 127 |
- InitPath: "/.dockerinit", |
|
| 128 | 127 |
WorkingDir: c.Config.WorkingDir, |
| 129 | 128 |
Network: en, |
| 130 | 129 |
MountLabel: c.GetMountLabel(), |
| ... | ... |
@@ -688,8 +688,7 @@ func initBridgeDriver(controller libnetwork.NetworkController, config *Config) e |
| 688 | 688 |
} |
| 689 | 689 |
|
| 690 | 690 |
// setupInitLayer populates a directory with mountpoints suitable |
| 691 |
-// for bind-mounting dockerinit into the container. The mountpoint is simply an |
|
| 692 |
-// empty file at /.dockerinit |
|
| 691 |
+// for bind-mounting things into the container. |
|
| 693 | 692 |
// |
| 694 | 693 |
// This extra layer is used by all containers as the top-most ro layer. It protects |
| 695 | 694 |
// the container from unwanted side-effects on the rw layer. |
| ... | ... |
@@ -699,7 +698,6 @@ func setupInitLayer(initLayer string, rootUID, rootGID int) error {
|
| 699 | 699 |
"/dev/shm": "dir", |
| 700 | 700 |
"/proc": "dir", |
| 701 | 701 |
"/sys": "dir", |
| 702 |
- "/.dockerinit": "file", |
|
| 703 | 702 |
"/.dockerenv": "file", |
| 704 | 703 |
"/etc/resolv.conf": "file", |
| 705 | 704 |
"/etc/hosts": "file", |
| ... | ... |
@@ -131,7 +131,6 @@ type CommonProcessConfig struct {
|
| 131 | 131 |
type CommonCommand struct {
|
| 132 | 132 |
ContainerPid int `json:"container_pid"` // the pid for the process inside a container |
| 133 | 133 |
ID string `json:"id"` |
| 134 |
- InitPath string `json:"initpath"` // dockerinit |
|
| 135 | 134 |
MountLabel string `json:"mount_label"` // TODO Windows. More involved, but can be factored out |
| 136 | 135 |
Mounts []Mount `json:"mounts"` |
| 137 | 136 |
Network *Network `json:"network"` |
| ... | ... |
@@ -49,11 +49,6 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
|
| 49 | 49 |
logrus.Errorf("Could not read system memory info: %v", err)
|
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 |
- // if we still have the original dockerinit binary from before |
|
| 53 |
- // we copied it locally, let's return the path to that, since |
|
| 54 |
- // that's more intuitive (the copied path is trivial to derive |
|
| 55 |
- // by hand given VERSION) |
|
| 56 |
- initPath := utils.DockerInitPath("")
|
|
| 57 | 52 |
sysInfo := sysinfo.New(true) |
| 58 | 53 |
|
| 59 | 54 |
var cRunning, cPaused, cStopped int32 |
| ... | ... |
@@ -94,8 +89,6 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
|
| 94 | 94 |
OSType: platform.OSType, |
| 95 | 95 |
Architecture: platform.Architecture, |
| 96 | 96 |
RegistryConfig: daemon.RegistryService.Config, |
| 97 |
- InitSha1: dockerversion.InitSHA1, |
|
| 98 |
- InitPath: initPath, |
|
| 99 | 97 |
NCPU: runtime.NumCPU(), |
| 100 | 98 |
MemTotal: meminfo.MemTotal, |
| 101 | 99 |
DockerRootDir: daemon.configStore.Root, |
| ... | ... |
@@ -76,7 +76,6 @@ _dockerfile_env() {
|
| 76 | 76 |
clean() {
|
| 77 | 77 |
local packages=( |
| 78 | 78 |
"${PROJECT}/docker" # package main
|
| 79 |
- "${PROJECT}/dockerinit" # package main
|
|
| 80 | 79 |
"${PROJECT}/integration-cli" # external tests
|
| 81 | 80 |
) |
| 82 | 81 |
local dockerPlatforms=( ${DOCKER_ENGINE_OSARCH:="linux/amd64"} $(_dockerfile_env DOCKER_CROSSPLATFORMS) )
|
| ... | ... |
@@ -17,14 +17,12 @@ override_dh_auto_test: |
| 17 | 17 |
./bundles/$(VERSION)/dynbinary/docker -v |
| 18 | 18 |
|
| 19 | 19 |
override_dh_strip: |
| 20 |
- # the SHA1 of dockerinit is important: don't strip it |
|
| 21 |
- # also, Go has lots of problems with stripping, so just don't |
|
| 20 |
+ # Go has lots of problems with stripping, so just don't |
|
| 22 | 21 |
|
| 23 | 22 |
override_dh_auto_install: |
| 24 | 23 |
mkdir -p debian/docker-engine/usr/bin |
| 25 | 24 |
cp -aT "$$(readlink -f bundles/$(VERSION)/dynbinary/docker)" debian/docker-engine/usr/bin/docker |
| 26 | 25 |
mkdir -p debian/docker-engine/usr/lib/docker |
| 27 |
- cp -aT "$$(readlink -f bundles/$(VERSION)/dynbinary/dockerinit)" debian/docker-engine/usr/lib/docker/dockerinit |
|
| 28 | 26 |
|
| 29 | 27 |
override_dh_installinit: |
| 30 | 28 |
# use "docker" as our service name, not "docker-engine" |
| ... | ... |
@@ -11,11 +11,6 @@ URL: https://dockerproject.org |
| 11 | 11 |
Vendor: Docker |
| 12 | 12 |
Packager: Docker <support@docker.com> |
| 13 | 13 |
|
| 14 |
-# docker builds in a checksum of dockerinit into docker, |
|
| 15 |
-# # so stripping the binaries breaks docker |
|
| 16 |
-%global __os_install_post %{_rpmconfigdir}/brp-compress
|
|
| 17 |
-%global debug_package %{nil}
|
|
| 18 |
- |
|
| 19 | 14 |
# is_systemd conditional |
| 20 | 15 |
%if 0%{?fedora} >= 21 || 0%{?centos} >= 7 || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1300
|
| 21 | 16 |
%global is_systemd 1 |
| ... | ... |
@@ -124,10 +119,6 @@ export DOCKER_GITCOMMIT=%{_gitcommit}
|
| 124 | 124 |
install -d $RPM_BUILD_ROOT/%{_bindir}
|
| 125 | 125 |
install -p -m 755 bundles/%{_origversion}/dynbinary/docker-%{_origversion} $RPM_BUILD_ROOT/%{_bindir}/docker
|
| 126 | 126 |
|
| 127 |
-# install dockerinit |
|
| 128 |
-install -d $RPM_BUILD_ROOT/%{_libexecdir}/docker
|
|
| 129 |
-install -p -m 755 bundles/%{_origversion}/dynbinary/dockerinit-%{_origversion} $RPM_BUILD_ROOT/%{_libexecdir}/docker/dockerinit
|
|
| 130 |
- |
|
| 131 | 127 |
# install udev rules |
| 132 | 128 |
install -d $RPM_BUILD_ROOT/%{_sysconfdir}/udev/rules.d
|
| 133 | 129 |
install -p -m 644 contrib/udev/80-docker.rules $RPM_BUILD_ROOT/%{_sysconfdir}/udev/rules.d/80-docker.rules
|
| ... | ... |
@@ -175,7 +166,6 @@ install -p -m 644 contrib/syntax/nano/Dockerfile.nanorc $RPM_BUILD_ROOT/usr/shar |
| 175 | 175 |
%files |
| 176 | 176 |
%doc AUTHORS CHANGELOG.md CONTRIBUTING.md LICENSE MAINTAINERS NOTICE README.md |
| 177 | 177 |
/%{_bindir}/docker
|
| 178 |
-/%{_libexecdir}/docker/dockerinit
|
|
| 179 | 178 |
/%{_sysconfdir}/udev/rules.d/80-docker.rules
|
| 180 | 179 |
%if 0%{?is_systemd}
|
| 181 | 180 |
/%{_unitdir}/docker.service
|
| 182 | 181 |
deleted file mode 100644 |
| ... | ... |
@@ -1,33 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
-set -e |
|
| 3 |
- |
|
| 4 |
-IAMSTATIC="true" |
|
| 5 |
-source "${MAKEDIR}/.go-autogen"
|
|
| 6 |
- |
|
| 7 |
-# dockerinit still needs to be a static binary, even if docker is dynamic |
|
| 8 |
-go build \ |
|
| 9 |
- -o "$DEST/dockerinit-$VERSION" \ |
|
| 10 |
- "${BUILDFLAGS[@]}" \
|
|
| 11 |
- -ldflags " |
|
| 12 |
- $LDFLAGS |
|
| 13 |
- $LDFLAGS_STATIC |
|
| 14 |
- -extldflags \"$EXTLDFLAGS_STATIC\" |
|
| 15 |
- " \ |
|
| 16 |
- ./dockerinit |
|
| 17 |
- |
|
| 18 |
-echo "Created binary: $DEST/dockerinit-$VERSION" |
|
| 19 |
-ln -sf "dockerinit-$VERSION" "$DEST/dockerinit" |
|
| 20 |
- |
|
| 21 |
-sha1sum= |
|
| 22 |
-if command -v sha1sum &> /dev/null; then |
|
| 23 |
- sha1sum=sha1sum |
|
| 24 |
-elif command -v shasum &> /dev/null; then |
|
| 25 |
- # Mac OS X - why couldn't they just use the same command name and be happy? |
|
| 26 |
- sha1sum=shasum |
|
| 27 |
-else |
|
| 28 |
- echo >&2 'error: cannot find sha1sum command or equivalent' |
|
| 29 |
- exit 1 |
|
| 30 |
-fi |
|
| 31 |
- |
|
| 32 |
-# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another |
|
| 33 |
-export DOCKER_INITSHA1=$($sha1sum "$DEST/dockerinit-$VERSION" | cut -d' ' -f1) |
| 34 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,31 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
-set -e |
|
| 3 |
- |
|
| 4 |
-IAMSTATIC="true" |
|
| 5 |
-source "${MAKEDIR}/.go-autogen"
|
|
| 6 |
- |
|
| 7 |
-# dockerinit still needs to be a static binary, even if docker is dynamic |
|
| 8 |
-go build --compiler=gccgo \ |
|
| 9 |
- -o "$DEST/dockerinit-$VERSION" \ |
|
| 10 |
- "${BUILDFLAGS[@]}" \
|
|
| 11 |
- --gccgoflags " |
|
| 12 |
- -g |
|
| 13 |
- -Wl,--no-export-dynamic |
|
| 14 |
- $EXTLDFLAGS_STATIC |
|
| 15 |
- -lnetgo |
|
| 16 |
- " \ |
|
| 17 |
- ./dockerinit |
|
| 18 |
- |
|
| 19 |
-echo "Created binary: $DEST/dockerinit-$VERSION" |
|
| 20 |
-ln -sf "dockerinit-$VERSION" "$DEST/dockerinit" |
|
| 21 |
- |
|
| 22 |
-sha1sum= |
|
| 23 |
-if command -v sha1sum &> /dev/null; then |
|
| 24 |
- sha1sum=sha1sum |
|
| 25 |
-else |
|
| 26 |
- echo >&2 'error: cannot find sha1sum command or equivalent' |
|
| 27 |
- exit 1 |
|
| 28 |
-fi |
|
| 29 |
- |
|
| 30 |
-# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another |
|
| 31 |
-export DOCKER_INITSHA1=$($sha1sum "$DEST/dockerinit-$VERSION" | cut -d' ' -f1) |
| ... | ... |
@@ -14,10 +14,7 @@ const ( |
| 14 | 14 |
GitCommit string = "$GITCOMMIT" |
| 15 | 15 |
Version string = "$VERSION" |
| 16 | 16 |
BuildTime string = "$BUILDTIME" |
| 17 |
- |
|
| 18 | 17 |
IAmStatic string = "${IAMSTATIC:-true}"
|
| 19 |
- InitSHA1 string = "$DOCKER_INITSHA1" |
|
| 20 |
- InitPath string = "$DOCKER_INITPATH" |
|
| 21 | 18 |
) |
| 22 | 19 |
// AUTOGENERATED FILE; see $BASH_SOURCE |
| 23 | 20 |
DVEOF |
| ... | ... |
@@ -44,9 +41,9 @@ When make binary is run, the Dockerfile prepares the build environment by: |
| 44 | 44 |
|
| 45 | 45 |
make.sh invokes hack/make/.go-autogen to: |
| 46 | 46 |
|
| 47 |
- - Run rsrc to create a binary file (autogen/winresources/rsrc.syso) that |
|
| 48 |
- contains the manifest and icon. This file is automatically picked up by |
|
| 49 |
- 'go build', so no post-processing steps are required. The sources for |
|
| 47 |
+ - Run rsrc to create a binary file (autogen/winresources/rsrc.syso) that |
|
| 48 |
+ contains the manifest and icon. This file is automatically picked up by |
|
| 49 |
+ 'go build', so no post-processing steps are required. The sources for |
|
| 50 | 50 |
rsrc.syso are under hack/make/.resources-windows. |
| 51 | 51 |
|
| 52 | 52 |
*/ |
| ... | ... |
@@ -1,16 +1,6 @@ |
| 1 | 1 |
#!/bin/bash |
| 2 | 2 |
set -e |
| 3 | 3 |
|
| 4 |
-if [ -z "$DOCKER_CLIENTONLY" ]; then |
|
| 5 |
- source "${MAKEDIR}/.dockerinit"
|
|
| 6 |
- |
|
| 7 |
- hash_files "$DEST/dockerinit-$VERSION" |
|
| 8 |
-else |
|
| 9 |
- # DOCKER_CLIENTONLY must be truthy, so we don't need to bother with dockerinit :) |
|
| 10 |
- export DOCKER_INITSHA1="" |
|
| 11 |
-fi |
|
| 12 |
-# DOCKER_INITSHA1 is exported so that other bundlescripts can easily access it later without recalculating it |
|
| 13 |
- |
|
| 14 | 4 |
( |
| 15 | 5 |
export IAMSTATIC="false" |
| 16 | 6 |
export LDFLAGS_STATIC_DOCKER='' |
| ... | ... |
@@ -1,16 +1,6 @@ |
| 1 | 1 |
#!/bin/bash |
| 2 | 2 |
set -e |
| 3 | 3 |
|
| 4 |
-if [ -z "$DOCKER_CLIENTONLY" ]; then |
|
| 5 |
- source "${MAKEDIR}/.dockerinit-gccgo"
|
|
| 6 |
- |
|
| 7 |
- hash_files "$DEST/dockerinit-$VERSION" |
|
| 8 |
-else |
|
| 9 |
- # DOCKER_CLIENTONLY must be truthy, so we don't need to bother with dockerinit :) |
|
| 10 |
- export DOCKER_INITSHA1="" |
|
| 11 |
-fi |
|
| 12 |
-# DOCKER_INITSHA1 is exported so that other bundlescripts can easily access it later without recalculating it |
|
| 13 |
- |
|
| 14 | 4 |
( |
| 15 | 5 |
export IAMSTATIC="false" |
| 16 | 6 |
export EXTLDFLAGS_STATIC='' |
| ... | ... |
@@ -27,10 +27,10 @@ func (s *DockerSuite) TestDiffFilenameShownInOutput(c *check.C) {
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 | 29 |
// test to ensure GH #3840 doesn't occur any more |
| 30 |
-func (s *DockerSuite) TestDiffEnsureDockerinitFilesAreIgnored(c *check.C) {
|
|
| 30 |
+func (s *DockerSuite) TestDiffEnsureInitLayerFilesAreIgnored(c *check.C) {
|
|
| 31 | 31 |
testRequires(c, DaemonIsLinux) |
| 32 | 32 |
// this is a list of files which shouldn't show up in `docker diff` |
| 33 |
- dockerinitFiles := []string{"/etc/resolv.conf", "/etc/hostname", "/etc/hosts", "/.dockerinit", "/.dockerenv"}
|
|
| 33 |
+ initLayerFiles := []string{"/etc/resolv.conf", "/etc/hostname", "/etc/hosts", "/.dockerenv"}
|
|
| 34 | 34 |
containerCount := 5 |
| 35 | 35 |
|
| 36 | 36 |
// we might not run into this problem from the first run, so start a few containers |
| ... | ... |
@@ -41,7 +41,7 @@ func (s *DockerSuite) TestDiffEnsureDockerinitFilesAreIgnored(c *check.C) {
|
| 41 | 41 |
cleanCID := strings.TrimSpace(out) |
| 42 | 42 |
out, _ = dockerCmd(c, "diff", cleanCID) |
| 43 | 43 |
|
| 44 |
- for _, filename := range dockerinitFiles {
|
|
| 44 |
+ for _, filename := range initLayerFiles {
|
|
| 45 | 45 |
c.Assert(out, checker.Not(checker.Contains), filename) |
| 46 | 46 |
} |
| 47 | 47 |
} |
| ... | ... |
@@ -224,7 +224,6 @@ const ( |
| 224 | 224 |
43 16 0:34 / /proc/fs/nfsd rw,nosuid,nodev,noexec,relatime - nfsd nfsd rw |
| 225 | 225 |
44 15 0:35 / /home/tianon/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=1000,group_id=1000 |
| 226 | 226 |
68 15 0:3336 / /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd rw,relatime - aufs none rw,si=9b4a7640128db39c |
| 227 |
-85 68 8:6 /var/lib/docker/init/dockerinit-0.7.2-dev//deleted /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/.dockerinit rw,noatime,nodiratime - ext4 /dev/sda6 rw,data=ordered |
|
| 228 | 227 |
86 68 8:6 /var/lib/docker/containers/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/config.env /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/.dockerenv rw,noatime,nodiratime - ext4 /dev/sda6 rw,data=ordered |
| 229 | 228 |
87 68 8:6 /etc/resolv.conf /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/etc/resolv.conf rw,noatime,nodiratime - ext4 /dev/sda6 rw,data=ordered |
| 230 | 229 |
88 68 8:6 /var/lib/docker/containers/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/hostname /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/etc/hostname rw,noatime,nodiratime - ext4 /dev/sda6 rw,data=ordered |
| ... | ... |
@@ -1,124 +1,17 @@ |
| 1 | 1 |
package utils |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "crypto/sha1" |
|
| 5 |
- "encoding/hex" |
|
| 6 | 4 |
"fmt" |
| 7 |
- "io" |
|
| 8 | 5 |
"io/ioutil" |
| 9 | 6 |
"os" |
| 10 |
- "os/exec" |
|
| 11 |
- "path/filepath" |
|
| 12 | 7 |
"runtime" |
| 13 | 8 |
"strings" |
| 14 | 9 |
|
| 15 | 10 |
"github.com/docker/distribution/registry/api/errcode" |
| 16 |
- "github.com/docker/docker/dockerversion" |
|
| 17 | 11 |
"github.com/docker/docker/pkg/archive" |
| 18 | 12 |
"github.com/docker/docker/pkg/stringid" |
| 19 | 13 |
) |
| 20 | 14 |
|
| 21 |
-// SelfPath figures out the absolute path of our own binary (if it's still around). |
|
| 22 |
-func SelfPath() string {
|
|
| 23 |
- path, err := exec.LookPath(os.Args[0]) |
|
| 24 |
- if err != nil {
|
|
| 25 |
- if os.IsNotExist(err) {
|
|
| 26 |
- return "" |
|
| 27 |
- } |
|
| 28 |
- if execErr, ok := err.(*exec.Error); ok && os.IsNotExist(execErr.Err) {
|
|
| 29 |
- return "" |
|
| 30 |
- } |
|
| 31 |
- panic(err) |
|
| 32 |
- } |
|
| 33 |
- path, err = filepath.Abs(path) |
|
| 34 |
- if err != nil {
|
|
| 35 |
- if os.IsNotExist(err) {
|
|
| 36 |
- return "" |
|
| 37 |
- } |
|
| 38 |
- panic(err) |
|
| 39 |
- } |
|
| 40 |
- return path |
|
| 41 |
-} |
|
| 42 |
- |
|
| 43 |
-func dockerInitSha1(target string) string {
|
|
| 44 |
- f, err := os.Open(target) |
|
| 45 |
- if err != nil {
|
|
| 46 |
- return "" |
|
| 47 |
- } |
|
| 48 |
- defer f.Close() |
|
| 49 |
- h := sha1.New() |
|
| 50 |
- _, err = io.Copy(h, f) |
|
| 51 |
- if err != nil {
|
|
| 52 |
- return "" |
|
| 53 |
- } |
|
| 54 |
- return hex.EncodeToString(h.Sum(nil)) |
|
| 55 |
-} |
|
| 56 |
- |
|
| 57 |
-func isValidDockerInitPath(target string, selfPath string) bool { // target and selfPath should be absolute (InitPath and SelfPath already do this)
|
|
| 58 |
- if target == "" {
|
|
| 59 |
- return false |
|
| 60 |
- } |
|
| 61 |
- if dockerversion.IAmStatic == "true" {
|
|
| 62 |
- if selfPath == "" {
|
|
| 63 |
- return false |
|
| 64 |
- } |
|
| 65 |
- if target == selfPath {
|
|
| 66 |
- return true |
|
| 67 |
- } |
|
| 68 |
- targetFileInfo, err := os.Lstat(target) |
|
| 69 |
- if err != nil {
|
|
| 70 |
- return false |
|
| 71 |
- } |
|
| 72 |
- selfPathFileInfo, err := os.Lstat(selfPath) |
|
| 73 |
- if err != nil {
|
|
| 74 |
- return false |
|
| 75 |
- } |
|
| 76 |
- return os.SameFile(targetFileInfo, selfPathFileInfo) |
|
| 77 |
- } |
|
| 78 |
- return dockerversion.InitSHA1 != "" && dockerInitSha1(target) == dockerversion.InitSHA1 |
|
| 79 |
-} |
|
| 80 |
- |
|
| 81 |
-// DockerInitPath figures out the path of our dockerinit (which may be SelfPath()) |
|
| 82 |
-func DockerInitPath(localCopy string) string {
|
|
| 83 |
- selfPath := SelfPath() |
|
| 84 |
- if isValidDockerInitPath(selfPath, selfPath) {
|
|
| 85 |
- // if we're valid, don't bother checking anything else |
|
| 86 |
- return selfPath |
|
| 87 |
- } |
|
| 88 |
- var possibleInits = []string{
|
|
| 89 |
- localCopy, |
|
| 90 |
- dockerversion.InitPath, |
|
| 91 |
- filepath.Join(filepath.Dir(selfPath), "dockerinit"), |
|
| 92 |
- |
|
| 93 |
- // FHS 3.0 Draft: "/usr/libexec includes internal binaries that are not intended to be executed directly by users or shell scripts. Applications may use a single subdirectory under /usr/libexec." |
|
| 94 |
- // https://www.linuxbase.org/betaspecs/fhs/fhs.html#usrlibexec |
|
| 95 |
- "/usr/libexec/docker/dockerinit", |
|
| 96 |
- "/usr/local/libexec/docker/dockerinit", |
|
| 97 |
- |
|
| 98 |
- // FHS 2.3: "/usr/lib includes object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts." |
|
| 99 |
- // https://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html#USRLIBLIBRARIESFORPROGRAMMINGANDPA |
|
| 100 |
- "/usr/lib/docker/dockerinit", |
|
| 101 |
- "/usr/local/lib/docker/dockerinit", |
|
| 102 |
- } |
|
| 103 |
- for _, dockerInit := range possibleInits {
|
|
| 104 |
- if dockerInit == "" {
|
|
| 105 |
- continue |
|
| 106 |
- } |
|
| 107 |
- path, err := exec.LookPath(dockerInit) |
|
| 108 |
- if err == nil {
|
|
| 109 |
- path, err = filepath.Abs(path) |
|
| 110 |
- if err != nil {
|
|
| 111 |
- // LookPath already validated that this file exists and is executable (following symlinks), so how could Abs fail? |
|
| 112 |
- panic(err) |
|
| 113 |
- } |
|
| 114 |
- if isValidDockerInitPath(path, selfPath) {
|
|
| 115 |
- return path |
|
| 116 |
- } |
|
| 117 |
- } |
|
| 118 |
- } |
|
| 119 |
- return "" |
|
| 120 |
-} |
|
| 121 |
- |
|
| 122 | 15 |
var globalTestID string |
| 123 | 16 |
|
| 124 | 17 |
// TestDirectory creates a new temporary directory and returns its path. |