8000 oci: deprecate SetCapabilities · moby/moby@e939d54 · GitHub
[go: up one dir, main page]

Skip to content

Commit e939d54

Browse files
committed
oci: deprecate SetCapabilities
rewrite daemon.WithCapabilities using c8d's oci.WithCapabilities. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 2e39b1c commit e939d54

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

daemon/oci_linux.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,20 @@ func WithApparmor(c *container.Container) coci.SpecOpts {
153153
}
154154
}
155155

156-
// WithCapabilities sets the container's capabilities
157-
func WithCapabilities(c *container.Container) coci.SpecOpts {
158-
return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
156+
// WithCapabilities adjusts the container's capabilities based on the
157+
// "CapAdd", "CapDrop", and "Privileged" fields in the container's HostConfig.
158+
func WithCapabilities(ctr *container.Container) coci.SpecOpts {
159+
return func(ctx context.Context, client coci.Client, c *containers.Container, s *specs.Spec) (err error) {
159160
capabilities, err := caps.TweakCapabilities(
160161
caps.DefaultCapabilities(),
161-
c.HostConfig.CapAdd,
162-
c.HostConfig.CapDrop,
163-
c.HostConfig.Privileged,
162+
ctr.HostConfig.CapAdd,
163+
ctr.HostConfig.CapDrop,
164+
ctr.HostConfig.Privileged,
164165
)
165166
if err != nil {
166167
return err
167168
}
168-
return oci.SetCapabilities(s, capabilities)
169+
return coci.WithCapabilities(capabilities)(ctx, client, c, s)
169170
}
170171
}
171172

oci/oci.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
var deviceCgroupRuleRegex = lazyregexp.New("^([acb]) ([0-9]+|\\*):([0-9]+|\\*) ([rwm]{1,3})$")
1919

2020
// SetCapabilities sets the provided capabilities on the spec.
21+
//
22+
// Deprecated: this function is no longer used and will be removed in the next release.
2123
func SetCapabilities(s *specs.Spec, caplist []string) error {
2224
if s.Process == nil {
2325
s.Process = &specs.Process{}

0 commit comments

Comments
 (0)
0