Commit graph

2888 commits

Author SHA1 Message Date
Kir Kolyshkin
669056f93d pkg/system.getxattr: handle changed size case
lgetxattr(2) man page says:

> If size is specified as zero, these calls return the  current  size  of
> the  named extended attribute (and leave value unchanged).  This can be
> used to determine the size of the buffer that should be supplied  in  a
> subsequent  call.   (But, bear in mind that there is a possibility that
> the attribute value may change between the two calls,  so  that  it  is
> still necessary to check the return status from the second call.)

The current code does not handle the case when the size changes between
the two calls, and the new size is larger.

Fix the above problem, and slightly simplify the code.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-02-26 07:56:12 -08:00
Akihiro Suda
7270d7eb94 fix goimports
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-02-11 22:16:54 +09:00
Sebastiaan van Stijn
9f0b3f5609
bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 00:06:42 +01:00
Hsing-Hui Hsu
c90254c746 Add George Washington Carver to name generator
Signed-off-by: Hsing-Hui Hsu <hsinghui@amazon.com>
2020-01-20 14:59:36 -08:00
Hsing-Hui Hsu
ac1d8bc760 Add Mae Jemison to name generator
Signed-off-by: Hsing-Hui Hsu <hsinghui@amazon.com>
2020-01-20 14:57:32 -08:00
Akihiro Suda
409bbdc321 cgroup2: enable resource limitation
enable resource limitation by disabling cgroup v1 warnings

resource limitation still doesn't work with rootless mode (even with systemd mode)

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-01-01 02:58:40 +09:00
Brian Goff
8d2456d1e6
Merge pull request #40246 from thaJeztah/system_windows_cleanup
pkg/system: minor cleanups and remove use of deprecated system.GetOSVersion()
2019-12-19 11:36:29 -08:00
Brian Goff
db85ef598b
Merge pull request #40247 from thaJeztah/pkg_system_consts
pkg/system: deprecate constants in favor of golang.org/x/sys/windows
2019-12-19 11:35:00 -08:00
Brian Goff
b95fad8e51
Merge pull request #40263 from thaJeztah/normalize_comments
Normalize comment formatting
2019-12-12 12:06:22 -08:00
Sascha Grunert
4138cd22ab
Fix possible runtime panic in Lgetxattr
If `unix.Lgetxattr` returns an error, then `sz == -1` which will cause a
runtime panic if `errno == unix.ERANGE`.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-12-04 14:26:02 +01:00
Sebastiaan van Stijn
5331e6ab2d
pkg/tailfile: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:42:07 +01:00
Sebastiaan van Stijn
b95fbe7630
pkg/signal: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:41:47 +01:00
Sebastiaan van Stijn
1d97da61a2
pkg/progress: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:41:23 +01:00
Sebastiaan van Stijn
e2addf46bf
pkg/mount: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:40:58 +01:00
Sebastiaan van Stijn
0b155db389
pkg/jsonmessage: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:40:39 +01:00
Sebastiaan van Stijn
a45b3a92f6
pkg/idtools: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:40:23 +01:00
Sebastiaan van Stijn
14cad10cea
pkg/containerfs: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:39:57 +01:00
Sebastiaan van Stijn
9de5d3da89
pkg/chrootarchive: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:39:12 +01:00
Sebastiaan van Stijn
ecb898dcb9
pkg/archive: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:38:49 +01:00
Sebastiaan van Stijn
0fb5630784
pkg/system: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:38:17 +01:00
Sebastiaan van Stijn
f572df7c22
pkg/system: deprecate constants in favor of golang.org/x/sys/windows
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-25 15:39:34 +01:00
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