enable creating encrypted config through external script invocation - fixes #3127

This commit is contained in:
Wojciech Smigielski 2019-05-29 01:41:12 +02:00 committed by Nick Craig-Wood
parent 6e8e620e71
commit 30ac9d920a

View File

@ -226,8 +226,17 @@ var errorConfigFileNotFound = errors.New("config file not found")
// automatically decrypt it. // automatically decrypt it.
func loadConfigFile() (*goconfig.ConfigFile, error) { func loadConfigFile() (*goconfig.ConfigFile, error) {
b, err := ioutil.ReadFile(ConfigPath) b, err := ioutil.ReadFile(ConfigPath)
envpw := os.Getenv("RCLONE_CONFIG_PASS")
if err != nil { if err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
if len(configKey) == 0 && envpw != "" {
err := setConfigPassword(envpw)
if err != nil {
fmt.Println("Using RCLONE_CONFIG_PASS returned:", err)
} else {
fs.Debugf(nil, "Using RCLONE_CONFIG_PASS password.")
}
}
return nil, errorConfigFileNotFound return nil, errorConfigFileNotFound
} }
return nil, err return nil, err
@ -266,7 +275,6 @@ func loadConfigFile() (*goconfig.ConfigFile, error) {
if len(box) < 24+secretbox.Overhead { if len(box) < 24+secretbox.Overhead {
return nil, errors.New("Configuration data too short") return nil, errors.New("Configuration data too short")
} }
envpw := os.Getenv("RCLONE_CONFIG_PASS")
var out []byte var out []byte
for { for {