From 4b480240573be4cd8fe04505b6a435a6aa454f86 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 16 May 2019 15:55:48 +0200 Subject: unshare: use rootless from libpod Signed-off-by: Giuseppe Scrivano --- cmd/podman/unshare.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/podman/unshare.go b/cmd/podman/unshare.go index 1db647dba..b9ae8dd6b 100644 --- a/cmd/podman/unshare.go +++ b/cmd/podman/unshare.go @@ -6,7 +6,7 @@ import ( "os" "os/exec" - "github.com/containers/buildah/pkg/unshare" + "github.com/containers/libpod/pkg/rootless" "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -30,9 +30,13 @@ func init() { flags.SetInterspersed(false) } +func unshareEnv() []string { + return append(os.Environ(), "_CONTAINERS_USERNS_CONFIGURED=done") +} + // unshareCmd execs whatever using the ID mappings that we want to use for ourselves func unshareCmd(c *cobra.Command, args []string) error { - if isRootless := unshare.IsRootless(); !isRootless { + if isRootless := rootless.IsRootless(); !isRootless { return errors.Errorf("please use unshare with rootless") } // exec the specified command, if there is one @@ -45,10 +49,9 @@ func unshareCmd(c *cobra.Command, args []string) error { args = []string{shell} } cmd := exec.Command(args[0], args[1:]...) - cmd.Env = unshare.RootlessEnv() + cmd.Env = unshareEnv() cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - unshare.ExecRunnable(cmd) - return nil + return cmd.Run() } -- cgit v1.2.3-54-g00ecf