diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-08-24 16:17:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 16:17:32 -0400 |
commit | 9a83fe33b5c93eff0e65064cc45158d8d0f6ea0d (patch) | |
tree | 3386049d28a35f181de4a29ba34f4e614b947a73 /pkg/machine/qemu/machine.go | |
parent | 6f4a6011d310bd831b9669058d018a5e5d282b7e (diff) | |
parent | 1788b26c431f461698d33f230ccfc8a3aa10033b (diff) | |
download | podman-9a83fe33b5c93eff0e65064cc45158d8d0f6ea0d.tar.gz podman-9a83fe33b5c93eff0e65064cc45158d8d0f6ea0d.tar.bz2 podman-9a83fe33b5c93eff0e65064cc45158d8d0f6ea0d.zip |
Merge pull request #15433 from arixmkii/win_compat3_rootless
Fixes isRootful check using qemu machine on Windows
Diffstat (limited to 'pkg/machine/qemu/machine.go')
-rw-r--r-- | pkg/machine/qemu/machine.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index 71752a101..e97b68e31 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 +} |