Change back to original goconfig package.

Add documentation for `--ask-password`.
This commit is contained in:
klauspost 2016-02-17 11:45:05 +01:00
parent bfd7601cf9
commit 84b00b362f
2 changed files with 12 additions and 6 deletions

View File

@ -501,6 +501,12 @@ If it is safe in your environment, you can set the `RCLONE_CONFIG_PASS`
environment variable to contain your password, in which case it will be environment variable to contain your password, in which case it will be
used for decrypting the configuration. used for decrypting the configuration.
If you are running rclone inside a script, you might want to disable
password prompts. To do that, pass the parameter
`--ask-password=false` to rclone. This will make rclone fail instead
of asking for a password, if if `RCLONE_CONFIG_PASS` doesn't contain
a valid password.
Developer options Developer options
----------------- -----------------

View File

@ -24,7 +24,7 @@ import (
"time" "time"
"unicode/utf8" "unicode/utf8"
"github.com/klauspost/goconfig" "github.com/Unknwon/goconfig"
"github.com/mreiferson/go-httpclient" "github.com/mreiferson/go-httpclient"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"golang.org/x/crypto/nacl/secretbox" "golang.org/x/crypto/nacl/secretbox"
@ -325,8 +325,8 @@ func LoadConfig() {
func loadConfigFile() (*goconfig.ConfigFile, error) { func loadConfigFile() (*goconfig.ConfigFile, error) {
b, err := ioutil.ReadFile(ConfigPath) b, err := ioutil.ReadFile(ConfigPath)
if err != nil { if err != nil {
log.Printf("Failed to load config file %v - using defaults: %v", ConfigPath, err) log.Printf("Failed to load config file \"%v\" - using defaults: %v", ConfigPath, err)
return goconfig.LoadFromData(nil) return goconfig.LoadFromReader(&bytes.Buffer{})
} }
// Find first non-empty line // Find first non-empty line
@ -335,7 +335,7 @@ func loadConfigFile() (*goconfig.ConfigFile, error) {
line, _, err := r.ReadLine() line, _, err := r.ReadLine()
if err != nil { if err != nil {
if err == io.EOF { if err == io.EOF {
return goconfig.LoadFromData(b) return goconfig.LoadFromReader(bytes.NewBuffer(b))
} }
return nil, err return nil, err
} }
@ -350,7 +350,7 @@ func loadConfigFile() (*goconfig.ConfigFile, error) {
if strings.HasPrefix(l, "RCLONE_ENCRYPT_V") { if strings.HasPrefix(l, "RCLONE_ENCRYPT_V") {
return nil, fmt.Errorf("Unsupported configuration encryption. Update rclone for support.") return nil, fmt.Errorf("Unsupported configuration encryption. Update rclone for support.")
} }
return goconfig.LoadFromData(b) return goconfig.LoadFromReader(bytes.NewBuffer(b))
} }
// Encrypted content is base64 encoded. // Encrypted content is base64 encoded.
@ -400,7 +400,7 @@ func loadConfigFile() (*goconfig.ConfigFile, error) {
configKey = nil configKey = nil
envpw = "" envpw = ""
} }
return goconfig.LoadFromData(out) return goconfig.LoadFromReader(bytes.NewBuffer(out))
} }
// getPassword will query the user for a password the // getPassword will query the user for a password the