mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
ssh commands: fix for rsync with no arguments
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -2278,8 +2278,8 @@ func TestRsyncArguments(t *testing.T) {
|
|||||||
assert.False(t, canAcceptRsyncArgs(args))
|
assert.False(t, canAcceptRsyncArgs(args))
|
||||||
args = []string{"--server", "--sender", "-vlogDtpre.", "--delete", ".", "/"}
|
args = []string{"--server", "--sender", "-vlogDtpre.", "--delete", ".", "/"}
|
||||||
assert.False(t, canAcceptRsyncArgs(args))
|
assert.False(t, canAcceptRsyncArgs(args))
|
||||||
args = []string{"--server", "--sender", "-e.iLsfxCIvu", "--delete", ".", "/"}
|
args = []string{"--server", "--sender", "-e.iLsfxCIvu", ".", "/"}
|
||||||
assert.False(t, canAcceptRsyncArgs(args))
|
assert.True(t, canAcceptRsyncArgs(args))
|
||||||
args = []string{"--server", "-vlogDtpre.iLsfxCIvu", "--delete", "/"}
|
args = []string{"--server", "-vlogDtpre.iLsfxCIvu", "--delete", "/"}
|
||||||
assert.False(t, canAcceptRsyncArgs(args))
|
assert.False(t, canAcceptRsyncArgs(args))
|
||||||
args = []string{"--server", "-vlogDtpre.iLsfxCIvu", "--delete", "--safe-links"}
|
args = []string{"--server", "-vlogDtpre.iLsfxCIvu", "--delete", "--safe-links"}
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ func canAcceptRsyncArgs(args []string) bool {
|
|||||||
// rsync --server -vlogDtpre.iLsfxCIvu --supported-options . ARG # push
|
// rsync --server -vlogDtpre.iLsfxCIvu --supported-options . ARG # push
|
||||||
// rsync --server --sender -vlogDtpre.iLsfxCIvu --supported-options . ARG # pull
|
// rsync --server --sender -vlogDtpre.iLsfxCIvu --supported-options . ARG # pull
|
||||||
//
|
//
|
||||||
// Then some options with a single dash and containing "e."" followed by
|
// Then some options with a single dash and containing "e." followed by
|
||||||
// supported options, listed in acceptedRsyncOptions, with double dash then
|
// supported options, listed in acceptedRsyncOptions, with double dash then
|
||||||
// dot and a finally single argument specifying the path to operate on.
|
// dot and a finally single argument specifying the path to operate on.
|
||||||
idx := 0
|
idx := 0
|
||||||
@@ -507,9 +507,9 @@ func canAcceptRsyncArgs(args []string) bool {
|
|||||||
if args[idx] == "--sender" {
|
if args[idx] == "--sender" {
|
||||||
idx++
|
idx++
|
||||||
}
|
}
|
||||||
// Check that this argument starts with a dash and contains e. but does start or end with e.
|
// Check that this argument starts with a dash and contains e. but does not
|
||||||
if !strings.HasPrefix(args[idx], "-") ||
|
// end with e.
|
||||||
strings.HasPrefix(args[idx], "--") || strings.HasPrefix(args[idx], "-e") ||
|
if !strings.HasPrefix(args[idx], "-") || strings.HasPrefix(args[idx], "--") ||
|
||||||
!strings.Contains(args[idx], "e.") || strings.HasSuffix(args[idx], "e.") {
|
!strings.Contains(args[idx], "e.") || strings.HasSuffix(args[idx], "e.") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user