scp: minor improvements

document that we don't support wildcard expansion.

I should refactor scp code ...
This commit is contained in:
Nicola Murino 2021-01-05 22:32:30 +01:00
parent aa40b04576
commit a8a17a223a
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB
2 changed files with 6 additions and 5 deletions

View file

@ -32,7 +32,7 @@ If the user cannot create symlinks we add the option `--munge-links`, if it is n
SFTPGo supports the following built-in SSH commands: SFTPGo supports the following built-in SSH commands:
- `scp`, SFTPGo implements the SCP protocol so we can support it for cloud filesystems too and we can avoid the other system commands limitations. SCP between two remote hosts is supported using the `-3` scp option. - `scp`, SFTPGo implements the SCP protocol so we can support it for cloud filesystems too and we can avoid the other system commands limitations. SCP between two remote hosts is supported using the `-3` scp option. Wildcard expansion is not supported.
- `md5sum`, `sha1sum`, `sha256sum`, `sha384sum`, `sha512sum`. Useful to check message digests for uploaded files. - `md5sum`, `sha1sum`, `sha256sum`, `sha384sum`, `sha512sum`. Useful to check message digests for uploaded files.
- `cd`, `pwd`. Some SFTP clients do not support the SFTP SSH_FXP_REALPATH packet type, so they use `cd` and `pwd` SSH commands to get the initial directory. Currently `cd` does nothing and `pwd` always returns the `/` path. These commands will work with any storage backend but keep in mind that to calculate the hash we need to read the whole file, for remote backends this means downloading the file, for the encrypted backend this means decrypting the file. - `cd`, `pwd`. Some SFTP clients do not support the SFTP SSH_FXP_REALPATH packet type, so they use `cd` and `pwd` SSH commands to get the initial directory. Currently `cd` does nothing and `pwd` always returns the `/` path. These commands will work with any storage backend but keep in mind that to calculate the hash we need to read the whole file, for remote backends this means downloading the file, for the encrypted backend this means decrypting the file.
- `sftpgo-copy`. This is a built-in copy implementation. It allows server side copy for files and directories. The first argument is the source file/directory and the second one is the destination file/directory, for example `sftpgo-copy <src> <dst>`. The command will fail if the destination exists. Copy for directories spanning virtual folders is not supported. Only local filesystem is supported: recursive copy for Cloud Storage filesystems requires a new request for every file in any case, so a real server side copy is not possible. - `sftpgo-copy`. This is a built-in copy implementation. It allows server side copy for files and directories. The first argument is the source file/directory and the second one is the destination file/directory, for example `sftpgo-copy <src> <dst>`. The command will fail if the destination exists. Copy for directories spanning virtual folders is not supported. Only local filesystem is supported: recursive copy for Cloud Storage filesystems requires a new request for every file in any case, so a real server side copy is not possible.

View file

@ -541,7 +541,7 @@ func (c *scpCommand) readConfirmationMessage() error {
break break
} }
if n > 0 { if n > 0 {
msg.WriteString(string(readed)) msg.Write(readed)
} }
} }
c.connection.Log(logger.LevelInfo, "scp error message received: %v is error: %v", msg.String(), isError) c.connection.Log(logger.LevelInfo, "scp error message received: %v is error: %v", msg.String(), isError)
@ -567,7 +567,7 @@ func (c *scpCommand) readProtocolMessage() (string, error) {
if n == 1 && readed[0] == newLine[0] { if n == 1 && readed[0] == newLine[0] {
break break
} }
command.WriteString(string(readed)) command.Write(readed)
} }
} }
if err != nil { if err != nil {
@ -605,7 +605,6 @@ func (c *scpCommand) sendProtocolMessage(message string) error {
} }
// get the next upload protocol message ignoring T command if any // get the next upload protocol message ignoring T command if any
// we use our own user setting for permissions
func (c *scpCommand) getNextUploadProtocolMessage() (string, error) { func (c *scpCommand) getNextUploadProtocolMessage() (string, error) {
var command string var command string
var err error var err error
@ -631,6 +630,8 @@ func (c *scpCommand) createDir(dirPath string) error {
var isDir bool var isDir bool
isDir, err = vfs.IsDirectory(c.connection.Fs, dirPath) isDir, err = vfs.IsDirectory(c.connection.Fs, dirPath)
if err == nil && isDir { if err == nil && isDir {
// if this is a virtual dir the resolved path will exist, we don't need a specific check
// TODO: remember to check if it's okay when we'll add virtual folders support to cloud backends
c.connection.Log(logger.LevelDebug, "directory %#v already exists", dirPath) c.connection.Log(logger.LevelDebug, "directory %#v already exists", dirPath)
return nil return nil
} }
@ -675,7 +676,7 @@ func (c *scpCommand) parseUploadMessage(command string) (int64, string, error) {
return size, name, err return size, name, err
} }
} else { } else {
err = fmt.Errorf("Error splitting upload message: %#v", command) err = fmt.Errorf("unable to split upload message: %#v", command)
c.connection.Log(logger.LevelWarn, "error: %v", err) c.connection.Log(logger.LevelWarn, "error: %v", err)
c.sendErrorMessage(err) c.sendErrorMessage(err)
return size, name, err return size, name, err