diff svr-chansession.c @ 1819:5120e22882de

pass on sever process environment to child processes (option -e) (#118)
author Roland Vollgraf <30869947+rvollgraf@users.noreply.github.com>
date Thu, 19 Aug 2021 17:13:41 +0200
parents f0cd000f3bca
children 1edf4f143e12
line wrap: on
line diff
--- a/svr-chansession.c	Sat May 01 20:47:15 2021 +0800
+++ b/svr-chansession.c	Thu Aug 19 17:13:41 2021 +0200
@@ -943,19 +943,21 @@
 	seedrandom();
 #endif
 
-	/* clear environment */
+	/* clear environment if -e was not set */
 	/* if we're debugging using valgrind etc, we need to keep the LD_PRELOAD
 	 * etc. This is hazardous, so should only be used for debugging. */
+	if ( !svr_opts.pass_on_env) {
 #ifndef DEBUG_VALGRIND
 #ifdef HAVE_CLEARENV
-	clearenv();
+		clearenv();
 #else /* don't HAVE_CLEARENV */
-	/* Yay for posix. */
-	if (environ) {
-		environ[0] = NULL;
-	}
+		/* Yay for posix. */
+		if (environ) {
+			environ[0] = NULL;
+		}
 #endif /* HAVE_CLEARENV */
 #endif /* DEBUG_VALGRIND */
+	}
 
 #if DROPBEAR_SVR_MULTIUSER
 	/* We can only change uid/gid as root ... */