Merge pull request #17124 from sstosh/e2e-rootless

e2e: use isRootless() instead of rootless.IsRootless()
This commit is contained in:
OpenShift Merge Robot
2023-01-20 09:04:25 -05:00
committed by GitHub
20 changed files with 49 additions and 61 deletions

View File

@ -63,7 +63,7 @@ output with given format JSON by using *structs* defined in inspect package.
You can run the entire suite of integration tests with the following command: You can run the entire suite of integration tests with the following command:
``` ```
GOPATH=~/go ginkgo -v test/e2e/. GOPATH=~/go ginkgo -tags "remote" -v test/e2e/.
``` ```
Note the trailing period on the command above. Also, **-v** invokes verbose mode. That Note the trailing period on the command above. Also, **-v** invokes verbose mode. That

View File

@ -20,7 +20,6 @@ import (
"github.com/containers/common/pkg/cgroups" "github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v4/libpod/define" "github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/inspect" "github.com/containers/podman/v4/pkg/inspect"
"github.com/containers/podman/v4/pkg/rootless"
"github.com/containers/podman/v4/pkg/util" "github.com/containers/podman/v4/pkg/util"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
"github.com/containers/storage/pkg/lockfile" "github.com/containers/storage/pkg/lockfile"
@ -232,7 +231,7 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
} }
cgroupManager := CGROUP_MANAGER cgroupManager := CGROUP_MANAGER
if rootless.IsRootless() { if isRootless() {
cgroupManager = "cgroupfs" cgroupManager = "cgroupfs"
} }
if os.Getenv("CGROUP_MANAGER") != "" { if os.Getenv("CGROUP_MANAGER") != "" {
@ -247,14 +246,14 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
networkBackend := CNI networkBackend := CNI
networkConfigDir := "/etc/cni/net.d" networkConfigDir := "/etc/cni/net.d"
if rootless.IsRootless() { if isRootless() {
networkConfigDir = filepath.Join(os.Getenv("HOME"), ".config/cni/net.d") networkConfigDir = filepath.Join(os.Getenv("HOME"), ".config/cni/net.d")
} }
if strings.ToLower(os.Getenv("NETWORK_BACKEND")) == "netavark" { if strings.ToLower(os.Getenv("NETWORK_BACKEND")) == "netavark" {
networkBackend = Netavark networkBackend = Netavark
networkConfigDir = "/etc/containers/networks" networkConfigDir = "/etc/containers/networks"
if rootless.IsRootless() { if isRootless() {
networkConfigDir = filepath.Join(root, "etc", "networks") networkConfigDir = filepath.Join(root, "etc", "networks")
} }
} }
@ -268,7 +267,7 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
} }
storageFs := STORAGE_FS storageFs := STORAGE_FS
if rootless.IsRootless() { if isRootless() {
storageFs = ROOTLESS_STORAGE_FS storageFs = ROOTLESS_STORAGE_FS
} }
if os.Getenv("STORAGE_FS") != "" { if os.Getenv("STORAGE_FS") != "" {
@ -300,7 +299,7 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
if remote { if remote {
var pathPrefix string var pathPrefix string
if !rootless.IsRootless() { if !isRootless() {
pathPrefix = "/run/podman/podman" pathPrefix = "/run/podman/podman"
} else { } else {
runtimeDir := os.Getenv("XDG_RUNTIME_DIR") runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
@ -676,21 +675,21 @@ func checkReason(reason string) {
func SkipIfRootlessCgroupsV1(reason string) { func SkipIfRootlessCgroupsV1(reason string) {
checkReason(reason) checkReason(reason)
if os.Geteuid() != 0 && !CGROUPSV2 { if isRootless() && !CGROUPSV2 {
Skip("[rootless]: " + reason) Skip("[rootless]: " + reason)
} }
} }
func SkipIfRootless(reason string) { func SkipIfRootless(reason string) {
checkReason(reason) checkReason(reason)
if os.Geteuid() != 0 { if isRootless() {
Skip("[rootless]: " + reason) Skip("[rootless]: " + reason)
} }
} }
func SkipIfNotRootless(reason string) { func SkipIfNotRootless(reason string) {
checkReason(reason) checkReason(reason)
if os.Geteuid() == 0 { if !isRootless() {
Skip("[notRootless]: " + reason) Skip("[notRootless]: " + reason)
} }
} }
@ -722,6 +721,8 @@ func SkipIfNotFedora() {
} }
} }
// Use isRootless() instead of rootless.IsRootless()
// This function can detect to join the user namespace by mistake
func isRootless() bool { func isRootless() bool {
return os.Geteuid() != 0 return os.Geteuid() != 0
} }

View File

@ -4,7 +4,6 @@ import (
"os" "os"
"time" "time"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -58,7 +57,7 @@ var _ = Describe("Podman create with --ip flag", func() {
result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", ip, ALPINE, "ip", "addr"}) result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", ip, ALPINE, "ip", "addr"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
// Rootless static ip assignment without network should error // Rootless static ip assignment without network should error
if rootless.IsRootless() { if isRootless() {
Expect(result).Should(Exit(125)) Expect(result).Should(Exit(125))
} else { } else {
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))

View File

@ -3,7 +3,6 @@ package integration
import ( import (
"os" "os"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
"github.com/containers/storage/pkg/stringid" "github.com/containers/storage/pkg/stringid"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -39,7 +38,7 @@ var _ = Describe("Podman run with --mac-address flag", func() {
It("Podman run --mac-address", func() { It("Podman run --mac-address", func() {
result := podmanTest.Podman([]string{"run", "--mac-address", "92:d0:c6:0a:29:34", ALPINE, "ip", "addr"}) result := podmanTest.Podman([]string{"run", "--mac-address", "92:d0:c6:0a:29:34", ALPINE, "ip", "addr"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
if rootless.IsRootless() { if isRootless() {
Expect(result).Should(Exit(125)) Expect(result).Should(Exit(125))
} else { } else {
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))

View File

@ -14,7 +14,6 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
@ -34,7 +33,7 @@ func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSession
args = p.makeOptions(args, false, false) args = p.makeOptions(args, false, false)
wrapper := []string{"systemd-run", "--scope"} wrapper := []string{"systemd-run", "--scope"}
if rootless.IsRootless() { if isRootless() {
wrapper = []string{"systemd-run", "--scope", "--user"} wrapper = []string{"systemd-run", "--scope", "--user"}
} }
@ -71,7 +70,7 @@ func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
} }
func (p *PodmanTestIntegration) StartRemoteService() { func (p *PodmanTestIntegration) StartRemoteService() {
if os.Geteuid() == 0 { if !isRootless() {
err := os.MkdirAll("/run/podman", 0755) err := os.MkdirAll("/run/podman", 0755)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
} }
@ -99,7 +98,7 @@ func (p *PodmanTestIntegration) StartRemoteService() {
} }
func (p *PodmanTestIntegration) StopRemoteService() { func (p *PodmanTestIntegration) StopRemoteService() {
if !rootless.IsRootless() { if !isRootless() {
if err := p.RemoteSession.Kill(); err != nil { if err := p.RemoteSession.Kill(); err != nil {
fmt.Fprintf(os.Stderr, "error on remote stop-kill %q", err) fmt.Fprintf(os.Stderr, "error on remote stop-kill %q", err)
} }

View File

@ -8,7 +8,6 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
@ -25,7 +24,7 @@ func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration
// PodmanSystemdScope runs the podman command in a new systemd scope // PodmanSystemdScope runs the podman command in a new systemd scope
func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration { func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration {
wrapper := []string{"systemd-run", "--scope"} wrapper := []string{"systemd-run", "--scope"}
if rootless.IsRootless() { if isRootless() {
wrapper = []string{"systemd-run", "--scope", "--user"} wrapper = []string{"systemd-run", "--scope", "--user"}
} }
podmanSession := p.PodmanAsUserBase(args, 0, 0, "", nil, false, false, wrapper, nil) podmanSession := p.PodmanAsUserBase(args, 0, 0, "", nil, false, false, wrapper, nil)

View File

@ -7,7 +7,6 @@ import (
"time" "time"
"github.com/containers/common/libnetwork/types" "github.com/containers/common/libnetwork/types"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
"github.com/containers/storage/pkg/stringid" "github.com/containers/storage/pkg/stringid"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -265,7 +264,7 @@ var _ = Describe("Podman network", func() {
defer removeConf(path) defer removeConf(path)
expectedNetworks := []string{name} expectedNetworks := []string{name}
if !rootless.IsRootless() { if !isRootless() {
// rootful image contains "podman/cni/87-podman-bridge.conflist" for "podman" network // rootful image contains "podman/cni/87-podman-bridge.conflist" for "podman" network
expectedNetworks = append(expectedNetworks, "podman") expectedNetworks = append(expectedNetworks, "podman")
} }

View File

@ -4368,7 +4368,7 @@ ENV OPENJ9_JAVA_OPTIONS=%q
initialUsernsConfig, err := os.ReadFile("/proc/self/uid_map") initialUsernsConfig, err := os.ReadFile("/proc/self/uid_map")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
if os.Geteuid() != 0 { if isRootless() {
unshare := podmanTest.Podman([]string{"unshare", "cat", "/proc/self/uid_map"}) unshare := podmanTest.Podman([]string{"unshare", "cat", "/proc/self/uid_map"})
unshare.WaitWithDefaultTimeout() unshare.WaitWithDefaultTimeout()
Expect(unshare).Should(Exit(0)) Expect(unshare).Should(Exit(0))

View File

@ -11,7 +11,6 @@ import (
"github.com/containers/common/pkg/apparmor" "github.com/containers/common/pkg/apparmor"
"github.com/containers/common/pkg/seccomp" "github.com/containers/common/pkg/seccomp"
"github.com/containers/common/pkg/sysinfo" "github.com/containers/common/pkg/sysinfo"
"github.com/containers/podman/v4/pkg/rootless"
"github.com/containers/podman/v4/pkg/util" "github.com/containers/podman/v4/pkg/util"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -252,7 +251,7 @@ var _ = Describe("Podman pod create", func() {
podCreate := podmanTest.Podman([]string{"pod", "create", "--ip", ip, "--name", name}) podCreate := podmanTest.Podman([]string{"pod", "create", "--ip", ip, "--name", name})
podCreate.WaitWithDefaultTimeout() podCreate.WaitWithDefaultTimeout()
// Rootless should error without network // Rootless should error without network
if rootless.IsRootless() { if isRootless() {
Expect(podCreate).Should(Exit(125)) Expect(podCreate).Should(Exit(125))
} else { } else {
Expect(podCreate).Should(Exit(0)) Expect(podCreate).Should(Exit(0))
@ -295,7 +294,7 @@ var _ = Describe("Podman pod create", func() {
podCreate := podmanTest.Podman([]string{"pod", "create", "--mac-address", mac, "--name", name}) podCreate := podmanTest.Podman([]string{"pod", "create", "--mac-address", mac, "--name", name})
podCreate.WaitWithDefaultTimeout() podCreate.WaitWithDefaultTimeout()
// Rootless should error // Rootless should error
if rootless.IsRootless() { if isRootless() {
Expect(podCreate).Should(Exit(125)) Expect(podCreate).Should(Exit(125))
} else { } else {
Expect(podCreate).Should(Exit(0)) Expect(podCreate).Should(Exit(0))
@ -662,7 +661,7 @@ ENTRYPOINT ["sleep","99999"]
}) })
It("podman pod create with --userns=keep-id", func() { It("podman pod create with --userns=keep-id", func() {
if os.Geteuid() == 0 { if !isRootless() {
Skip("Test only runs without root") Skip("Test only runs without root")
} }
@ -698,7 +697,7 @@ ENTRYPOINT ["sleep","99999"]
}) })
It("podman pod create with --userns=keep-id can add users", func() { It("podman pod create with --userns=keep-id can add users", func() {
if os.Geteuid() == 0 { if !isRootless() {
Skip("Test only runs without root") Skip("Test only runs without root")
} }
@ -1097,7 +1096,7 @@ ENTRYPOINT ["sleep","99999"]
inspect := podmanTest.InspectContainer(ctrCreate.OutputToString()) inspect := podmanTest.InspectContainer(ctrCreate.OutputToString())
Expect(data.CgroupPath).To(HaveLen(0)) Expect(data.CgroupPath).To(HaveLen(0))
if podmanTest.CgroupManager == "cgroupfs" || !rootless.IsRootless() { if podmanTest.CgroupManager == "cgroupfs" || !isRootless() {
Expect(inspect[0].HostConfig.CgroupParent).To(HaveLen(0)) Expect(inspect[0].HostConfig.CgroupParent).To(HaveLen(0))
} else if podmanTest.CgroupManager == "systemd" { } else if podmanTest.CgroupManager == "systemd" {
Expect(inspect[0].HostConfig).To(HaveField("CgroupParent", "user.slice")) Expect(inspect[0].HostConfig).To(HaveField("CgroupParent", "user.slice"))

View File

@ -6,7 +6,6 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -623,7 +622,7 @@ var _ = Describe("Podman pull", func() {
podmanTest.AddImageToRWStore(ALPINE) podmanTest.AddImageToRWStore(ALPINE)
if rootless.IsRootless() { if isRootless() {
err := podmanTest.RestoreArtifact(REGISTRY_IMAGE) err := podmanTest.RestoreArtifact(REGISTRY_IMAGE)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
} }

View File

@ -7,7 +7,6 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
"github.com/containers/storage/pkg/archive" "github.com/containers/storage/pkg/archive"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -99,7 +98,7 @@ var _ = Describe("Podman push", func() {
if podmanTest.Host.Arch == "ppc64le" { if podmanTest.Host.Arch == "ppc64le" {
Skip("No registry image for ppc64le") Skip("No registry image for ppc64le")
} }
if rootless.IsRootless() { if isRootless() {
err := podmanTest.RestoreArtifact(REGISTRY_IMAGE) err := podmanTest.RestoreArtifact(REGISTRY_IMAGE)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
} }

View File

@ -9,7 +9,6 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -55,7 +54,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
udsPath := filepath.Join(udsDir, "fifo") udsPath := filepath.Join(udsDir, "fifo")
err = syscall.Mkfifo(udsPath, 0600) err = syscall.Mkfifo(udsPath, 0600)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
if rootless.IsRootless() { if isRootless() {
err = podmanTest.RestoreArtifact(fedoraMinimal) err = podmanTest.RestoreArtifact(fedoraMinimal)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
} }
@ -113,7 +112,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
Specify("signals are not forwarded to container with sig-proxy false", func() { Specify("signals are not forwarded to container with sig-proxy false", func() {
signal := syscall.SIGFPE signal := syscall.SIGFPE
if rootless.IsRootless() { if isRootless() {
err = podmanTest.RestoreArtifact(fedoraMinimal) err = podmanTest.RestoreArtifact(fedoraMinimal)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
} }

View File

@ -13,7 +13,6 @@ import (
"github.com/containers/common/pkg/cgroups" "github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v4/libpod/define" "github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
"github.com/containers/storage/pkg/stringid" "github.com/containers/storage/pkg/stringid"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -261,7 +260,7 @@ var _ = Describe("Podman run", func() {
if os.Getenv("container") != "" { if os.Getenv("container") != "" {
Skip("Overlay mounts not supported when running in a container") Skip("Overlay mounts not supported when running in a container")
} }
if rootless.IsRootless() { if isRootless() {
if _, err := exec.LookPath("fuse-overlayfs"); err != nil { if _, err := exec.LookPath("fuse-overlayfs"); err != nil {
Skip("Fuse-Overlayfs required for rootless overlay mount test") Skip("Fuse-Overlayfs required for rootless overlay mount test")
} }
@ -562,7 +561,7 @@ var _ = Describe("Podman run", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring("0000000000000002")) Expect(session.OutputToString()).To(ContainSubstring("0000000000000002"))
if os.Geteuid() > 0 { if isRootless() {
if os.Getenv("SKIP_USERNS") != "" { if os.Getenv("SKIP_USERNS") != "" {
Skip("Skip userns tests.") Skip("Skip userns tests.")
} }
@ -2022,7 +2021,7 @@ WORKDIR /madethis`, BB)
podmanTest.AddImageToRWStore(ALPINE) podmanTest.AddImageToRWStore(ALPINE)
if rootless.IsRootless() { if isRootless() {
err := podmanTest.RestoreArtifact(REGISTRY_IMAGE) err := podmanTest.RestoreArtifact(REGISTRY_IMAGE)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
} }

View File

@ -128,8 +128,9 @@ var _ = Describe("Podman UserNS support", func() {
It("podman --userns=keep-id", func() { It("podman --userns=keep-id", func() {
session := podmanTest.Podman([]string{"run", "--userns=keep-id", "alpine", "id", "-u"}) session := podmanTest.Podman([]string{"run", "--userns=keep-id", "alpine", "id", "-u"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
if os.Geteuid() == 0 { if !isRootless() {
Expect(session).Should(Exit(125)) Expect(session).Should(Exit(125))
Expect(session.ErrorToString()).To(ContainSubstring("keep-id is only supported in rootless mode"))
return return
} }
@ -139,8 +140,9 @@ var _ = Describe("Podman UserNS support", func() {
session = podmanTest.Podman([]string{"run", "--userns=keep-id:uid=10,gid=12", "alpine", "sh", "-c", "echo $(id -u):$(id -g)"}) session = podmanTest.Podman([]string{"run", "--userns=keep-id:uid=10,gid=12", "alpine", "sh", "-c", "echo $(id -u):$(id -g)"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
if os.Geteuid() == 0 { if !isRootless() {
Expect(session).Should(Exit(125)) Expect(session).Should(Exit(125))
Expect(session.ErrorToString()).To(ContainSubstring("keep-id is only supported in rootless mode"))
return return
} }

View File

@ -8,7 +8,6 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -222,7 +221,7 @@ var _ = Describe("Podman run with volumes", func() {
if os.Getenv("container") != "" { if os.Getenv("container") != "" {
Skip("Overlay mounts not supported when running in a container") Skip("Overlay mounts not supported when running in a container")
} }
if rootless.IsRootless() { if isRootless() {
if _, err := exec.LookPath("fuse-overlayfs"); err != nil { if _, err := exec.LookPath("fuse-overlayfs"); err != nil {
Skip("Fuse-Overlayfs required for rootless overlay mount test") Skip("Fuse-Overlayfs required for rootless overlay mount test")
} }
@ -242,7 +241,7 @@ var _ = Describe("Podman run with volumes", func() {
if os.Getenv("container") != "" { if os.Getenv("container") != "" {
Skip("Overlay mounts not supported when running in a container") Skip("Overlay mounts not supported when running in a container")
} }
if rootless.IsRootless() { if isRootless() {
if _, err := exec.LookPath("fuse-overlayfs"); err != nil { if _, err := exec.LookPath("fuse-overlayfs"); err != nil {
Skip("Fuse-Overlayfs required for rootless overlay mount test") Skip("Fuse-Overlayfs required for rootless overlay mount test")
} }
@ -275,7 +274,7 @@ var _ = Describe("Podman run with volumes", func() {
if os.Getenv("container") != "" { if os.Getenv("container") != "" {
Skip("Overlay mounts not supported when running in a container") Skip("Overlay mounts not supported when running in a container")
} }
if rootless.IsRootless() { if isRootless() {
if _, err := exec.LookPath("fuse-overlayfs"); err != nil { if _, err := exec.LookPath("fuse-overlayfs"); err != nil {
Skip("Fuse-Overlayfs required for rootless overlay mount test") Skip("Fuse-Overlayfs required for rootless overlay mount test")
} }
@ -329,7 +328,7 @@ var _ = Describe("Podman run with volumes", func() {
if os.Getenv("container") != "" { if os.Getenv("container") != "" {
Skip("Overlay mounts not supported when running in a container") Skip("Overlay mounts not supported when running in a container")
} }
if rootless.IsRootless() { if isRootless() {
if _, err := exec.LookPath("fuse-overlayfs"); err != nil { if _, err := exec.LookPath("fuse-overlayfs"); err != nil {
Skip("Fuse-Overlayfs required for rootless overlay mount test") Skip("Fuse-Overlayfs required for rootless overlay mount test")
} }
@ -655,7 +654,7 @@ VOLUME /test/`, ALPINE)
if os.Getenv("container") != "" { if os.Getenv("container") != "" {
Skip("Overlay mounts not supported when running in a container") Skip("Overlay mounts not supported when running in a container")
} }
if rootless.IsRootless() { if isRootless() {
if _, err := exec.LookPath("fuse-overlayfs"); err != nil { if _, err := exec.LookPath("fuse-overlayfs"); err != nil {
Skip("Fuse-Overlayfs required for rootless overlay mount test") Skip("Fuse-Overlayfs required for rootless overlay mount test")
} }
@ -778,7 +777,7 @@ VOLUME /test/`, ALPINE)
if os.Getenv("container") != "" { if os.Getenv("container") != "" {
Skip("Overlay mounts not supported when running in a container") Skip("Overlay mounts not supported when running in a container")
} }
if rootless.IsRootless() { if isRootless() {
if _, err := exec.LookPath("fuse_overlay"); err != nil { if _, err := exec.LookPath("fuse_overlay"); err != nil {
Skip("Fuse-Overlayfs required for rootless overlay mount test") Skip("Fuse-Overlayfs required for rootless overlay mount test")
} }

View File

@ -7,7 +7,6 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -88,7 +87,7 @@ var _ = Describe("Podman save", func() {
}) })
It("podman save to directory with oci format", func() { It("podman save to directory with oci format", func() {
if rootless.IsRootless() { if isRootless() {
Skip("Requires a fix in containers image for chown/lchown") Skip("Requires a fix in containers image for chown/lchown")
} }
outdir := filepath.Join(podmanTest.TempDir, "save") outdir := filepath.Join(podmanTest.TempDir, "save")
@ -99,7 +98,7 @@ var _ = Describe("Podman save", func() {
}) })
It("podman save to directory with v2s2 docker format", func() { It("podman save to directory with v2s2 docker format", func() {
if rootless.IsRootless() { if isRootless() {
Skip("Requires a fix in containers image for chown/lchown") Skip("Requires a fix in containers image for chown/lchown")
} }
outdir := filepath.Join(podmanTest.TempDir, "save") outdir := filepath.Join(podmanTest.TempDir, "save")
@ -110,7 +109,7 @@ var _ = Describe("Podman save", func() {
}) })
It("podman save to directory with docker format and compression", func() { It("podman save to directory with docker format and compression", func() {
if rootless.IsRootless() && podmanTest.RemoteTest { if isRootless() && podmanTest.RemoteTest {
Skip("Requires a fix in containers image for chown/lchown") Skip("Requires a fix in containers image for chown/lchown")
} }
outdir := filepath.Join(podmanTest.TempDir, "save") outdir := filepath.Join(podmanTest.TempDir, "save")
@ -121,7 +120,7 @@ var _ = Describe("Podman save", func() {
}) })
It("podman save to directory with --compress but not use docker-dir and oci-dir", func() { It("podman save to directory with --compress but not use docker-dir and oci-dir", func() {
if rootless.IsRootless() && podmanTest.RemoteTest { if isRootless() && podmanTest.RemoteTest {
Skip("Requires a fix in containers image for chown/lchown") Skip("Requires a fix in containers image for chown/lchown")
} }
outdir := filepath.Join(podmanTest.TempDir, "save") outdir := filepath.Join(podmanTest.TempDir, "save")

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -95,7 +94,7 @@ var _ = Describe("podman system reset", func() {
// TODO: machine tests currently don't run outside of the machine test pkg // TODO: machine tests currently don't run outside of the machine test pkg
// no machines are created here to cleanup // no machines are created here to cleanup
// machine commands are rootless only // machine commands are rootless only
if rootless.IsRootless() { if isRootless() {
session = podmanTest.Podman([]string{"machine", "list", "-q"}) session = podmanTest.Podman([]string{"machine", "list", "-q"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))

View File

@ -12,7 +12,6 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/containers/podman/v4/pkg/rootless"
testUtils "github.com/containers/podman/v4/test/utils" testUtils "github.com/containers/podman/v4/test/utils"
podmanUtils "github.com/containers/podman/v4/utils" podmanUtils "github.com/containers/podman/v4/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -77,7 +76,7 @@ var _ = Describe("Systemd activate", func() {
if selinux.GetEnabled() { if selinux.GetEnabled() {
rootDir := "/var/lib/containers" rootDir := "/var/lib/containers"
label := "container_var_lib_t" label := "container_var_lib_t"
if rootless.IsRootless() { if isRootless() {
rootDir = filepath.Join(os.Getenv("HOME"), ".local/share/containers") rootDir = filepath.Join(os.Getenv("HOME"), ".local/share/containers")
label = "data_home_t" label = "data_home_t"
} }

View File

@ -35,7 +35,6 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/containers/podman/v4/pkg/rootless"
. "github.com/containers/podman/v4/test/utils" . "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -381,7 +380,7 @@ var _ = Describe("Toolbox-specific testing", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring(currentUser.HomeDir)) Expect(session.OutputToString()).To(ContainSubstring(currentUser.HomeDir))
if rootless.IsRootless() { if isRootless() {
location := path.Dir(currentUser.HomeDir) location := path.Dir(currentUser.HomeDir)
volumeArg := fmt.Sprintf("%s:%s", location, location) volumeArg := fmt.Sprintf("%s:%s", location, location)
session = podmanTest.Podman([]string{"run", session = podmanTest.Podman([]string{"run",

View File

@ -20,7 +20,7 @@ var _ = Describe("Podman unshare", func() {
Skip("User namespaces not supported.") Skip("User namespaces not supported.")
} }
if os.Geteuid() == 0 { if !isRootless() {
Skip("Use unshare in rootless only") Skip("Use unshare in rootless only")
} }