Skip to content

Commit

Permalink
fix(security): hide console window only in Windows (#94)
Browse files Browse the repository at this point in the history
* fix(security): hide console window only in Windows

* update
  • Loading branch information
ayoubfaouzi authored Feb 13, 2024
1 parent 35bd244 commit 8846571
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 1 addition & 2 deletions security.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"runtime"
"sort"
"strings"
"syscall"
"time"

"go.mozilla.org/pkcs7"
Expand Down Expand Up @@ -489,7 +488,7 @@ func loadSystemRoots() (*x509.CertPool, error) {
// Use certutil to download all the root certs.
if needSync {
cmd := exec.Command("certutil", "-syncWithWU", dir)
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
hideWindow(cmd)
out, err := cmd.Output()
if err != nil {
return roots, err
Expand Down
9 changes: 9 additions & 0 deletions security_linux_mac.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !windows
// +build !windows

package pe

import "os/exec"

func hideWindow(cmd *exec.Cmd) {
}
13 changes: 13 additions & 0 deletions security_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build windows
// +build windows

package pe

import (
"os/exec"
"syscall"
)

func hideWindow(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
}

0 comments on commit 8846571

Please sign in to comment.