diff --git a/main-runner.go b/main-runner.go index f8b8dc398..fb7cd6e67 100644 --- a/main-runner.go +++ b/main-runner.go @@ -10,6 +10,7 @@ import ( "fmt" "os" "os/signal" + "os/user" "syscall" "time" @@ -171,6 +172,9 @@ func doMain() { initPacket.Env = os.Environ() initPacket.HomeDir = homeDir initPacket.ScHomeDir = scHomeDir + if user, _ := user.Current(); user != nil { + initPacket.User = user.Username + } sender.SendPacket(initPacket) for pk := range packetCh { if pk.GetType() == packet.PingPacketStr { diff --git a/pkg/packet/packet.go b/pkg/packet/packet.go index bd47abf81..ea791e489 100644 --- a/pkg/packet/packet.go +++ b/pkg/packet/packet.go @@ -235,6 +235,7 @@ type RunnerInitPacketType struct { ScHomeDir string `json:"schomedir"` HomeDir string `json:"homedir"` Env []string `json:"env"` + User string `json:"user"` } func (*RunnerInitPacketType) GetType() string {