Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd63d640

Browse files
committed
Move set of env vars to createCommand
1 parentc2910e1 commitd63d640

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎agent/agent.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,15 @@ func (a *agent) createCommand(ctx context.Context, rawCommand string, env []stri
400400
unixExecutablePath:=strings.ReplaceAll(executablePath,"\\","/")
401401
cmd.Env=append(cmd.Env,fmt.Sprintf(`GIT_SSH_COMMAND=%s gitssh --`,unixExecutablePath))
402402

403+
// Set SSH connection environment variables (these are also set by OpenSSH
404+
// and thus expected to be present by SSH clients). Since the agent does
405+
// networking in-memory, trying to provide accurate values here would be
406+
// nonsensical. For now, we hard code these values so that they're present.
407+
srcAddr,srcPort:="0.0.0.0","0"
408+
dstAddr,dstPort:="0.0.0.0","0"
409+
cmd.Env=append(cmd.Env,fmt.Sprintf("SSH_CLIENT=%s %s %s",srcAddr,srcPort,dstPort))
410+
cmd.Env=append(cmd.Env,fmt.Sprintf("SSH_CONNECTION=%s %s %s %s",srcAddr,srcPort,dstAddr,dstPort))
411+
403412
// Load environment variables passed via the agent.
404413
// These should override all variables we manually specify.
405414
forenvKey,value:=rangemetadata.EnvironmentVariables {
@@ -423,15 +432,6 @@ func (a *agent) handleSSHSession(session ssh.Session) (retErr error) {
423432
iferr!=nil {
424433
returnerr
425434
}
426-
// Set SSH connection environment variables, from the clients perspective.
427-
// Set SSH connection environment variables (these are also set by OpenSSH
428-
// and thus expected to be present by SSH clients). Since the agent does
429-
// networking in-memory, trying to provide accurate values here would be
430-
// nonsensical. For now, we hard code these values so that they're present.
431-
srcAddr,srcPort:="0.0.0.0","0"
432-
dstAddr,dstPort:="0.0.0.0","0"
433-
cmd.Env=append(cmd.Env,fmt.Sprintf("SSH_CLIENT=%s %s %s",srcAddr,srcPort,dstPort))
434-
cmd.Env=append(cmd.Env,fmt.Sprintf("SSH_CONNECTION=%s %s %s %s",srcAddr,srcPort,dstAddr,dstPort))
435435

436436
ifssh.AgentRequested(session) {
437437
l,err:=ssh.NewAgentListener()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp