mirror of
https://github.com/containers/podman.git
synced 2025-10-25 18:25:59 +08:00
rootless, search: do not create a new userns
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1360 Approved by: vrothberg
This commit is contained in:
committed by
Atomic Bot
parent
ec07b2d021
commit
c33b359ed1
@ -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{})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user