Skip to content

Commit 577fa7e

Browse files
authored
Add support for windows shell and command wrapping
1 parent afabff3 commit 577fa7e

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

pkg/config/config.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"errors"
66
"fmt"
77
"os"
8+
"runtime"
89
"time"
910

1011
"github.com/rs/zerolog"
1112
"google.golang.org/grpc/metadata"
1213
internalv1 "namespacelabs.dev/breakpoint/api/private/v1"
13-
"namespacelabs.dev/breakpoint/api/public/v1"
14+
v1 "namespacelabs.dev/breakpoint/api/public/v1"
1415
"namespacelabs.dev/breakpoint/pkg/github"
1516
"namespacelabs.dev/breakpoint/pkg/githuboidc"
1617
"namespacelabs.dev/breakpoint/pkg/jsonfile"
@@ -36,7 +37,11 @@ func LoadConfig(ctx context.Context, file string) (ParsedConfig, error) {
3637
if sh, ok := os.LookupEnv("SHELL"); ok {
3738
cfg.Shell = []string{sh}
3839
} else {
39-
cfg.Shell = []string{"/bin/sh"}
40+
if runtime.GOOS == "windows" {
41+
cfg.Shell = []string{"C:\\Windows\\System32\\cmd.exe"}
42+
} else {
43+
cfg.Shell = []string{"/bin/sh"}
44+
}
4045
}
4146
}
4247

pkg/sshd/sshd.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"net"
1010
"os/exec"
11+
"runtime"
1112
"time"
1213

1314
"github.com/gliderlabs/ssh"
@@ -61,7 +62,11 @@ func MakeServer(ctx context.Context, opts SSHServerOpts) (*SSHServer, error) {
6162

6263
args := opts.Shell[1:]
6364
if session.RawCommand() != "" {
64-
args = []string{"-c", session.RawCommand()}
65+
if runtime.GOOS == "windows" {
66+
args = []string{"/C", session.RawCommand()}
67+
} else {
68+
args = []string{"-c", session.RawCommand()}
69+
}
6570
}
6671

6772
cmd := exec.Command(opts.Shell[0], args...)

0 commit comments

Comments
 (0)