From d4fb68ee0fb41d3c68814097c01e150e42db86f6 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 27 Mar 2014 11:00:18 -0700 Subject: [PATCH] beam/examples/beamsh: 'in' chdirs to a directory. 'pass' does simple passthrough Docker-DCO-1.1-Signed-off-by: Solomon Hykes (github: shykes) --- beam/examples/beamsh/beamsh.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/beam/examples/beamsh/beamsh.go b/beam/examples/beamsh/beamsh.go index 4c82410..c96a75d 100644 --- a/beam/examples/beamsh/beamsh.go +++ b/beam/examples/beamsh/beamsh.go @@ -191,7 +191,27 @@ func randomId() string { } func GetHandler(name string) Handler { - if name == "exec" { + if name == "pass" { + return func(args []string, in *net.UnixConn, out *net.UnixConn) { + for { + payload, attachment, err := beam.Receive(in) + if err != nil { + return + } + if err := beam.Send(out, payload, attachment); err != nil { + if attachment != nil { + attachment.Close() + } + return + } + } + } + } else if name == "in" { + return func(args []string, in *net.UnixConn, out *net.UnixConn) { + os.Chdir(args[1]) + GetHandler("pass")([]string{"pass"}, in, out) + } + } else if name == "exec" { return func(args []string, in *net.UnixConn, out *net.UnixConn) { cmd := exec.Command(args[1], args[2:]...) outR, outW, err := os.Pipe()