From 6754ab823fba420ccfec2cd9d7d90075d0d7a516 Mon Sep 17 00:00:00 2001 From: Ari Edelkind Date: Tue, 3 Oct 2017 20:08:29 -0700 Subject: [PATCH 1/2] Create config dirs when generating account key. --- config.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index eda72ba..126d4ec 100644 --- a/config.go +++ b/config.go @@ -86,7 +86,11 @@ func readConfig() (*userConfig, error) { return uc, nil } -// writeConfig writes uc to a file specified by path, creating paret dirs +func mkConfigDirs() error { + return os.MkdirAll(configDir, 0700) +} + +// writeConfig writes uc to a file specified by path, creating parent dirs // along the way. If file does not exists, it will be created with 0600 mod. // This function does not store uc.key. //func writeConfig(path string, uc *userConfig) error { @@ -95,7 +99,7 @@ func writeConfig(uc *userConfig) error { if err != nil { return err } - if err := os.MkdirAll(configDir, 0700); err != nil { + if err := mkConfigDirs(); err != nil { return err } return ioutil.WriteFile(filepath.Join(configDir, accountFile), b, 0600) @@ -124,7 +128,11 @@ func readKey(path string) (crypto.Signer, error) { // writeKey writes k to the specified path in PEM format. // If file does not exists, it will be created with 0600 mod. +// Parent directories will be created along the way. func writeKey(path string, k *ecdsa.PrivateKey) error { + if err := mkConfigDirs(); err != nil { + return err + } f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err From 68896bd428482be64b4eed5c0726fd2ebfca2271 Mon Sep 17 00:00:00 2001 From: Ari Edelkind Date: Wed, 4 Oct 2017 00:07:52 -0700 Subject: [PATCH 2/2] Make acceptance default text reflect reality. --- reg.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reg.go b/reg.go index 7143c95..71c13fb 100644 --- a/reg.go +++ b/reg.go @@ -98,7 +98,7 @@ func runReg(args []string) { func ttyPrompt(tos string) bool { fmt.Println("CA requires acceptance of their Terms and Services agreement:") fmt.Println(tos) - fmt.Print("Do you accept? (Y/n) ") + fmt.Print("Do you accept? (y/N) ") var a string if _, err := fmt.Scanln(&a); err != nil { return false