mod: copy stderr from ssh session to locally running processes stderr
Log the `serve` version in the beginning with a closing log message.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -56,14 +57,10 @@ func setupSshServer(host string, port string, host_key_path string, users map[st
|
|||||||
func(next ssh.Handler) ssh.Handler {
|
func(next ssh.Handler) ssh.Handler {
|
||||||
return func(s ssh.Session) {
|
return func(s ssh.Session) {
|
||||||
cmd := wish.Command(s, name, args...)
|
cmd := wish.Command(s, name, args...)
|
||||||
file, err := os.OpenFile("log", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
|
|
||||||
if err != nil {
|
|
||||||
wish.Fatalln(s, err)
|
|
||||||
}
|
|
||||||
cmd.SetStderr(file)
|
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
wish.Fatalln(s, err)
|
wish.Fatalln(s, err)
|
||||||
}
|
}
|
||||||
|
io.Copy(os.Stderr, s.Stderr())
|
||||||
next(s)
|
next(s)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -76,6 +73,9 @@ func setupSshServer(host string, port string, host_key_path string, users map[st
|
|||||||
// Serve an ssh application using the provided arguments.
|
// Serve an ssh application using the provided arguments.
|
||||||
func Serve(host string, port string, host_key_path string, users map[string]string, name string, args []string) {
|
func Serve(host string, port string, host_key_path string, users map[string]string, name string, args []string) {
|
||||||
setupLogging()
|
setupLogging()
|
||||||
|
log.Info("Running Serve (v2.7)...") // TODO make version string automatically the git tag (otherwise commit-hash)?
|
||||||
|
defer log.Info("Stopping Serve...")
|
||||||
|
|
||||||
srv, err := setupSshServer(host, port, host_key_path, users, name, args)
|
srv, err := setupSshServer(host, port, host_key_path, users, name, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Could not start server", "error", err)
|
log.Error("Could not start server", "error", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user