sftpd: improve logging if filesystem creation fails

This commit is contained in:
Nicola Murino 2021-02-03 09:45:04 +01:00
parent e9dd4ecdf0
commit 1cde50f050
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB
2 changed files with 11 additions and 0 deletions

View file

@ -456,6 +456,8 @@ func (c *Configuration) AcceptInboundConnection(conn net.Conn, config *ssh.Serve
channel: channel,
}
go c.handleSftpConnection(channel, &connection)
} else {
logger.Debug(logSender, connID, "unable to create filesystem: %v", err)
}
}
case "exec":
@ -469,6 +471,8 @@ func (c *Configuration) AcceptInboundConnection(conn net.Conn, config *ssh.Serve
channel: channel,
}
ok = processSSHCommand(req.Payload, &connection, c.EnabledSSHCommands)
} else {
logger.Debug(sshCommandLogSender, connID, "unable to create filesystem: %v", err)
}
}
if req.WantReply {

View file

@ -1070,12 +1070,19 @@ func TestSFTPFsLoginWrongFingerprint(t *testing.T) {
assert.NoError(t, err)
}
out, err := runSSHCommand("md5sum", sftpUser, usePubKey)
assert.NoError(t, err)
assert.Contains(t, string(out), "d41d8cd98f00b204e9800998ecf8427e")
sftpUser.FsConfig.SFTPConfig.Fingerprints = []string{"wrong"}
_, _, err = httpdtest.UpdateUser(sftpUser, http.StatusOK, "")
assert.NoError(t, err)
_, err = getSftpClient(sftpUser, usePubKey)
assert.Error(t, err)
_, err = runSSHCommand("md5sum", sftpUser, usePubKey)
assert.Error(t, err)
_, err = httpdtest.RemoveUser(sftpUser, http.StatusOK)
assert.NoError(t, err)
_, err = httpdtest.RemoveUser(localUser, http.StatusOK)