Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1diff --git a/src/svr-chansession.c b/src/svr-chansession.c 2index 9ae2e60..2db7598 100644 3--- a/src/svr-chansession.c 4+++ b/src/svr-chansession.c 5@@ -948,6 +948,8 @@ static void addchildpid(struct ChanSess *chansess, pid_t pid) { 6 static void execchild(const void *user_data) { 7 const struct ChanSess *chansess = user_data; 8 char *usershell = NULL; 9+ const char *path = (getuid() == 0) ? DEFAULT_ROOT_PATH : DEFAULT_PATH; 10+ const char *ldpath = NULL; 11 char *cp = NULL; 12 char *envcp = getenv("LANG"); 13 if (envcp != NULL) { 14@@ -965,6 +967,11 @@ static void execchild(const void *user_data) { 15 seedrandom(); 16 #endif 17 18+ if (getenv("PATH")) { 19+ path = getenv("PATH"); 20+ } 21+ ldpath = getenv("LD_LIBRARY_PATH"); 22+ 23 /* clear environment if -e was not set */ 24 /* if we're debugging using valgrind etc, we need to keep the LD_PRELOAD 25 * etc. This is hazardous, so should only be used for debugging. */ 26@@ -1012,10 +1019,9 @@ static void execchild(const void *user_data) { 27 addnewvar("LOGNAME", ses.authstate.pw_name); 28 addnewvar("HOME", ses.authstate.pw_dir); 29 addnewvar("SHELL", get_user_shell()); 30- if (getuid() == 0) { 31- addnewvar("PATH", DEFAULT_ROOT_PATH); 32- } else { 33- addnewvar("PATH", DEFAULT_PATH); 34+ addnewvar("PATH", path); 35+ if (ldpath != NULL) { 36+ addnewvar("LD_LIBRARY_PATH", ldpath); 37 } 38 if (cp != NULL) { 39 addnewvar("LANG", cp);