1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-11 13:53:15 +00:00

config: add error if RCLONE_CONFIG_PASS was supplied but didn't decrypt config

This commit is contained in:
n4n5
2025-07-25 12:24:18 +02:00
committed by GitHub
parent 30d8ab5f2f
commit ff9cbab5fa

View File

@@ -51,6 +51,7 @@ func Decrypt(b io.ReadSeeker) (io.Reader, error) {
ctx := context.Background() ctx := context.Background()
ci := fs.GetConfig(ctx) ci := fs.GetConfig(ctx)
var usingPasswordCommand bool var usingPasswordCommand bool
var usingEnvPassword bool
// Find first non-empty line // Find first non-empty line
r := bufio.NewReader(b) r := bufio.NewReader(b)
@@ -99,15 +100,18 @@ func Decrypt(b io.ReadSeeker) (io.Reader, error) {
} else { } else {
usingPasswordCommand = false usingPasswordCommand = false
envpw := os.Getenv("RCLONE_CONFIG_PASS") envPassword := os.Getenv("RCLONE_CONFIG_PASS")
if envpw != "" { if envPassword != "" {
err := SetConfigPassword(envpw) usingEnvPassword = true
err := SetConfigPassword(envPassword)
if err != nil { if err != nil {
fs.Errorf(nil, "Using RCLONE_CONFIG_PASS returned: %v", err) fs.Errorf(nil, "Using RCLONE_CONFIG_PASS returned: %v", err)
} else { } else {
fs.Debugf(nil, "Using RCLONE_CONFIG_PASS password.") fs.Debugf(nil, "Using RCLONE_CONFIG_PASS password.")
} }
} else {
usingEnvPassword = false
} }
} }
} }
@@ -144,6 +148,9 @@ func Decrypt(b io.ReadSeeker) (io.Reader, error) {
if usingPasswordCommand { if usingPasswordCommand {
return nil, errors.New("using --password-command derived password, unable to decrypt configuration") return nil, errors.New("using --password-command derived password, unable to decrypt configuration")
} }
if usingEnvPassword {
return nil, errors.New("using RCLONE_CONFIG_PASS env password, unable to decrypt configuration")
}
if !ci.AskPassword { if !ci.AskPassword {
return nil, errors.New("unable to decrypt configuration and not allowed to ask for password - set RCLONE_CONFIG_PASS to your configuration password") return nil, errors.New("unable to decrypt configuration and not allowed to ask for password - set RCLONE_CONFIG_PASS to your configuration password")
} }