From: Andrej Shadura Date: Tue, 24 Jan 2023 10:11:13 +0100 Subject: Detect and workaround fakeroot or pseudo With fakeroot, podman and toolbox try to do root things and fail. --- src/cmd/root.go | 4 ++-- src/pkg/utils/utils.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -136,7 +136,7 @@ logrus.Debugf("Running as real user ID %s", currentUser.Uid) logrus.Debugf("Resolved absolute path to the executable as %s", executable) - if !utils.IsInsideContainer() { + if !utils.IsInsideContainer() && !utils.IsInFakeroot() { logrus.Debugf("Running on a cgroups v%d host", cgroupsVersion) if currentUser.Uid != "0" { @@ -214,7 +214,7 @@ func migrate() error { logrus.Debug("Migrating to newer Podman") - if utils.IsInsideContainer() { + if utils.IsInsideContainer() || utils.IsInFakeroot() { return nil } --- a/src/pkg/utils/utils.go +++ b/src/pkg/utils/utils.go @@ -693,6 +693,11 @@ return matched } +func IsInFakeroot() bool { + return strings.Contains(os.Getenv("LD_PRELOAD"), "libfakeroot") || + strings.Contains(os.Getenv("LD_PRELOAD"), "libpseudo") +} + func IsInsideContainer() bool { return PathExists("/run/.containerenv") }