Skip to content

Commit

Permalink
prevent plugins in Windows from creating terminals (vmware-archive#2701)
Browse files Browse the repository at this point in the history
Signed-off-by: Wayne Witzel III <wayne@riotousliving.com>
  • Loading branch information
wwitzel3 committed Aug 30, 2021
1 parent 79ef374 commit ff7d861
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/2143-wwitzel3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixed Go plugins spawning terminals under Windows
5 changes: 3 additions & 2 deletions pkg/plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package plugin
import (
"context"
"fmt"
"os/exec"
"path/filepath"
"sort"
"sync"
Expand Down Expand Up @@ -60,10 +59,12 @@ func (f *DefaultClientFactory) Init(ctx context.Context, cmd string) Client {
dashLogger: log.From(ctx),
}

c := pluginCmd(cmd)

return plugin.NewClient(&plugin.ClientConfig{
HandshakeConfig: Handshake,
Plugins: pluginMap,
Cmd: exec.Command(cmd),
Cmd: c,
AllowedProtocols: []plugin.Protocol{
plugin.ProtocolGRPC,
},
Expand Down
17 changes: 17 additions & 0 deletions pkg/plugin/plugincmd_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// +build !windows

/*
Copyright (c) 2019 the Octant contributors. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package plugin

import (
"os/exec"
)

func pluginCmd(cmd string) *exec.Cmd {
pluginCmd := exec.Command(cmd)
return pluginCmd
}
19 changes: 19 additions & 0 deletions pkg/plugin/plugincmd_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// +build windows

/*
Copyright (c) 2019 the Octant contributors. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package plugin

import (
"os/exec"
"syscall"
)

func pluginCmd(cmd string) *exec.Cmd {
pluginCmd := exec.Command(cmd)
pluginCmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
return pluginCmd
}

0 comments on commit ff7d861

Please sign in to comment.