diff --git a/xsd/xsd.go b/xsd/xsd.go index 6c270db..428d434 100755 --- a/xsd/xsd.go +++ b/xsd/xsd.go @@ -346,6 +346,9 @@ func runShellAs(who, hname, ttype, cmd string, interactive bool, //nolint:funlen defer func() { goutmp.Unput_utmp(utmpx) }() goutmp.Put_lastlog_entry("xs", who, pts, hname) + conn.Pproc = c.Process.Pid + //fmt.Printf("[process %d started]\n", c.Process.Pid) + log.Printf("[%s]\n", cmd) if err != nil { log.Printf("Command finished with error: %v", err) diff --git a/xsnet/net.go b/xsnet/net.go index 3ac54d7..103086d 100644 --- a/xsnet/net.go +++ b/xsnet/net.go @@ -39,6 +39,7 @@ import ( "net" "strings" "sync" + "syscall" "time" hkex "blitter.com/go/herradurakex" @@ -87,6 +88,7 @@ type ( Cols uint16 keepalive uint // if this reaches zero, conn is considered dead + Pproc int // proc ID of command run on this conn chaff ChaffConfig tuns *map[uint16](*TunEndpoint) @@ -1649,7 +1651,8 @@ func (hc *Conn) keepaliveHelper() { time.Sleep(time.Duration(nextDuration) * time.Millisecond) hc.keepalive -= 1 logger.LogDebug(fmt.Sprintf("[keepAlive is now %d]\n", hc.keepalive)) - //if rand.Intn(32) == 0 { + + //if rand.Intn(8) == 0 { // hc.keepalive = 0 //} @@ -1657,6 +1660,10 @@ func (hc *Conn) keepaliveHelper() { logger.LogDebug(fmt.Sprintf("*** keepaliveHelper shutting down\n")) hc.SetStatus(CSEConnDead) hc.ShutdownKeepAlive() + if hc.Pproc != 0 { + //fmt.Printf("[pid %d needs to be killed]\n", hc.Pproc) + syscall.Kill(hc.Pproc, syscall.SIGABRT) //nolint:errcheck + } break } }