Skip to content

Commit

Permalink
SessionChannel: set HOME and CHDIR only if not set by translation server
Browse files Browse the repository at this point in the history
Give the translation server some control for overriding these.
  • Loading branch information
MaxKellermann committed Sep 25, 2024
1 parent b8e4212 commit 0845dcb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cm4all-lukko (0.29) unstable; urgency=low

* obey the NO_PASSWORD=sftp translation packet
* verify that the translation response has UID, GID and HOME
* set HOME and CHDIR only if not set by translation server
* translation: add packet CHROOT

--
Expand Down
2 changes: 1 addition & 1 deletion libcommon
4 changes: 2 additions & 2 deletions src/DelegateOpen.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ SpawnOpen(const Connection &ssh_connection)
rootfs; minimalism! */
ssh_connection.PrepareChildProcess(p, close_fds, true);

if (const char *home = p.GetJailedHome())
p.chdir = home;
if (p.chdir == nullptr)
p.chdir = p.GetJailedHome();

p.control_fd = control_socket_for_child.ToFileDescriptor();

Expand Down
10 changes: 6 additions & 4 deletions src/SessionChannel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,12 @@ SessionChannel::PrepareChildProcess(PreparedChildProcess &p,
stderr_pipe.Open(stderr_r.Release());
}

if (const char *home = p.GetJailedHome()) {
p.SetEnv("HOME", home);
p.chdir = home;
}
if (!p.HasEnv("HOME"sv))
if (const char *home = p.GetJailedHome())
p.SetEnv("HOME"sv, home);

if (p.chdir == nullptr)
p.chdir = p.GetJailedHome();
}

void
Expand Down

0 comments on commit 0845dcb

Please sign in to comment.