From 1cde50f05070c0b533b6c30aa1368eb4ed73e02a Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Wed, 3 Feb 2021 09:45:04 +0100 Subject: [PATCH] sftpd: improve logging if filesystem creation fails --- sftpd/server.go | 4 ++++ sftpd/sftpd_test.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/sftpd/server.go b/sftpd/server.go index df70a03b..aa6a4a52 100644 --- a/sftpd/server.go +++ b/sftpd/server.go @@ -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 { diff --git a/sftpd/sftpd_test.go b/sftpd/sftpd_test.go index d25027ae..668f99aa 100644 --- a/sftpd/sftpd_test.go +++ b/sftpd/sftpd_test.go @@ -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)