Skip to content

Commit

Permalink
Merge pull request #4051 from rancher/selinux
Browse files Browse the repository at this point in the history
Use spec's mountLabel when mounting the rootfs
  • Loading branch information
estesp authored Feb 24, 2020
2 parents 2c5279e + c134a9b commit 3b9f2e8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
prototypes "github.com/gogo/protobuf/types"
ver "github.com/opencontainers/image-spec/specs-go"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -242,7 +243,17 @@ func (c *container) NewTask(ctx context.Context, ioCreate cio.Creator, opts ...N
if err != nil {
return nil, err
}
spec, err := c.Spec(ctx)
if err != nil {
return nil, err
}
for _, m := range mounts {
if spec.Linux != nil && spec.Linux.MountLabel != "" {
context := label.FormatMountLabel("", spec.Linux.MountLabel)
if context != "" {
m.Options = append(m.Options, context)
}
}
request.Rootfs = append(request.Rootfs, &types.Mount{
Type: m.Type,
Source: m.Source,
Expand Down

0 comments on commit 3b9f2e8

Please sign in to comment.