File tree Expand file tree Collapse file tree 4 files changed +28
-4
lines changed Expand file tree Collapse file tree 4 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -2,15 +2,15 @@ NAME=sshfront
22OWNER =gliderlabs
33ARCH =$(shell uname -m)
44RMFLAG =--rm
5- VERSION =0.2.0
5+ VERSION =0.2.1
66
77build :
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
Original file line number Diff line number Diff line change 11# sshfront
22
3+ [ ![ CircleCI] ( https://img.shields.io/circleci/project/gliderlabs/sshfront/release.svg )] ( https://circleci.com/gh/gliderlabs/sshfront )
4+ [ ![ IRC Channel] ( https://img.shields.io/badge/irc-%23gliderlabs-blue.svg )] ( https://kiwiirc.com/client/irc.freenode.net/#gliderlabs )
5+
36A lightweight SSH server frontend where authentication and connections
47are controlled with command handlers / shell scripts.
58
@@ -74,3 +77,4 @@ This project was made possible thanks to [Deis](http://deis.io) and [DigitalOcea
7477## License
7578
7679MIT
80+ <img src =" https://ga-beacon.appspot.com/UA-58928488-2/sshfront/readme?pixel " />
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ echo " Stdin:"
3+ cat
Original file line number Diff line number Diff line change @@ -163,10 +163,16 @@ func (h *sshHandler) Exit(err error) error {
163163 return err
164164}
165165
166+ type EnvVar struct {
167+ Name , Value string
168+ }
169+
166170func (h * sshHandler ) Request (req * ssh.Request ) {
167171 switch req .Type {
168172 case "exec" :
169173 h .handleExec (req )
174+ case "env" :
175+ h .handleEnv (req )
170176 case "pty-req" :
171177 h .handlePty (req )
172178 case "window-change" :
@@ -178,6 +184,14 @@ func (h *sshHandler) Request(req *ssh.Request) {
178184 }
179185}
180186
187+ func (h * sshHandler ) handleEnv (req * ssh.Request ) {
188+ var pair EnvVar
189+ ssh .Unmarshal (req .Payload , & pair )
190+ envvar := fmt .Sprintf ("%s=%s" , pair .Name , pair .Value )
191+ h .Env = append (h .Env , envvar )
192+ req .Reply (true , nil )
193+ }
194+
181195func (h * sshHandler ) handleExec (req * ssh.Request ) {
182196 h .Lock ()
183197 defer h .Unlock ()
@@ -207,7 +221,10 @@ func (h *sshHandler) handleExec(req *ssh.Request) {
207221 h .channel .Close ()
208222 return
209223 }
210- go io .Copy (stdinPipe , h .channel )
224+ go func () {
225+ defer stdinPipe .Close ()
226+ io .Copy (stdinPipe , h .channel )
227+ }()
211228
212229 if req .WantReply {
213230 req .Reply (true , nil )
You can’t perform that action at this time.
0 commit comments