File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,13 +138,15 @@ func parseTsshdArgs() *tsshdArgs {
138138 return args
139139}
140140
141+ const kEnvTsshdBackground = "TRZSZ-SSHD-BACKGROUND"
142+
141143func background () (bool , io.ReadCloser , error ) {
142- if v := os .Getenv ("TRZSZ-SSHD-BACKGROUND" ); v == "TRUE" {
144+ if v := os .Getenv (kEnvTsshdBackground ); v == "TRUE" {
143145 return false , nil , nil
144146 }
145147 cmd := exec .Command (os .Args [0 ], os .Args [1 :]... )
146148 cmd .Stderr = os .Stderr
147- cmd .Env = append (os .Environ (), "TRZSZ-SSHD-BACKGROUND =TRUE" )
149+ cmd .Env = append (os .Environ (), kEnvTsshdBackground + " =TRUE" )
148150 cmd .SysProcAttr = getSysProcAttr ()
149151 stdout , err := cmd .StdoutPipe ()
150152 if err != nil {
Original file line number Diff line number Diff line change @@ -845,6 +845,9 @@ func getSessionStartCmd(msg *startMessage) (*exec.Cmd, error) {
845845 continue
846846 }
847847 name := strings .TrimSpace (env [:pos ])
848+ if name == kEnvTsshdBackground {
849+ continue
850+ }
848851 if _ , ok := msg .Envs [name ]; ! ok {
849852 envs = append (envs , env )
850853 }
@@ -1012,10 +1015,7 @@ func (c *sessionContext) handleX11Request(msg *startMessage) {
10121015 go c .handleChannelAccept (listener , msg .X11 .ChannelType )
10131016 }
10141017
1015- if msg .Envs == nil {
1016- msg .Envs = make (map [string ]string )
1017- }
1018- msg .Envs ["DISPLAY" ] = display
1018+ c .cmd .Env = append (c .cmd .Env , fmt .Sprintf ("DISPLAY=%s" , display ))
10191019}
10201020
10211021func getHostnameForX11 (useLocalhost bool ) string {
@@ -1150,10 +1150,7 @@ func (c *sessionContext) handleAgentRequest(msg *startMessage) {
11501150
11511151 go c .handleChannelAccept (listener , msg .Agent .ChannelType )
11521152
1153- if msg .Envs == nil {
1154- msg .Envs = make (map [string ]string )
1155- }
1156- msg .Envs ["SSH_AUTH_SOCK" ] = agentPath
1153+ c .cmd .Env = append (c .cmd .Env , fmt .Sprintf ("SSH_AUTH_SOCK=%s" , agentPath ))
11571154}
11581155
11591156func (c * sessionContext ) handleChannelAccept (listener net.Listener , channelType string ) {
You can’t perform that action at this time.
0 commit comments