Merge 10da5fc487b9ca524111176336e5482c9b739b7c into 0b9671313b14ffe839ecbd7dd2ae5ac7f6f05db8

This commit is contained in:
n4n5 2025-04-11 19:29:46 +05:30 committed by GitHub
commit 95c9011da1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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