pkg/overlay: add a MountLabel flag to Options
Add a way to pass a "set the SELinux contexts" labels to MountWithOptions. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> Signed-off-by: David Shea <dshea@redhat.com> Signed-off-by: Vivek Naruka <vnaruka@redhat.com>
This commit is contained in:
parent
6015a6929c
commit
b9b2969bb6
|
|
@ -15,6 +15,8 @@ import (
|
||||||
"github.com/containers/storage/pkg/system"
|
"github.com/containers/storage/pkg/system"
|
||||||
"github.com/containers/storage/pkg/unshare"
|
"github.com/containers/storage/pkg/unshare"
|
||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
|
"github.com/opencontainers/selinux/go-selinux/label"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
@ -55,6 +57,8 @@ type Options struct {
|
||||||
// attempting to optimize by having the runtime actually mount and
|
// attempting to optimize by having the runtime actually mount and
|
||||||
// manage the overlay filesystem.
|
// manage the overlay filesystem.
|
||||||
ForceMount bool
|
ForceMount bool
|
||||||
|
// MountLabel is a label to force for the overlay filesystem.
|
||||||
|
MountLabel string
|
||||||
}
|
}
|
||||||
|
|
||||||
// TempDir generates an overlay Temp directory in the container content
|
// TempDir generates an overlay Temp directory in the container content
|
||||||
|
|
@ -198,6 +202,9 @@ func MountWithOptions(contentDir, source, dest string, opts *Options) (mount spe
|
||||||
}
|
}
|
||||||
overlayOptions = fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s,private", escapeColon(source), upperDir, workDir)
|
overlayOptions = fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s,private", escapeColon(source), upperDir, workDir)
|
||||||
}
|
}
|
||||||
|
if opts.MountLabel != "" {
|
||||||
|
overlayOptions = overlayOptions + "," + label.FormatMountLabel("", opts.MountLabel)
|
||||||
|
}
|
||||||
|
|
||||||
mountProgram := findMountProgram(opts.GraphOpts)
|
mountProgram := findMountProgram(opts.GraphOpts)
|
||||||
if mountProgram != "" {
|
if mountProgram != "" {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue