Commit graph

2867 commits

Author SHA1 Message Date
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