Skip to content

Commit 9d2462a

Browse files
committed
login shell convention
1 parent 35609c2 commit 9d2462a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cmd/function22/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ func handleSSHConnection(s gliderssh.Session, account linuxuser.Account, verbose
206206
},
207207
}
208208

209+
if userWantsDefaultShell {
210+
// "bash" -> "-bash"
211+
// convention to tell that we want login shell (read shell config files, fill PATH etc.)
212+
// https://unix.stackexchange.com/a/46856
213+
//
214+
// cmd := exec.Command(name, "argv1") is internally copied to two fields:
215+
// - cmd.Path (which we're not mutating here)
216+
// - cmd.Args[0] (mutating this one, which no longer affects the actual exec'd binary)
217+
cmd.Args[0] = "-" + cmd.Args[0]
218+
}
219+
209220
sigs := make(chan gliderssh.Signal, 1)
210221
s.Signals(sigs)
211222
go func() { // signals coming from SSH client are piped to the process

0 commit comments

Comments
 (0)