Skip to content

Commit ff9cab1

Browse files
committed
stdin pipe needs to be closed in case program continues to expect input
1 parent 456459e commit ff9cab1

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ NAME=sshfront
22
OWNER=gliderlabs
33
ARCH=$(shell uname -m)
44
RMFLAG=--rm
5-
VERSION=0.2.0
5+
VERSION=0.2.1
66

77
build:
88
mkdir -p build/Linux && GOOS=linux CGO_ENABLED=0 go build -a \
9-
-ldflags "-X main.Version $(VERSION)" \
9+
-ldflags "-X main.Version=$(VERSION)" \
1010
-installsuffix cgo \
1111
-o build/Linux/$(NAME)
1212
mkdir -p build/Darwin && GOOS=darwin CGO_ENABLED=0 go build -a \
13-
-ldflags "-X main.Version $(VERSION)" \
13+
-ldflags "-X main.Version=$(VERSION)" \
1414
-installsuffix cgo \
1515
-o build/Darwin/$(NAME)
1616

example/stdinecho

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
echo "Stdin:"
3+
cat

handlers.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ func (h *sshHandler) handleExec(req *ssh.Request) {
221221
h.channel.Close()
222222
return
223223
}
224-
go io.Copy(stdinPipe, h.channel)
224+
go func() {
225+
defer stdinPipe.Close()
226+
io.Copy(stdinPipe, h.channel)
227+
}()
225228

226229
if req.WantReply {
227230
req.Reply(true, nil)

0 commit comments

Comments
 (0)