From 0d404470c199bf5fb637d1dfef18b9f45535ebc8 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Sat, 14 Jul 2018 13:15:58 -0700 Subject: [PATCH] Make hkexshd log IP not hostname to wtmp/lastlog --- hkexshd/hkexshd.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hkexshd/hkexshd.go b/hkexshd/hkexshd.go index 5d28f75..97a624e 100644 --- a/hkexshd/hkexshd.go +++ b/hkexshd/hkexshd.go @@ -17,6 +17,7 @@ import ( "os/exec" "os/user" "runtime" + "strings" "syscall" "blitter.com/go/goutmp" @@ -319,7 +320,8 @@ func main() { if rec.op[0] == 'c' { // Non-interactive command addr := hc.RemoteAddr() - hname := goutmp.GetHost(addr.String()) + //hname := goutmp.GetHost(addr.String()) + hname := strings.Split(addr.String(), ":")[0] log.Printf("[Running command for [%s@%s]]\n", rec.who, hname) runErr, cmdStatus := runShellAs(string(rec.who), string(rec.cmd), false, hc, chaffEnabled) @@ -335,7 +337,8 @@ func main() { } else if rec.op[0] == 's' { // Interactive session addr := hc.RemoteAddr() - hname := goutmp.GetHost(addr.String()) + //hname := goutmp.GetHost(addr.String()) + hname := strings.Split(addr.String(), ":")[0] log.Printf("[Running shell for [%s@%s]]\n", rec.who, hname) utmpx := goutmp.Put_utmp(string(rec.who), hname)