Commit Graph

104 Commits

Author SHA1 Message Date
Fu Wei
ab963e1cc1
Merge pull request #5063 from Iceber/fix-with-dev-shm-size
oci: fix WithDevShmSize
2021-05-06 23:48:04 +08:00
Sebastiaan van Stijn
9bc8d63c9f
cri/server: use containerd/oci instead of libcontainer/devices
Looks like we had our own copy of the "getDevices" code already, so use
that code (which also matches the code that's used to _generate_ the spec,
so a better match).

Moving the code to a separate file, I also noticed that the _unix and _linux
code was _exactly_ the same (baring some `//nolint:` comments), so also
removing the duplicated code.

With this patch applied, we removed the dependency on the libcontainer/devices
package (leaving only libcontainer/user).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-04-08 23:25:21 +02:00
Akihiro Suda
8ba8533bde
pkg/cri/opts.WithoutRunMount -> oci.WithoutRunMount
Move `pkg/cri/opts.WithoutRunMount` function to `oci.WithoutRunMount`
so that it can be used without dependency on CRI.

Also add `oci.WithoutMounts(dests ...string)` for generality.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-04-07 21:25:36 +09:00
Iceber Gu
b592a4c1ec
oci: fix WithDevShmSize
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-03-17 13:43:58 +08:00
Brian Goff
7776e5ef2a Support adding devices by dir
This enables cases where devices exist in a subdirectory of /dev,
particularly where those device names are not portable across machines,
which makes it problematic to specify from a runtime such as cri.

Added this to `ctr` as well so I could test that the code at least
works.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-03-15 16:42:23 +00:00
Derek McGowan
35eeb24a17
Fix exported comments enforcer in CI
Add comments where missing and fix incorrect comments

Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-03-12 08:47:05 -08:00
Iceber Gu
f7f6aabfff oci: fix superfluous slice operations
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-02-26 02:35:25 +08:00
Phil Estes
757be0a090
Merge pull request #5017 from AkihiroSuda/parse-cap
oci.WithPrivileged: set the current caps, not the known caps
2021-02-23 09:10:57 -05:00
Akihiro Suda
51f985cb1f
oci: move cap UT to _linux_test.go
No substantial code change

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-02-10 17:42:18 +09:00
Iceber Gu
d08aa4b681
oci: fix the file mode of the device
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-02-10 16:37:12 +08:00
Akihiro Suda
a2d1a8a865
oci.WithPrivileged: set the current caps, not the known caps
This change is needed for running the latest containerd inside Docker
that is not aware of the recently added caps (BPF, PERFMON, CHECKPOINT_RESTORE).

Without this change, containerd inside Docker fails to run containers with
"apply caps: operation not permitted" error.

See kubernetes-sigs/kind 2058

NOTE: The caller process of this function is now assumed to be as
privileged as possible.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-02-10 17:14:17 +09:00
Akihiro Suda
8a57d70a50
oci: expose getUserFromPath and getGIDFromPath
These functions are planned to be used for implementing `nerdctl exec --user`.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-12-14 21:53:17 +09:00
Michael Crosby
02afa94256 Add --cpus flag to ctr
Signed-off-by: Michael Crosby <michael@thepasture.io>
2020-07-28 23:06:07 -04:00
Paul "TBBle" Hampson
ca15cb0d81 Fix incorrect (cut-and-paste) method comment
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2020-07-21 19:43:08 +10:00
Kir Kolyshkin
6e638ad27a Nit: fix use of bufio.Scanner.Err
The Err() method should be called after the Scan() loop, not inside it.

Found by: git grep -A3 -F '.Scan()'

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-11 19:36:21 -07:00
Michael Crosby
a3ca8a0dfc Add linux resource oci.SpecOpts
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2020-03-05 13:02:10 -05:00
Jie Hao Liao
51a6813c06 Split uid and gid user ns remapping in oci
Signed-off-by: Jie Hao Liao <liaojh1998@gmail.com>
2019-12-10 03:07:50 -06:00
fahedouch
afd33bce81 test add tests to spec_opts
Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

test func WithDefaultPathEnv & WithDefaultSpecForPlatform

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

fix nil context

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

[test] TTY information && ProcessCwd

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

fix TestWithTTYSize value

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

test WithUserNamespace sets the uid and gid mappings for the task

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

format test file

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

update TestWithUserNamespace check condition

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

relaunch ci

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

improve spec_opts_test test coverage

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>
2019-11-22 18:16:36 +01:00
Michael Crosby
a6d3f4d30b
Add device opts to ctr --privileged
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-10-10 14:23:59 -04:00
Michael Crosby
25947db049 Add support for spec generation with host devices
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-10-07 10:37:58 -04:00
yuxiaobo
a0ae24b984 Word spelling correction
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
2019-09-25 16:49:54 +08:00
Michael Crosby
20d3fae3db Add Opt for modifying shm size
Closes #3654

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-09-18 10:20:36 -04:00
Michael Crosby
fa11147e5f Add --env-file to ctr
Closes #3517

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-09-06 16:25:02 -04:00
chentanjun
8788af7f8d modify-document-duplicate-word
Signed-off-by: chentanjun <2799194073@qq.com>
2019-09-05 09:10:19 +08:00
Phil Estes
bc692cc59d
Use default UNIX env when image has no environment
Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2019-08-29 10:16:24 -04:00
chentanjun
92a5b08a68 fix-grammar-mistake
Signed-off-by: chentanjun <2799194073@qq.com>
2019-08-28 16:10:08 +08:00
Michael Crosby
7379fa6631 Remove the process default ENV
With the change in #3542 it breaks $PATH handling for images becuase our
default spec always sets a PATH on the process's .Env.

This removes the default and adds an Opt to add this back.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-08-19 18:18:58 +00:00
Yangyang
1c30d4d04c bugfix: override image.Env with process.Env, rather than be contrary
Signed-off-by: Yangyang <1032120121@163.com>
2019-08-16 18:53:07 +08:00
wanghuaiqing
d8322e38c7 cast Rdev of Stat_t to uint64 for mips
Signed-off-by: wanghuaiqing <wanghuaiqing@loongson.cn>
2019-08-08 14:24:50 +08:00
Michael Crosby
725d3ad8cb Add --device flag to ctr
Closes #3066

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-07-18 18:51:05 +00:00
Michael Crosby
dca17853d8 Add WithLinuxDevices Opt
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-07-18 17:11:14 +00:00
Lantao Liu
808b223536 Fix race and panic.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-03-28 01:27:13 -07:00
Michael Crosby
388c8a1760 Fastpath opt and ExecProcess loading
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-03-22 12:08:43 -04:00
Michael Crosby
bdd84abf05 Add additional capability handling opts
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-03-15 12:31:41 -04:00
Michael Crosby
84a24711e8 Add runc.v2 multi-shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-02-21 11:09:46 -05:00
Eric Hotinger
0190e5f390 Removes the oci.test.exe binary.
Signed-off-by: Eric Hotinger <ehotinger@gmail.com>
2019-02-07 11:55:20 -08:00
John Howard
59ea134ce1 OCI Modifiers for Windows
Signed-off-by: John Howard <jhoward@microsoft.com>

Needed for the containerd work on Windows and integrating the
oci package from containerd into moby.

No longer sets defaults for
 - .Process.ConsoleSize
 - .Windows.IgnoreFlushesDuringBoot
 - .Windows.Network.AllowUnqualifiedDNSQuery

Adds helper functions and tests for
 - WithWindowsIgnoreFlushesDuringBoot
 - WithWindowNetworksAllowUnqualifiedDNSQuery

