From 30ac9d920a695f6100818fc5055b7a174e816350 Mon Sep 17 00:00:00 2001 From: Wojciech Smigielski Date: Wed, 29 May 2019 01:41:12 +0200 Subject: [PATCH] enable creating encrypted config through external script invocation - fixes #3127 --- fs/config/config.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/config/config.go b/fs/config/config.go index 01230f77b..37c989607 100644 --- a/fs/config/config.go +++ b/fs/config/config.go @@ -226,8 +226,17 @@ var errorConfigFileNotFound = errors.New("config file not found") // automatically decrypt it. func loadConfigFile() (*goconfig.ConfigFile, error) { b, err := ioutil.ReadFile(ConfigPath) + envpw := os.Getenv("RCLONE_CONFIG_PASS") if err != nil { 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, err @@ -266,7 +275,6 @@ func loadConfigFile() (*goconfig.ConfigFile, error) { if len(box) < 24+secretbox.Overhead { return nil, errors.New("Configuration data too short") } - envpw := os.Getenv("RCLONE_CONFIG_PASS") var out []byte for {