diff options
author | Arthur Sengileyev <arthur.sengileyev@gmail.com> | 2022-08-23 17:09:14 +0300 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2022-09-06 14:24:32 -0400 |
commit | 64fe541a62fe304ab47fd006e3d81db190059a1c (patch) | |
tree | 1e2b1d57b77310910976fee8f11142a52a6b4ecc | |
parent | b103f057944a272fe67922c1a6c6ebe0d4ea5c07 (diff) | |
download | podman-64fe541a62fe304ab47fd006e3d81db190059a1c.tar.gz podman-64fe541a62fe304ab47fd006e3d81db190059a1c.tar.bz2 podman-64fe541a62fe304ab47fd006e3d81db190059a1c.zip |
Fixes isRootfull check using qemu machine on Windows
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
-rw-r--r-- | pkg/machine/qemu/claim_unsupported.go | 4 | ||||
-rw-r--r-- | pkg/machine/qemu/config.go | 3 | ||||
-rw-r--r-- | pkg/machine/qemu/machine.go | 14 |
3 files changed, 13 insertions, 8 deletions
diff --git a/pkg/machine/qemu/claim_unsupported.go b/pkg/machine/qemu/claim_unsupported.go index e0b3dd3d3..187ef9d69 100644 --- a/pkg/machine/qemu/claim_unsupported.go +++ b/pkg/machine/qemu/claim_unsupported.go @@ -1,5 +1,5 @@ -//go:build !darwin && !windows -// +build !darwin,!windows +//go:build !darwin +// +build !darwin package qemu diff --git a/pkg/machine/qemu/config.go b/pkg/machine/qemu/config.go index bada1af9b..8081727f6 100644 --- a/pkg/machine/qemu/config.go +++ b/pkg/machine/qemu/config.go @@ -1,6 +1,3 @@ -//go:build (amd64 && !windows) || (arm64 && !windows) -// +build amd64,!windows arm64,!windows - package qemu import ( diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index 5a451c02a..a570bfd3e 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -870,7 +870,7 @@ func NewQMPMonitor(network, name string, timeout time.Duration) (Monitor, error) if err != nil { return Monitor{}, err } - if !rootless.IsRootless() { + if isRootful() { rtDir = "/run" } rtDir = filepath.Join(rtDir, "podman") @@ -1371,7 +1371,7 @@ func (v *MachineVM) setPIDSocket() error { if err != nil { return err } - if !rootless.IsRootless() { + if isRootful() { rtPath = "/run" } socketDir := filepath.Join(rtPath, "podman") @@ -1397,7 +1397,7 @@ func (v *MachineVM) getSocketandPid() (string, string, error) { if err != nil { return "", "", err } - if !rootless.IsRootless() { + if isRootful() { rtPath = "/run" } socketDir := filepath.Join(rtPath, "podman") @@ -1735,3 +1735,11 @@ func isProcessAlive(pid int) bool { func (p *Provider) VMType() string { return vmtype } + +func isRootful() bool { + // Rootless is not relevant on Windows. In the future rootless.IsRootless + // could be switched to return true on Windows, and other codepaths migrated + // for now will check additionally for valid os.Getuid + + return !rootless.IsRootless() && os.Getuid() != -1 +} |