mod: use log file as stderr for ssh command
Some checks failed
Go Project Action / Spell-check and test go project (push) Has been cancelled
Some checks failed
Go Project Action / Spell-check and test go project (push) Has been cancelled
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -57,10 +56,14 @@ func setupSshServer(host string, port string, host_key_path string, users map[st
|
||||
func(next ssh.Handler) ssh.Handler {
|
||||
return func(s ssh.Session) {
|
||||
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 {
|
||||
wish.Fatalln(s, err)
|
||||
}
|
||||
io.Copy(os.Stderr, s.Stderr())
|
||||
next(s)
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user