Merge pull request #46722 from thaJeztah/dedup_additionalgroups

daemon: remove redundant withResetAdditionalGIDs option
This commit is contained in:
Sebastiaan van Stijn 2023-10-25 22:48:19 +02:00 committed by GitHub
commit 4776a9e6fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,6 @@ import (
"context" "context"
"github.com/containerd/containerd" "github.com/containerd/containerd"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/oci" "github.com/containerd/containerd/oci"
coci "github.com/containerd/containerd/oci" coci "github.com/containerd/containerd/oci"
"github.com/containerd/containerd/pkg/apparmor" "github.com/containerd/containerd/pkg/apparmor"
@ -14,13 +13,6 @@ import (
specs "github.com/opencontainers/runtime-spec/specs-go" specs "github.com/opencontainers/runtime-spec/specs-go"
) )
func withResetAdditionalGIDs() oci.SpecOpts {
return func(_ context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error {
s.Process.User.AdditionalGids = nil
return nil
}
}
func getUserFromContainerd(ctx context.Context, containerdCli *containerd.Client, ec *container.ExecConfig) (specs.User, error) { func getUserFromContainerd(ctx context.Context, containerdCli *containerd.Client, ec *container.ExecConfig) (specs.User, error) {
ctr, err := containerdCli.LoadContainer(ctx, ec.Container.ID) ctr, err := containerdCli.LoadContainer(ctx, ec.Container.ID)
if err != nil { if err != nil {
@ -39,7 +31,6 @@ func getUserFromContainerd(ctx context.Context, containerdCli *containerd.Client
opts := []oci.SpecOpts{ opts := []oci.SpecOpts{
coci.WithUser(ec.User), coci.WithUser(ec.User),
withResetAdditionalGIDs(),
coci.WithAdditionalGIDs(ec.User), coci.WithAdditionalGIDs(ec.User),
coci.WithAppendAdditionalGroups(ec.Container.HostConfig.GroupAdd...), coci.WithAppendAdditionalGroups(ec.Container.HostConfig.GroupAdd...),
} }