sftpd: explicitly configure supported SFTP extensions

update pkg/sftp to a git revision that includes the needed patch

https://github.com/pkg/sftp/pull/315
This commit is contained in:
Nicola Murino
2019-11-12 07:37:47 +01:00
parent 74367a65cc
commit 363b9ccc7f
4 changed files with 30 additions and 3 deletions

View File

@@ -28,6 +28,8 @@ import (
const defaultPrivateKeyName = "id_rsa"
var sftpExtensions = []string{"posix-rename@openssh.com"}
// Configuration for the SFTP server
type Configuration struct {
// Identification string used by the server
@@ -153,6 +155,7 @@ func (c Configuration) Initialize(configDir string) error {
c.configureSecurityOptions(serverConfig)
c.configureLoginBanner(serverConfig, configDir)
c.configureSFTPExtensions()
listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", c.BindAddress, c.BindPort))
if err != nil {
@@ -208,6 +211,15 @@ func (c Configuration) configureLoginBanner(serverConfig *ssh.ServerConfig, conf
return err
}
func (c Configuration) configureSFTPExtensions() error {
err := sftp.SetSFTPExtensions(sftpExtensions...)
if err != nil {
logger.WarnToConsole("unable to configure SFTP extensions: %v", err)
logger.Warn(logSender, "", "unable to configure SFTP extensions: %v", err)
}
return err
}
// AcceptInboundConnection handles an inbound connection to the server instance and determines if the request should be served or not.
func (c Configuration) AcceptInboundConnection(conn net.Conn, config *ssh.ServerConfig) {