From 807f6f8d8f98422cfcfe7e474e26a985d951af4d Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 31 Aug 2018 09:31:34 +0200 Subject: rootless: check uid with Geteuid() instead of Getuid() change the tests to use chroot to set a numeric UID/GID. Go syscall.Credential doesn't change the effective UID/GID of the process. Signed-off-by: Giuseppe Scrivano Closes: #1372 Approved by: mheon --- cmd/podman/create.go | 4 ++-- cmd/podman/pause.go | 2 +- cmd/podman/run.go | 2 +- cmd/podman/stats.go | 2 +- cmd/podman/unpause.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/create.go b/cmd/podman/create.go index 04f3cd9e6..20d976c0b 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -99,7 +99,7 @@ func createCmd(c *cli.Context) error { storageOpts.UIDMap = mappings.UIDMap storageOpts.GIDMap = mappings.GIDMap - if os.Getuid() != 0 { + if os.Geteuid() != 0 { rootless.SetSkipStorageSetup(true) } @@ -778,7 +778,7 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim } func joinOrCreateRootlessUserNamespace(createConfig *cc.CreateConfig, runtime *libpod.Runtime) (bool, int, error) { - if os.Getuid() == 0 { + if os.Geteuid() == 0 { return false, 0, nil } diff --git a/cmd/podman/pause.go b/cmd/podman/pause.go index e6224dcd2..203fa6070 100644 --- a/cmd/podman/pause.go +++ b/cmd/podman/pause.go @@ -26,7 +26,7 @@ var ( ) func pauseCmd(c *cli.Context) error { - if os.Getuid() != 0 { + if os.Geteuid() != 0 { return errors.New("pause is not supported for rootless containers") } diff --git a/cmd/podman/run.go b/cmd/podman/run.go index d8a8a48d5..3445daef5 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -74,7 +74,7 @@ func runCmd(c *cli.Context) error { storageOpts.UIDMap = mappings.UIDMap storageOpts.GIDMap = mappings.GIDMap - if os.Getuid() != 0 { + if os.Geteuid() != 0 { rootless.SetSkipStorageSetup(true) } diff --git a/cmd/podman/stats.go b/cmd/podman/stats.go index 181f5376c..0e1d2a9c6 100644 --- a/cmd/podman/stats.go +++ b/cmd/podman/stats.go @@ -64,7 +64,7 @@ func statsCmd(c *cli.Context) error { return err } - if os.Getuid() != 0 { + if os.Geteuid() != 0 { return errors.New("stats is not supported for rootless containers") } diff --git a/cmd/podman/unpause.go b/cmd/podman/unpause.go index d4e2605cb..a792aaf6d 100644 --- a/cmd/podman/unpause.go +++ b/cmd/podman/unpause.go @@ -26,7 +26,7 @@ var ( ) func unpauseCmd(c *cli.Context) error { - if os.Getuid() != 0 { + if os.Geteuid() != 0 { return errors.New("unpause is not supported for rootless containers") } -- cgit v1.2.3-54-g00ecf