2015-07-25 16:19:29 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
// small wrapper around sftp server that allows it to be used as a separate process subsystem call by the ssh server.
|
|
|
|
// in practice this will statically link; however this allows unit testing from the sftp client.
|
|
|
|
|
|
|
|
import (
|
2015-07-31 14:43:00 +08:00
|
|
|
"flag"
|
|
|
|
"io/ioutil"
|
2015-07-25 16:19:29 +08:00
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/ScriptRock/sftp"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2015-07-31 14:43:00 +08:00
|
|
|
readOnly := false
|
|
|
|
debugLevelStr := "none"
|
|
|
|
debugLevel := 0
|
|
|
|
debugStderr := false
|
|
|
|
flag.BoolVar(&readOnly, "R", false, "read-only server")
|
|
|
|
flag.BoolVar(&debugStderr, "e", false, "debug to stderr")
|
|
|
|
flag.StringVar(&debugLevelStr, "l", "none", "debug level")
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
debugStream := ioutil.Discard
|
|
|
|
if debugStderr {
|
|
|
|
debugStream = os.Stderr
|
|
|
|
debugLevel = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
svr, _ := sftp.NewServer(os.Stdin, os.Stdout, debugStream, debugLevel, readOnly, "")
|
2015-07-25 16:19:29 +08:00
|
|
|
svr.Run()
|
|
|
|
}
|