diff --git a/pkg/machine/provider/platform_windows.go b/pkg/machine/provider/platform_windows.go index 943a66926c..4287f1c5f4 100644 --- a/pkg/machine/provider/platform_windows.go +++ b/pkg/machine/provider/platform_windows.go @@ -32,6 +32,9 @@ func Get() (vmconfigs.VMProvider, error) { case define.WSLVirt: return new(wsl.WSLStubber), nil case define.HyperVVirt: + if !wsl.HasAdminRights() { + return nil, fmt.Errorf("hyperv machines require admin authority") + } return new(hyperv.HyperVStubber), nil default: return nil, fmt.Errorf("unsupported virtualization provider: `%s`", resolvedVMType.String()) diff --git a/pkg/machine/wsl/machine.go b/pkg/machine/wsl/machine.go index 18593e9fa3..20afee2dc4 100644 --- a/pkg/machine/wsl/machine.go +++ b/pkg/machine/wsl/machine.go @@ -308,7 +308,7 @@ func checkAndInstallWSL(reExec bool) (bool, error) { return true, nil } - admin := hasAdminRights() + admin := HasAdminRights() if !IsWSLFeatureEnabled() { return false, attemptFeatureInstall(reExec, admin) diff --git a/pkg/machine/wsl/util_windows.go b/pkg/machine/wsl/util_windows.go index 7b24a39b1d..c6d9d1ab71 100644 --- a/pkg/machine/wsl/util_windows.go +++ b/pkg/machine/wsl/util_windows.go @@ -96,7 +96,7 @@ func winVersionAtLeast(major uint, minor uint, build uint) bool { return true } -func hasAdminRights() bool { +func HasAdminRights() bool { var sid *windows.SID // See: https://coolaj86.com/articles/golang-and-windows-and-admins-oh-my/