Skip to content

Commit

Permalink
Fixes isRootfull check using qemu machine on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Sengileyev <[email protected]>
  • Loading branch information
arixmkii authored and mheon committed Sep 6, 2022
1 parent b103f05 commit 64fe541
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/machine/qemu/claim_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !darwin && !windows
// +build !darwin,!windows
//go:build !darwin
// +build !darwin

package qemu

Expand Down
3 changes: 0 additions & 3 deletions pkg/machine/qemu/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build (amd64 && !windows) || (arm64 && !windows)
// +build amd64,!windows arm64,!windows

package qemu

import (
Expand Down
14 changes: 11 additions & 3 deletions pkg/machine/qemu/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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
}

0 comments on commit 64fe541

Please sign in to comment.