Skip to content

Commit cc9a4df

Browse files
committed
feat: add dokku-specific env vars
This change allows us to pass the ssh user and a proxy 'name' (mapping to the authenticating user) that will allow sshcommand to identify who is performing commands.
1 parent 2837b10 commit cc9a4df

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

git-http-backend.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,24 @@ func serviceRpc(hr HandlerReq) {
119119
w.Header().Set("Content-Type", fmt.Sprintf("application/x-git-%s-result", rpc))
120120
w.WriteHeader(http.StatusOK)
121121

122+
env := []string{
123+
"SSH_USER=git-http-backend",
124+
}
125+
126+
user, _, authok := r.BasicAuth()
127+
if authok {
128+
env = append(env, fmt.Sprintf("NAME=%s", user))
129+
env = append(env, fmt.Sprintf("SSH_NAME=%s", user))
130+
}
131+
122132
args := []string{rpc, "--stateless-rpc", dir}
123133
cmd := exec.Command(config.GitBinPath, args...)
124134
version := r.Header.Get("Git-Protocol")
125135
if len(version) != 0 {
126136
cmd.Env = append(os.Environ(), fmt.Sprintf("GIT_PROTOCOL=%s", version))
127137
}
128138
cmd.Dir = dir
139+
cmd.Env = env
129140
in, err := cmd.StdinPipe()
130141
if err != nil {
131142
log.Print(err)

0 commit comments

Comments
 (0)