diff options
author | Vincent Ambo <tazjin@gmail.com> | 2017-02-11T15·32+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2017-02-11T15·32+0100 |
commit | 4a85116b4a04765e13a0aa7c8b8a37778ef8dcbd (patch) | |
tree | d64ae7debdfd3af0278963f5eb621dc426ab87a8 /main.go | |
parent | 393cff48479e3cb065c00fc542c353c5ac29f0af (diff) |
fix: Remove trailing newlines from input
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/main.go b/main.go index 93a85324f192..9ac5598b1724 100644 --- a/main.go +++ b/main.go @@ -34,8 +34,8 @@ func main() { fmt.Fprintf(os.Stderr, "Could not read credentials: %v\n", err) } - fmt.Println("Requesting challenge from %s as user %s\n", host, *username) - challenge, err := triggerChallengeResponse(&host, username, password) + fmt.Println("Requesting challenge from %s as user %s\n", host, username) + challenge, err := triggerChallengeResponse(&host, &username, &password) if err != nil || challenge.LogonStatus != 4 { fmt.Fprintln(os.Stderr, "Did not receive challenge from server") @@ -54,17 +54,16 @@ func main() { fmt.Printf("Login succeeded, you may now (quickly) authenticate OpenVPN with %d as your password\n", token) } -func readCredentials() (*string, *string, error) { +func readCredentials() (string, string, error) { fmt.Printf("Username: ") reader := bufio.NewReader(os.Stdin) username, err := reader.ReadString('\n') fmt.Printf("Password: ") - passwordBytes, err := terminal.ReadPassword(1) - password := string(passwordBytes) + password, err := terminal.ReadPassword(1) // If an error occured, I don't care about which one it is. - return &username, &password, err + return strings.TrimSpace(username), strings.TrimSpace(string(password)), err } func triggerChallengeResponse(host *string, username *string, password *string) (r Resp, err error) { |