mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
SELinux: fix ENOTSUP errors not being detected when relabeling
Commit12c7541f1f
updated the opencontainers/selinux dependency to v1.3.1, which had a breaking change in the errors that were returned. Before v1.3.1, the "raw" `syscall.ENOTSUP` was returned if the underlying filesystem did not support xattrs, but later versions wrapped the error, which caused our detection to fail. This patch uses `errors.Is()` to check for the underlying error. This requires github.com/pkg/errors v0.9.1 or above (older versions could use `errors.Cause()`, but are not compatible with "native" wrapping of errors in Go 1.13 and up, and could potentially cause these errors to not being detected again. Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit49f8a4224c
) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c4c6cf6b6a
commit
57f6c9a0ef
2 changed files with 2 additions and 3 deletions
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/opencontainers/selinux/go-selinux/label"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -147,7 +146,7 @@ func (container *Container) CopyImagePathContent(v volume.Volume, destination st
|
|||
logrus.Warnf("error while unmounting volume %s: %v", v.Name(), err)
|
||||
}
|
||||
}()
|
||||
if err := label.Relabel(path, container.MountLabel, true); err != nil && err != unix.ENOTSUP {
|
||||
if err := label.Relabel(path, container.MountLabel, true); err != nil && !errors.Is(err, syscall.ENOTSUP) {
|
||||
return err
|
||||
}
|
||||
return copyExistingContents(rootfs, path)
|
||||
|
|
|
@ -113,7 +113,7 @@ func (m *MountPoint) Setup(mountLabel string, rootIDs idtools.Identity, checkFun
|
|||
return
|
||||
}
|
||||
err = label.Relabel(sourcePath, mountLabel, label.IsShared(m.Mode))
|
||||
if err == syscall.ENOTSUP {
|
||||
if errors.Is(err, syscall.ENOTSUP) {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue