ソースを参照

sftpd: improve logging if filesystem creation fails

Nicola Murino 4 年 前
コミット
1cde50f050
2 ファイル変更11 行追加0 行削除
  1. 4 0
      sftpd/server.go
  2. 7 0
      sftpd/sftpd_test.go

+ 4 - 0
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 {

+ 7 - 0
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)