Commit ea005a02 authored by Felix Lange's avatar Felix Lange

cmd/utils: fix --password on Windows

Text files created on Windows typically have \r\n line endings.
Trim them when reading password files.
parent aca9d6a1
...@@ -606,17 +606,22 @@ func MakeMinerExtra(extra []byte, ctx *cli.Context) []byte { ...@@ -606,17 +606,22 @@ func MakeMinerExtra(extra []byte, ctx *cli.Context) []byte {
return extra return extra
} }
// MakePasswordList loads up a list of password from a file specified by the // MakePasswordList reads password lines from the file specified by --password.
// command line flags.
func MakePasswordList(ctx *cli.Context) []string { func MakePasswordList(ctx *cli.Context) []string {
if path := ctx.GlobalString(PasswordFileFlag.Name); path != "" { path := ctx.GlobalString(PasswordFileFlag.Name)
blob, err := ioutil.ReadFile(path) if path == "" {
if err != nil { return nil
Fatalf("Failed to read password file: %v", err) }
} text, err := ioutil.ReadFile(path)
return strings.Split(string(blob), "\n") if err != nil {
Fatalf("Failed to read password file: %v", err)
}
lines := strings.Split(string(text), "\n")
// Sanitise DOS line endings.
for i := range lines {
lines[i] = strings.TrimRight(lines[i], "\r")
} }
return nil return lines
} }
// MakeSystemNode sets up a local node, configures the services to launch and // MakeSystemNode sets up a local node, configures the services to launch and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment