1diff --git a/svr-chansession.c b/svr-chansession.c
2index e44299e..7ef750a 100644
3--- a/svr-chansession.c
4+++ b/svr-chansession.c
5@@ -893,6 +893,8 @@ static void addchildpid(struct ChanSess *chansess, pid_t pid) {
6 static void execchild(void *user_data) {
7 struct ChanSess *chansess = user_data;
8 char *usershell = NULL;
9+ const char *path = DEFAULT_PATH;
10+ const char *ldpath = NULL;
11
12 /* with uClinux we'll have vfork()ed, so don't want to overwrite the
13 * hostkey. can't think of a workaround to clear it */
14@@ -905,6 +907,10 @@ static void execchild(void *user_data) {
15 seedrandom();
16 #endif
17
18+ if (getenv("PATH"))
19+ path = getenv("PATH");
20+ ldpath = getenv("LD_LIBRARY_PATH");
21+
22 /* clear environment */
23 /* if we're debugging using valgrind etc, we need to keep the LD_PRELOAD
24 * etc. This is hazardous, so should only be used for debugging. */
25@@ -948,7 +954,10 @@ static void execchild(void *user_data) {
26 addnewvar("LOGNAME", ses.authstate.pw_name);
27 addnewvar("HOME", ses.authstate.pw_dir);
28 addnewvar("SHELL", get_user_shell());
29- addnewvar("PATH", DEFAULT_PATH);
30+ addnewvar("PATH", path);
31+ if (ldpath != NULL) {
32+ addnewvar("LD_LIBRARY_PATH", ldpath);
33+ }
34 if (chansess->term != NULL) {
35 addnewvar("TERM", chansess->term);
36 }