Skip to content

Commit

Permalink
Add HOME to environment of interactive unix shells
Browse files Browse the repository at this point in the history
  • Loading branch information
Fahrj committed Dec 24, 2021
1 parent 51d087a commit 5dbb75d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ssh_session_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"io"
"log"
"os/exec"
"os/user"

"github.com/creack/pty"
"github.com/gliderlabs/ssh"
Expand All @@ -36,6 +37,9 @@ func createPty(s ssh.Session, shell string) {
)

cmd.Env = append(cmd.Env, fmt.Sprintf("TERM=%s", ptyReq.Term))
if currentUser, err := user.Current(); err == nil {
cmd.Env = append(cmd.Env, fmt.Sprintf("HOME=%s", currentUser.HomeDir))
}
f, err := pty.Start(cmd)
if err != nil {
log.Fatalln("Could not start shell:", err)
Expand Down

0 comments on commit 5dbb75d

Please sign in to comment.