diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2018-08-28 09:14:53 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-28 11:25:01 +0000 |
commit | c33b359ed196102c44ec0b58491d88a7dedd6294 (patch) | |
tree | 3e5b9f34613121b310cfa0bb44cd53a463da355f | |
parent | ec07b2d0216c316ac7b2e0869a4e8af02859509d (diff) | |
download | podman-c33b359ed196102c44ec0b58491d88a7dedd6294.tar.gz podman-c33b359ed196102c44ec0b58491d88a7dedd6294.tar.bz2 podman-c33b359ed196102c44ec0b58491d88a7dedd6294.zip |
rootless, search: do not create a new userns
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #1360
Approved by: vrothberg
-rw-r--r-- | cmd/podman/main.go | 1 | ||||
-rw-r--r-- | cmd/podman/search.go | 7 | ||||
-rw-r--r-- | test/e2e/rootless_test.go | 34 |
3 files changed, 28 insertions, 14 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go index 1fdd5c939..bd1cc8b95 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -32,6 +32,7 @@ var cmdsNotRequiringRootless = map[string]bool{ "login": true, "logout": true, "kill": true, + "search": true, "stop": true, } diff --git a/cmd/podman/search.go b/cmd/podman/search.go index cc18cd1de..2e68e8c21 100644 --- a/cmd/podman/search.go +++ b/cmd/podman/search.go @@ -8,7 +8,6 @@ import ( "github.com/containers/image/docker" "github.com/containers/libpod/cmd/podman/formats" - "github.com/containers/libpod/cmd/podman/libpodruntime" "github.com/containers/libpod/libpod/common" sysreg "github.com/containers/libpod/pkg/registries" "github.com/docker/distribution/reference" @@ -108,12 +107,6 @@ func searchCmd(c *cli.Context) error { return err } - runtime, err := libpodruntime.GetRuntime(c) - if err != nil { - return errors.Wrapf(err, "could not get runtime") - } - defer runtime.Shutdown(false) - format := genSearchFormat(c.String("format")) opts := searchOpts{ format: format, diff --git a/test/e2e/rootless_test.go b/test/e2e/rootless_test.go index 7b3f26d45..84af927ea 100644 --- a/test/e2e/rootless_test.go +++ b/test/e2e/rootless_test.go @@ -58,6 +58,13 @@ var _ = Describe("Podman rootless", func() { } }) + chownFunc := func(p string, info os.FileInfo, err error) error { + if err != nil { + return err + } + return os.Lchown(p, 1000, 1000) + } + runRootless := func(args []string) { // Check if we can create an user namespace err := exec.Command("unshare", "-r", "echo", "hello").Run() @@ -75,13 +82,6 @@ var _ = Describe("Podman rootless", func() { Expect(mount.ExitCode()).To(Equal(0)) mountPath := mount.OutputToString() - chownFunc := func(p string, info os.FileInfo, err error) error { - if err != nil { - return err - } - return os.Lchown(p, 1000, 1000) - } - err = filepath.Walk(tempdir, chownFunc) if err != nil { fmt.Printf("cannot chown the directory: %q\n", err) @@ -160,6 +160,26 @@ var _ = Describe("Podman rootless", func() { Expect(umount.ExitCode()).To(Equal(0)) } + It("podman rootless search", func() { + xdgRuntimeDir, err := ioutil.TempDir("/run", "") + Expect(err).To(BeNil()) + defer os.RemoveAll(xdgRuntimeDir) + err = filepath.Walk(xdgRuntimeDir, chownFunc) + Expect(err).To(BeNil()) + + home, err := CreateTempDirInTempDir() + Expect(err).To(BeNil()) + err = filepath.Walk(xdgRuntimeDir, chownFunc) + Expect(err).To(BeNil()) + + env := os.Environ() + env = append(env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", xdgRuntimeDir)) + env = append(env, fmt.Sprintf("HOME=%s", home)) + cmd := podmanTest.PodmanAsUser([]string{"search", "docker.io/busybox"}, 1000, 1000, env) + cmd.WaitWithDefaultTimeout() + Expect(cmd.ExitCode()).To(Equal(0)) + }) + It("podman rootless rootfs", func() { runRootless([]string{}) }) |