mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
backend/sftp: Add sftp.args option
Allow setting custom arguments for the `sftp` backend, by using the `sftp.args` option. This is similar to the approach already implemented in the `rclone` backend, to support new arguments without requiring future code changes for each different SSH argument. Closes #4241
This commit is contained in:
committed by
Michael Eischer
parent
17f2301cc2
commit
41f70f1f4f
@@ -213,6 +213,9 @@ func buildSSHCommand(cfg Config) (cmd string, args []string, err error) {
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
if cfg.Args != "" {
|
||||
return "", nil, errors.New("cannot specify both sftp.command and sftp.args options")
|
||||
}
|
||||
|
||||
return args[0], args[1:], nil
|
||||
}
|
||||
@@ -226,11 +229,19 @@ func buildSSHCommand(cfg Config) (cmd string, args []string, err error) {
|
||||
args = append(args, "-p", port)
|
||||
}
|
||||
if cfg.User != "" {
|
||||
args = append(args, "-l")
|
||||
args = append(args, cfg.User)
|
||||
args = append(args, "-l", cfg.User)
|
||||
}
|
||||
args = append(args, "-s")
|
||||
args = append(args, "sftp")
|
||||
|
||||
if cfg.Args != "" {
|
||||
a, err := backend.SplitShellStrings(cfg.Args)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
args = append(args, a...)
|
||||
}
|
||||
|
||||
args = append(args, "-s", "sftp")
|
||||
return cmd, args, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user