diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-02-13 21:42:18 -0500 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-02-13 21:42:57 -0500 |
commit | b4fa6f4f0819bcc0b85a5215564b937c374f315c (patch) | |
tree | 415ded3f8671a72252a5252391f32d9751ebe7a2 /libpod/util_linux.go | |
parent | 0c060dace19710716ff8f3a65865a295312d9d94 (diff) | |
download | podman-b4fa6f4f0819bcc0b85a5215564b937c374f315c.tar.gz podman-b4fa6f4f0819bcc0b85a5215564b937c374f315c.tar.bz2 podman-b4fa6f4f0819bcc0b85a5215564b937c374f315c.zip |
Fix SELinux labels of volumes
If we attempt to label a volume and the file system
does not support labeling, then just warn. SELinux
may or may not work, on the volume.
There is no way to setup a private label on a newly
created volume without using the container mountlabel.
If we don't have a mount label at the time of creation of
the volume, the only option we have is to create a shared
label.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/util_linux.go')
-rw-r--r-- | libpod/util_linux.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libpod/util_linux.go b/libpod/util_linux.go index 631f6836c..f0b4028de 100644 --- a/libpod/util_linux.go +++ b/libpod/util_linux.go @@ -92,7 +92,7 @@ func assembleSystemdCgroupName(baseSlice, newSlice string) (string, error) { // LabelVolumePath takes a mount path for a volume and gives it an // selinux label of either shared or not -func LabelVolumePath(path string, shared bool) error { +func LabelVolumePath(path string) error { _, mountLabel, err := label.InitLabels([]string{}) if err != nil { return errors.Wrapf(err, "error getting default mountlabels") @@ -100,12 +100,13 @@ func LabelVolumePath(path string, shared bool) error { if err := label.ReleaseLabel(mountLabel); err != nil { return errors.Wrapf(err, "error releasing label %q", mountLabel) } - if err := label.Relabel(path, mountLabel, shared); err != nil { - permString := "private" - if shared { - permString = "shared" + + if err := label.Relabel(path, mountLabel, true); err != nil { + if err != syscall.ENOTSUP { + logrus.Debugf("Labeling not supported on %q", path) + } else { + return errors.Wrapf(err, "error setting selinux label for %s to %q as shared", path, mountLabel) } - return errors.Wrapf(err, "error setting selinux label for %s to %q as %s", path, mountLabel, permString) } return nil } |