Updates `ctr run` on Windows to use the new helper functions,
ConsoleSize is already handled.
2019-02-06 10:44:36 -08:00
akolomentsev
1be86af108 add test for WithImageConfigArgs
Signed-off-by: Andrey Kolomentsev <andrey.kolomentsev@docker.com>
2018-12-20 18:15:24 -08:00
akolomentsev
f2344db40a do not mutate defaults in replaceOrAppendEnvValues
Signed-off-by: Andrey Kolomentsev <andrey.kolomentsev@docker.com>
2018-12-19 16:38:22 -08:00
akolomentsev
da9471fb11 fix oci.WithImageConfigArgs for windows
Signed-off-by: Andrey Kolomentsev <andrey.kolomentsev@docker.com>
2018-12-19 12:25:36 -08:00
Justin Terry (VM)
7ac221e8d7 Adding ctr memory and cpu flags
Adds ctr run --memory-limit for all platforms.
Adds ctr run --cpu-count for Windows platforms.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-12-10 13:31:59 -08:00
Sebastiaan van Stijn
70084ea6c3
Add /proc/asound to masked paths
While looking through the Moby source code was found /proc/asound to be shared
with containers as read-only.

This can lead to two information leaks.

---

**Leak of media playback status of the host**

Steps to reproduce the issue:

 - Listen to music/Play a YouTube video/Do anything else that involves sound
   output
 - Execute docker run --rm ubuntu:latest bash -c "sleep 7; cat
   /proc/asound/card*/pcm*p/sub*/status | grep state | cut -d ' ' -f2 | grep
   RUNNING || echo 'not running'"
 - See that the containerized process is able to check whether someone on the
   host is playing music as it prints RUNNING
 - Stop the music output
 - Execute the command again (The sleep is delaying the output because
   information regarding playback status isn't propagated instantly)
 - See that it outputs not running

**Describe the results you received:**

A containerized process is able to gather information on the playback
status of an audio device governed by the host. Therefore a process of a
container is able to check whether and what kind of user activity is
present on the host system. Also, this may indicate whether a container
runs on a desktop system or a server as media playback rarely happens on
server systems.

The description above is in regard to media playback - when examining
`/proc/asound/card*/pcm*c/sub*/status` (`pcm*c` instead of `pcm*p`) this
can also leak information regarding capturing sound, as in recording
audio or making calls on the host system.

Reported-by: Philipp Schmied <pschmied@mailbox.org>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-11-30 14:27:08 +01:00
Justin Terry (VM)
223acbca2a Skip AdditionalGID's for LCOW oci spec
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-10-03 10:43:29 -07:00
Justin Terry (VM)
547bb94e4b Fix ctr run for Windows containers
1. Fixes bugs in ctr run that were introduced by 1d9b969
2. Adds support for the --isolated flag that runs Windows HyperV
cotainers instead of process isolated containers on Windows.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-20 14:28:36 -07:00
Phil Estes
16b42fce94
Merge pull request #2653 from liyongxin/master
typo fix oci/typo_spec_opts_test
2018-09-20 10:07:00 -04:00
Yongxin Li
03b1dae195 typo fix
Signed-off-by: Yongxin Li <yxli@alauda.io>
2018-09-20 10:56:42 +08:00
Derek McGowan
9faeea1e5e
Merge pull request #2649 from estesp/nonewpriv-flag
Add flag to ctr for running with "NoNewPrivileges: false"
2018-09-19 11:17:05 -07:00
Michael Crosby
94c33d4f94 Add nosuid,noexec,nodev to proc
This is to match the same mount options as the host.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-09-19 13:29:56 -04:00
Yongxin Li
bd902372de typo fix oci/typo_spec_opts_test
Signed-off-by: Yongxin Li <yxli@alauda.io>
2018-09-18 10:33:23 +08:00
Phil Estes
13931e41d6
Add additional GIDs by default if they exist in /etc/group
If we are using an image config, we should by default add any additional
GIDs that are found from reading /etc/group, even if the default user is
root.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2018-09-14 13:28:50 -04:00