mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-22 07:30:25 +00:00
sftpd: send exit-status message on close
this fix restic compatibility
This commit is contained in:
parent
08e85f6be9
commit
5be1d1be69
2 changed files with 10 additions and 5 deletions
|
@ -28,10 +28,6 @@ type execMsg struct {
|
||||||
Command string
|
Command string
|
||||||
}
|
}
|
||||||
|
|
||||||
type exitStatusMsg struct {
|
|
||||||
Status uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
type scpCommand struct {
|
type scpCommand struct {
|
||||||
connection Connection
|
connection Connection
|
||||||
args []string
|
args []string
|
||||||
|
|
|
@ -30,6 +30,10 @@ const defaultPrivateKeyName = "id_rsa"
|
||||||
|
|
||||||
var sftpExtensions = []string{"posix-rename@openssh.com"}
|
var sftpExtensions = []string{"posix-rename@openssh.com"}
|
||||||
|
|
||||||
|
type exitStatusMsg struct {
|
||||||
|
Status uint32
|
||||||
|
}
|
||||||
|
|
||||||
// Configuration for the SFTP server
|
// Configuration for the SFTP server
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
// Identification string used by the server
|
// Identification string used by the server
|
||||||
|
@ -329,7 +333,12 @@ func (c Configuration) handleSftpConnection(channel ssh.Channel, connection Conn
|
||||||
server := sftp.NewRequestServer(channel, handler)
|
server := sftp.NewRequestServer(channel, handler)
|
||||||
|
|
||||||
if err := server.Serve(); err == io.EOF {
|
if err := server.Serve(); err == io.EOF {
|
||||||
connection.Log(logger.LevelDebug, logSender, "connection closed")
|
connection.Log(logger.LevelDebug, logSender, "connection closed, sending exit-status")
|
||||||
|
ex := exitStatusMsg{
|
||||||
|
Status: 0,
|
||||||
|
}
|
||||||
|
_, err = channel.SendRequest("exit-status", false, ssh.Marshal(&ex))
|
||||||
|
connection.Log(logger.LevelDebug, logSender, "send exit status error: %v", err)
|
||||||
server.Close()
|
server.Close()
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
connection.Log(logger.LevelWarn, logSender, "connection closed with error: %v", err)
|
connection.Log(logger.LevelWarn, logSender, "connection closed with error: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue