aboutsummaryrefslogtreecommitdiff
path: root/password.go
diff options
context:
space:
mode:
Diffstat (limited to 'password.go')
-rw-r--r--password.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/password.go b/password.go
index 935ff87..01c71a7 100644
--- a/password.go
+++ b/password.go
@@ -7,16 +7,18 @@ import (
"strings"
"golang.org/x/crypto/ssh/terminal"
+
+ "github.com/rfjakob/gocryptfs/internal/toggledlog"
)
func readPasswordTwice(extpass string) string {
if extpass == "" {
- fmt.Printf("Password: ")
+ fmt.Fprintf(os.Stderr, "Password: ")
p1 := readPassword("")
- fmt.Printf("Repeat: ")
+ fmt.Fprintf(os.Stderr, "Repeat: ")
p2 := readPassword("")
if p1 != p2 {
- fmt.Println(colorRed + "Passwords do not match" + colorReset)
+ toggledlog.Fatal.Println(colorRed + "Passwords do not match" + colorReset)
os.Exit(ERREXIT_PASSWORD)
}
return p1
@@ -37,7 +39,7 @@ func readPassword(extpass string) string {
cmd.Stderr = os.Stderr
output, err = cmd.Output()
if err != nil {
- fmt.Printf(colorRed+"extpass program returned error: %v\n"+colorReset, err)
+ toggledlog.Fatal.Printf(colorRed+"extpass program returned error: %v\n"+colorReset, err)
os.Exit(ERREXIT_PASSWORD)
}
// Trim trailing newline like terminal.ReadPassword() does
@@ -48,14 +50,14 @@ func readPassword(extpass string) string {
fd := int(os.Stdin.Fd())
output, err = terminal.ReadPassword(fd)
if err != nil {
- fmt.Printf(colorRed+"Could not read password from terminal: %v\n"+colorReset, err)
+ toggledlog.Fatal.Printf(colorRed+"Could not read password from terminal: %v\n"+colorReset, err)
os.Exit(ERREXIT_PASSWORD)
}
- fmt.Printf("\n")
+ fmt.Fprintf(os.Stderr, "\n")
}
password = string(output)
if password == "" {
- fmt.Printf(colorRed + "Password is empty\n" + colorReset)
+ toggledlog.Fatal.Printf(colorRed + "Password is empty\n" + colorReset)
os.Exit(ERREXIT_PASSWORD)
}
return password