From d25b883873d61bdd913a7c31443b21fc2b58e462 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Sun, 16 Sep 2018 17:30:02 -0700 Subject: [PATCH] Fixed bug in fallback from authtoken (-g) to password login --- hkexauth.go | 4 ++-- hkexsh/hkexsh.go | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/hkexauth.go b/hkexauth.go index 7806512..c5018f6 100644 --- a/hkexauth.go +++ b/hkexauth.go @@ -94,8 +94,8 @@ func AuthUserByToken(username string, connhostname string, auth string) (valid b } record[0] = strings.TrimSpace(record[0]) record[1] = strings.TrimSpace(record[1]) - fmt.Println("auth:", auth, "record:", - strings.Join([]string{record[0], record[1]}, ":")) + //fmt.Println("auth:", auth, "record:", + // strings.Join([]string{record[0], record[1]}, ":")) if (connhostname == record[0]) && (auth == strings.Join([]string{record[0], record[1]}, ":")) { diff --git a/hkexsh/hkexsh.go b/hkexsh/hkexsh.go index b4862c4..4427e06 100755 --- a/hkexsh/hkexsh.go +++ b/hkexsh/hkexsh.go @@ -482,21 +482,20 @@ func main() { idx := strings.Index(string(ab), remoteHost) if idx >= 0 { ab = ab[idx:] + entries := strings.SplitN(string(ab), "\n", -1) + //if len(entries) > 0 { + //fmt.Println("entries[0]:", entries[0]) + authCookie = strings.TrimSpace(entries[0]) + //} else { + // fmt.Fprintln(os.Stderr, "ERROR: no matching authtoken") + // os.Exit(1) + //} + // Security scrub + ab = nil + runtime.GC() } else { fmt.Fprintln(os.Stderr, "ERROR: no matching authtoken") - os.Exit(1) } - entries := strings.SplitN(string(ab), "\n", -1) - //if len(entries) > 0 { - //fmt.Println("entries[0]:", entries[0]) - authCookie = strings.TrimSpace(entries[0]) - //} else { - // fmt.Fprintln(os.Stderr, "ERROR: no matching authtoken") - // os.Exit(1) - //} - // Security scrub - ab = nil - runtime.GC() } }