mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 02:14:42 +01:00
ftp: add --ftp-ask-password to prompt for password when needed
This commit is contained in:
parent
ae395d8cf0
commit
627ac1b2d9
@ -61,7 +61,6 @@ func init() {
|
|||||||
Name: "pass",
|
Name: "pass",
|
||||||
Help: "FTP password.",
|
Help: "FTP password.",
|
||||||
IsPassword: true,
|
IsPassword: true,
|
||||||
Required: true,
|
|
||||||
}, {
|
}, {
|
||||||
Name: "tls",
|
Name: "tls",
|
||||||
Help: `Use Implicit FTPS (FTP over TLS).
|
Help: `Use Implicit FTPS (FTP over TLS).
|
||||||
@ -139,6 +138,14 @@ Enabled by default. Use 0 to disable.`,
|
|||||||
Help: "Maximum time to wait for data connection closing status.",
|
Help: "Maximum time to wait for data connection closing status.",
|
||||||
Default: fs.Duration(60 * time.Second),
|
Default: fs.Duration(60 * time.Second),
|
||||||
Advanced: true,
|
Advanced: true,
|
||||||
|
}, {
|
||||||
|
Name: "ask_password",
|
||||||
|
Default: false,
|
||||||
|
Help: `Allow asking for FTP password when needed.
|
||||||
|
|
||||||
|
If this is set and no password is supplied then rclone will ask for a password
|
||||||
|
`,
|
||||||
|
Advanced: true,
|
||||||
}, {
|
}, {
|
||||||
Name: config.ConfigEncoding,
|
Name: config.ConfigEncoding,
|
||||||
Help: config.ConfigEncodingHelp,
|
Help: config.ConfigEncodingHelp,
|
||||||
@ -179,6 +186,7 @@ type Options struct {
|
|||||||
IdleTimeout fs.Duration `config:"idle_timeout"`
|
IdleTimeout fs.Duration `config:"idle_timeout"`
|
||||||
CloseTimeout fs.Duration `config:"close_timeout"`
|
CloseTimeout fs.Duration `config:"close_timeout"`
|
||||||
ShutTimeout fs.Duration `config:"shut_timeout"`
|
ShutTimeout fs.Duration `config:"shut_timeout"`
|
||||||
|
AskPassword bool `config:"ask_password"`
|
||||||
Enc encoder.MultiEncoder `config:"encoding"`
|
Enc encoder.MultiEncoder `config:"encoding"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,9 +452,14 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (ff fs.Fs
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pass, err := obscure.Reveal(opt.Pass)
|
pass := ""
|
||||||
if err != nil {
|
if opt.AskPassword && opt.Pass == "" {
|
||||||
return nil, fmt.Errorf("NewFS decrypt password: %w", err)
|
pass = config.GetPassword("FTP server password")
|
||||||
|
} else {
|
||||||
|
pass, err = obscure.Reveal(opt.Pass)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("NewFS decrypt password: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
user := opt.User
|
user := opt.User
|
||||||
if user == "" {
|
if user == "" {
|
||||||
|
@ -180,6 +180,15 @@ FTP password.
|
|||||||
- Type: string
|
- Type: string
|
||||||
- Default: ""
|
- Default: ""
|
||||||
|
|
||||||
|
#### --ftp-ask-password
|
||||||
|
|
||||||
|
Ask for password when connecting to a FTP server and no password is configured.
|
||||||
|
|
||||||
|
- Config: ask_password
|
||||||
|
- Env Var: RCLONE_FTP_ASK_PASSWORD
|
||||||
|
- Type: bool
|
||||||
|
- Default: false
|
||||||
|
|
||||||
#### --ftp-tls
|
#### --ftp-tls
|
||||||
|
|
||||||
Use Implicit FTPS (FTP over TLS).
|
Use Implicit FTPS (FTP over TLS).
|
||||||
|
Loading…
Reference in New Issue
Block a user