Commit Graph

42 Commits

Author SHA1 Message Date
Maksym Pavlenko
3bc8fc4d30 Cleanup build constraints
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-12-08 09:36:20 -08:00
Justin Terry
de3d9993f5 Adds support for Windows ArgsEscaped images
Adds support for Windows container images built by Docker
that contain the ArgsEscaped boolean in the ImageConfig. This
is a non-OCI entry that tells the runtime that the Entrypoint
and/or Cmd are a single element array with the args pre-escaped
into a single CommandLine that should be passed directly to
Windows rather than passed as an args array which will be
additionally escaped.

Signed-off-by: Justin Terry <jlterry@amazon.com>
2022-03-01 13:40:44 -08:00
Mikko Ylinen
e0f8c04dad cri: Devices ownership from SecurityContext
CRI container runtimes mount devices (set via kubernetes device plugins)
to containers by taking the host user/group IDs (uid/gid) to the
corresponding container device.

This triggers a problem when trying to run those containers with
non-zero (root uid/gid = 0) uid/gid set via runAsUser/runAsGroup:
the container process has no permission to use the device even when
its gid is permissive to non-root users because the container user
does not belong to that group.

It is possible to workaround the problem by manually adding the device
gid(s) to supplementalGroups. However, this is also problematic because
the device gid(s) may have different values depending on the workers'
distro/version in the cluster.

This patch suggests to take RunAsUser/RunAsGroup set via SecurityContext
as the device UID/GID, respectively. The feature must be enabled by
setting device_ownership_from_security_context runtime config value to
true (valid on Linux only).

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2021-08-30 09:30:00 +03:00
Akihiro Suda
d3aa7ee9f0
Run go fmt with Go 1.17
The new `go fmt` adds `//go:build` lines (https://golang.org/doc/go1.17#tools).

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-08-22 09:31:50 +09: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
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
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
Michael Crosby
02afa94256 Add --cpus flag to ctr
Signed-off-by: Michael Crosby <michael@thepasture.io>
2020-07-28 23:06:07 -04: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
725d3ad8cb Add --device flag to ctr
Closes #3066

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-07-18 18:51:05 +00:00
Justin Terry (VM)
c818a6b13d Merges the oci package for Linux and Windows
On Windows we need to be able to create both Linux and Windows OCI spec
files by default to support WCOW and LCOW scenarios. This merges the
compile time differences into runtime differences between the two based
on the spec and platform the user sets.

It maintains the old behavior with Default specs resulting in the
platform default the binary is compiled for.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-30 09:46:04 -07:00
Michael Crosby
4b9b3e8fc9 Add WithAmbientCapabilities opt
Closes #2516

This can be used for non-root users binding to low ports.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-27 17:16:44 -04:00
kadisi
7dae56671d set args value of process if args is nil
Signed-off-by: kadisi <iamkadisi@163.com>
2018-08-21 09:44:50 +08:00
Michael Crosby
b67ea850af Add opt for default unix device permissions
These opts either inherit the parent cgroup device.list or append the
default unix devices like /dev/null /dev/random so that the container
has access.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-15 11:52:43 -04:00
Ian Campbell
4a74731cd0 oci: Update docs for oci.WithUserID
The behaviour was changed in 99df1a9e11 ("Set gid 0 when no group is
specified"), part of #2529.

Take the opportunity to tighten up the grammar a bit too.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2018-08-08 15:32:59 +01:00
Michael Crosby
99df1a9e11 Set gid 0 when no group is specified
This change is to match Docker's implementaion of setting gid and groups
to 0 when no gid is specified but an explicit uid is set.

Fixes #2527

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-06 15:08:59 -04:00
Michael Crosby
e956441fe0 Add WithImageConfigArgs to replace CMD on image
This allows users to provide args for the process arguments while
creating the base spec with an image.  It provides the same symantics as
Docker where additional args replace the CMD while leaving the
ENTRYPOINT the same.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-27 12:09:11 -04:00
Akihiro Suda
d88de4a34f content: change Writer/ReaderAt to take OCI
This change allows implementations to resolve the location of the actual data
using OCI descriptor fields such as MediaType.

No OCI descriptor field is written to the store.

No change on gRPC API.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-06-01 11:51:43 +09:00
Michael Crosby
62e22a9fe7 Type alias spec in oci package
This allows Go to build third party packages correctly without vendoring
issues what want to create their own SpecOpts.

Fixes #2289

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-05-17 09:18:46 -04:00
Justin Cormack
062c3a00ef
Add a WithPrivileged OCI constructor and the options needed to build it
Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2018-04-04 13:25:34 +01:00
Justin Cormack
0ee2f35e43
Consistently add empty types where they are nil in spec
In a few places we check for nil types when modifying a spec,
but in many cases we do not so we could get a panic if the
passed in type was not filled. Because the generated spec is
filled we will not notice this but users may get unexpected
panics.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2018-04-03 14:44:23 +01:00
Lantao Liu
00b600a605 Improve WithUser comments and code style.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-03-30 20:34:12 +00:00
Lantao Liu
45b0045593 Add oci.WithUser helper function.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-03-30 20:06:25 +00:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00
Brian Goff
c776b6d8d9 Use continuity fs package
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-02-07 12:40:52 -05:00
Michael Crosby
d179c61231 Revert "Use jsoniteer for faster json encoding/decoding"
This reverts commit 4233b87b89.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-01-29 15:47:48 -05:00
Michael Crosby
4233b87b89 Use jsoniteer for faster json encoding/decoding
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-01-26 16:32:55 -05:00
Michael Crosby
4e27c4d53d Add WithAllCapabilities as spec opt
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-01-26 14:31:32 -05:00
Michael Crosby
1f5ce14a82 Support getting uid/gid from rootfs path
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-01-16 14:48:29 -05:00
Michael Crosby
5b042945b0 Refactor get uid/gid from path
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-01-16 12:01:31 -05:00
Akihiro Suda
1645d8406d oci: simplify WithImageConfig
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-01-12 15:46:53 +09:00
Akihiro Suda
b99dc56817 oci: add TODO comments
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-01-12 15:36:18 +09:00
Akihiro Suda
369d7c9545 oci: fix err variable scope
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-01-12 15:36:18 +09:00
Derek McGowan
dfd7ee122f
Clean up error logs and messages in temp mount
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-01-05 15:37:11 -08:00
yanxuean
cb58bb885a solve incorrect unmount
1. add WithTempMount for better unmount and remove
2. solve incorrect unmount for
   diff.DiffMounts,
   diff.Apply,
   oci.WithUsername,
   oci.WithUserID,
   remapRootFS

Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
2018-01-06 00:28:16 +08:00
Michael Crosby
a8b543f87d rmdir tmp dirs for rootfs mounts
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-12-04 13:51:11 -05:00
Michael Crosby
b0ca685874 Retry unmount on EBUSY and return errors
This is another WIP to fix #1785.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-12-04 11:31:08 -05:00
Michael Crosby
a4a4c90ed3 Use strconv.Atoi for uid/gid parsing
This follows the same logic that runc uses for parsing uid/gid values.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-11-30 15:22:41 -05:00
Stephen J Day
0d957b1da5
oci: allocate process if not already set
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-27 17:36:43 -08:00
Daniel Nephin
f6e877e8be Proposed fix for image content store
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-27 16:16:17 -05:00
Daniel Nephin
081f8c7ce0 oci package passing tests
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-27 16:14:43 -05:00