mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
host lookup for goutmp (wtmp) tracking
This commit is contained in:
parent
11fad87345
commit
889203c9de
1 changed files with 11 additions and 6 deletions
|
@ -292,24 +292,29 @@ func main() {
|
|||
|
||||
if rec.op[0] == 'c' {
|
||||
// Non-interactive command
|
||||
log.Println("[Running command]")
|
||||
addr := c.RemoteAddr()
|
||||
hname := goutmp.GetHost(addr.String())
|
||||
|
||||
log.Println("[Running command for [%s@%s]]\n", rec.who, hname)
|
||||
runShellAs(string(rec.who), string(rec.cmd), false, conn, chaffEnabled)
|
||||
// Returned hopefully via an EOF or exit/logout;
|
||||
// Clear current op so user can enter next, or EOF
|
||||
rec.op[0] = 0
|
||||
log.Println("[Command complete]")
|
||||
log.Printf("[Command completed for [%s@%s]\n", rec.who, hname)
|
||||
} else if rec.op[0] == 's' {
|
||||
log.Println("[Running shell]")
|
||||
// Interactive session
|
||||
addr := c.RemoteAddr()
|
||||
hname := goutmp.GetHost(addr.String())
|
||||
log.Println("[Running shell for [%s@%s]]\n", rec.who, hname)
|
||||
|
||||
utmpx := goutmp.Put_utmp(string(rec.who), addr.String())
|
||||
utmpx := goutmp.Put_utmp(string(rec.who), hname)
|
||||
defer func() { goutmp.Unput_utmp(utmpx) }()
|
||||
goutmp.Put_lastlog_entry("hkexsh", string(rec.who), addr.String())
|
||||
goutmp.Put_lastlog_entry("hkexsh", string(rec.who), hname)
|
||||
runShellAs(string(rec.who), string(rec.cmd), true, conn, chaffEnabled)
|
||||
// Returned hopefully via an EOF or exit/logout;
|
||||
// Clear current op so user can enter next, or EOF
|
||||
rec.op[0] = 0
|
||||
log.Println("[Exiting shell]")
|
||||
log.Printf("[Exiting shell for [%s@%s]]\n", rec.who, hname)
|
||||
} else {
|
||||
log.Println("[Bad cmdSpec]")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue