Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
prevent plugins in Windows from creating terminals (#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 6, 2021
1 parent 0572292 commit 82e96d4
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
@@ -0,0 +1 @@
fixed Go plugins spawning terminals under Windows
5 changes: 3 additions & 2 deletions pkg/plugin/manager.go
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
@@ -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
@@ -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 82e96d4

Please sign in to comment.