Skip to content

Commit

Permalink
fix(ssh): pass GIT_PROTOCOL from ssh session down to binary
Browse files Browse the repository at this point in the history
Fixes: 4daebdd (sec: do not append session envs to git run (#544))
  • Loading branch information
aymanbagabas committed Jul 31, 2024
1 parent 876db8d commit f23ea48
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/ssh/cmd/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"errors"
"path/filepath"
"strings"
"time"

"github.com/charmbracelet/log"
Expand Down Expand Up @@ -204,6 +205,16 @@ func gitRunE(cmd *cobra.Command, args []string) error {

envs = append(envs, cfg.Environ()...)

// Add GIT_PROTOCOL from session.
if sess := sshutils.SessionFromContext(ctx); sess != nil {
for _, env := range sess.Environ() {
if strings.HasPrefix(env, "GIT_PROTOCOL=") {
envs = append(envs, env)
break
}
}
}

repoPath := filepath.Join(reposDir, repoDir)
service := git.Service(cmd.Name())
stdin := cmd.InOrStdin()
Expand Down

0 comments on commit f23ea48

Please sign in to comment.