mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
ssh/tailssh: use root / as cmd.Dir when users HomeDir doesn't exist
Fixes #5224 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
2be951a582
commit
1440742a1c
@ -283,7 +283,16 @@ func (ss *sshSession) launchProcess() error {
|
|||||||
ss.cmd = ss.newIncubatorCommand()
|
ss.cmd = ss.newIncubatorCommand()
|
||||||
|
|
||||||
cmd := ss.cmd
|
cmd := ss.cmd
|
||||||
cmd.Dir = ss.conn.localUser.HomeDir
|
homeDir := ss.conn.localUser.HomeDir
|
||||||
|
if _, err := os.Stat(homeDir); err == nil {
|
||||||
|
cmd.Dir = homeDir
|
||||||
|
} else if os.IsNotExist(err) {
|
||||||
|
// If the home directory doesn't exist, we can't chdir to it.
|
||||||
|
// Instead, we'll chdir to the root directory.
|
||||||
|
cmd.Dir = "/"
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
cmd.Env = append(cmd.Env, envForUser(ss.conn.localUser)...)
|
cmd.Env = append(cmd.Env, envForUser(ss.conn.localUser)...)
|
||||||
for _, kv := range ss.Environ() {
|
for _, kv := range ss.Environ() {
|
||||||
if acceptEnvPair(kv) {
|
if acceptEnvPair(kv) {
|
||||||
|
Loading…
Reference in New Issue
Block a user