From bfa9e61f8f39f736f3222d9644c7de048c5a65fb Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 9 Nov 2020 15:56:48 -0800 Subject: [PATCH] libct/cg/fscommon: log openat2 init failures In case we get ENOSYS from openat2(2), this is expected, so log that we're falling back to using securejoin as debug. Otherwise, log it as a warning (as the error is unexpected, but we're still good to go). Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/fscommon/open.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libcontainer/cgroups/fscommon/open.go b/libcontainer/cgroups/fscommon/open.go index 3858269caa6..0a7e3d95282 100644 --- a/libcontainer/cgroups/fscommon/open.go +++ b/libcontainer/cgroups/fscommon/open.go @@ -7,6 +7,7 @@ import ( securejoin "github.com/cyphar/filepath-securejoin" "github.com/pkg/errors" + "github.com/sirupsen/logrus" "golang.org/x/sys/unix" ) @@ -31,11 +32,17 @@ func prepareOpenat2() error { Flags: unix.O_DIRECTORY | unix.O_PATH}) if err != nil { prepErr = &os.PathError{Op: "openat2", Path: cgroupfsDir, Err: err} + if err != unix.ENOSYS { + logrus.Warnf("falling back to securejoin: %s", prepErr) + } else { + logrus.Debug("openat2 not available, falling back to securejoin") + } return } var st unix.Statfs_t if err = unix.Fstatfs(fd, &st); err != nil { prepErr = &os.PathError{Op: "statfs", Path: cgroupfsDir, Err: err} + logrus.Warnf("falling back to securejoin: %s", prepErr) return }