Unverified Commit e758f922 authored by Eric_Lee's avatar Eric_Lee Committed by GitHub

Merge pull request #146 from jumpserver/dev_bugfix

[bugfix] fix bugs
parents b4ed7c7a 952f26c1
...@@ -34,7 +34,7 @@ func SftpHandler(sess ssh.Session) { ...@@ -34,7 +34,7 @@ func SftpHandler(sess ssh.Session) {
logger.Infof("SFTP request %s: Handler start", reqID) logger.Infof("SFTP request %s: Handler start", reqID)
req := sftp.NewRequestServer(sess, handlers) req := sftp.NewRequestServer(sess, handlers)
if err := req.Serve(); err == io.EOF { if err := req.Serve(); err == io.EOF {
logger.Debug("SFTP request %s: Exited session.", reqID) logger.Debugf("SFTP request %s: Exited session.", reqID)
} else if err != nil { } else if err != nil {
logger.Errorf("SFTP request %s: Server completed with error %s", reqID, err) logger.Errorf("SFTP request %s: Server completed with error %s", reqID, err)
} }
...@@ -82,7 +82,7 @@ func (fs *sftpHandler) Filecmd(r *sftp.Request) (err error) { ...@@ -82,7 +82,7 @@ func (fs *sftpHandler) Filecmd(r *sftp.Request) (err error) {
case "Setstat": case "Setstat":
return return
case "Rename": case "Rename":
logger.Debug("%s=>%s", r.Filepath, r.Target) logger.Debugf("%s=>%s", r.Filepath, r.Target)
return fs.Rename(r.Filepath, r.Target) return fs.Rename(r.Filepath, r.Target)
case "Rmdir": case "Rmdir":
err = fs.RemoveDirectory(r.Filepath) err = fs.RemoveDirectory(r.Filepath)
...@@ -91,7 +91,7 @@ func (fs *sftpHandler) Filecmd(r *sftp.Request) (err error) { ...@@ -91,7 +91,7 @@ func (fs *sftpHandler) Filecmd(r *sftp.Request) (err error) {
case "Mkdir": case "Mkdir":
err = fs.MkdirAll(r.Filepath) err = fs.MkdirAll(r.Filepath)
case "Symlink": case "Symlink":
logger.Debug("%s=>%s", r.Filepath, r.Target) logger.Debugf("%s=>%s", r.Filepath, r.Target)
err = fs.Symlink(r.Filepath, r.Target) err = fs.Symlink(r.Filepath, r.Target)
default: default:
return return
......
...@@ -61,6 +61,11 @@ func (w *WrapperSession) Read(p []byte) (int, error) { ...@@ -61,6 +61,11 @@ func (w *WrapperSession) Read(p []byte) (int, error) {
} }
func (w *WrapperSession) Close() error { func (w *WrapperSession) Close() error {
select {
case <-w.closed:
return nil
default:
}
err := w.inWriter.Close() err := w.inWriter.Close()
w.initReadPip() w.initReadPip()
return err return err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment