aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-03-31 05:20:06 +0800
committerFelix Lange <fjl@twurst.com>2016-04-12 21:59:18 +0800
commitea005a02950513603b7346ef39bc76dc53b82863 (patch)
tree801666d41e899ee85895e46b431ebb1a959d38b1 /cmd
parentaca9d6a1fb4c2b01d1b8f6e1bf165a39d4b9ac8e (diff)
downloaddexon-ea005a02950513603b7346ef39bc76dc53b82863.tar.gz
dexon-ea005a02950513603b7346ef39bc76dc53b82863.tar.zst
dexon-ea005a02950513603b7346ef39bc76dc53b82863.zip
cmd/utils: fix --password on Windows
Text files created on Windows typically have \r\n line endings. Trim them when reading password files.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/utils/flags.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index da29ceb09..ceed04cd3 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -606,17 +606,22 @@ func MakeMinerExtra(extra []byte, ctx *cli.Context) []byte {
return extra
}
-// MakePasswordList loads up a list of password from a file specified by the
-// command line flags.
+// MakePasswordList reads password lines from the file specified by --password.
func MakePasswordList(ctx *cli.Context) []string {
- if path := ctx.GlobalString(PasswordFileFlag.Name); path != "" {
- blob, err := ioutil.ReadFile(path)
- if err != nil {
- Fatalf("Failed to read password file: %v", err)
- }
- return strings.Split(string(blob), "\n")
+ path := ctx.GlobalString(PasswordFileFlag.Name)
+ if path == "" {
+ return nil
+ }
+ text, err := ioutil.ReadFile(path)
+ 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