summaryrefslogtreecommitdiff
path: root/pkg/machine
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-09-08 12:26:50 +0200
committerGitHub <noreply@github.com>2022-09-08 12:26:50 +0200
commitd729dd8c2e6556de10c4543c018fbebffa265a5e (patch)
treeb374d334aef07d3b699e4f4bdf3861de48206b75 /pkg/machine
parente46bcd72f8d6528dbafb1ad1b34abeb0177a8b77 (diff)
parent744878a71cb225fca6cf6b8f322539b717559614 (diff)
downloadpodman-d729dd8c2e6556de10c4543c018fbebffa265a5e.tar.gz
podman-d729dd8c2e6556de10c4543c018fbebffa265a5e.tar.bz2
podman-d729dd8c2e6556de10c4543c018fbebffa265a5e.zip
Merge pull request #15610 from n1hility/release-workflow
Introduce a new signed Windows installer with automated build process
Diffstat (limited to 'pkg/machine')
-rw-r--r--pkg/machine/wsl/machine.go14
-rw-r--r--pkg/machine/wsl/util_windows.go15
2 files changed, 22 insertions, 7 deletions
diff --git a/pkg/machine/wsl/machine.go b/pkg/machine/wsl/machine.go
index 8b6d74817..7e453823f 100644
--- a/pkg/machine/wsl/machine.go
+++ b/pkg/machine/wsl/machine.go
@@ -638,13 +638,13 @@ func installScripts(dist string) error {
}
func checkAndInstallWSL(opts machine.InitOptions) (bool, error) {
- if isWSLInstalled() {
+ if IsWSLInstalled() {
return true, nil
}
admin := hasAdminRights()
- if !isWSLFeatureEnabled() {
+ if !IsWSLFeatureEnabled() {
return false, attemptFeatureInstall(opts, admin)
}
@@ -1105,9 +1105,10 @@ func waitPipeExists(pipeName string, retries int, checkFailure func() error) err
return err
}
-func isWSLInstalled() bool {
- cmd := exec.Command("wsl", "--status")
+func IsWSLInstalled() bool {
+ cmd := SilentExecCmd("wsl", "--status")
out, err := cmd.StdoutPipe()
+ cmd.Stderr = nil
if err != nil {
return false
}
@@ -1131,9 +1132,8 @@ func isWSLInstalled() bool {
return true
}
-func isWSLFeatureEnabled() bool {
- cmd := exec.Command("wsl", "--set-default-version", "2")
- return cmd.Run() == nil
+func IsWSLFeatureEnabled() bool {
+ return SilentExec("wsl", "--set-default-version", "2") == nil
}
func isWSLRunning(dist string) (bool, error) {
diff --git a/pkg/machine/wsl/util_windows.go b/pkg/machine/wsl/util_windows.go
index 6c74e5652..6613bde1f 100644
--- a/pkg/machine/wsl/util_windows.go
+++ b/pkg/machine/wsl/util_windows.go
@@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"os"
+ "os/exec"
"path/filepath"
"strings"
"syscall"
@@ -343,3 +344,17 @@ func sendQuit(tid uint32) {
postMessage := user32.NewProc("PostThreadMessageW")
postMessage.Call(uintptr(tid), WM_QUIT, 0, 0)
}
+
+func SilentExec(command string, args ...string) error {
+ cmd := exec.Command(command, args...)
+ cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: 0x08000000}
+ cmd.Stdout = nil
+ cmd.Stderr = nil
+ return cmd.Run()
+}
+
+func SilentExecCmd(command string, args ...string) *exec.Cmd {
+ cmd := exec.Command(command, args...)
+ cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: 0x08000000}
+ return cmd
+}