Mercurial > dropbear
changeset 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 | 587c76726b5f |
children | e9854650d45b |
files | dropbear.8 runopts.h svr-chansession.c svr-runopts.c |
diffstat | 4 files changed, 21 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/dropbear.8 Sat May 01 20:47:15 2021 +0800 +++ b/dropbear.8 Thu Aug 19 17:13:41 2021 +0200 @@ -35,6 +35,11 @@ .B \-E Log to standard error rather than syslog. .TP +.B \-e +Pass on the server environment to all child processes. This is required, for example, +if dropbear is launched on the fly from a SLURM workload manager. The enviroment is not +passed by default. Note that this can be a potential security risk. +.TP .B \-m Don't display the message of the day on login. .TP
--- a/runopts.h Sat May 01 20:47:15 2021 +0800 +++ b/runopts.h Thu Aug 19 17:13:41 2021 +0200 @@ -130,6 +130,8 @@ char *pubkey_plugin_options; #endif + int pass_on_env; + } svr_runopts; extern svr_runopts svr_opts;
--- 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 ... */
--- a/svr-runopts.c Sat May 01 20:47:15 2021 +0800 +++ b/svr-runopts.c Thu Aug 19 17:13:41 2021 +0200 @@ -64,6 +64,7 @@ "-R Create hostkeys as required\n" #endif "-F Don't fork into background\n" + "-e Pass on server process environment to child process\n" #ifdef DISABLE_SYSLOG "(Syslog support not compiled in, using stderr)\n" #else @@ -173,6 +174,7 @@ svr_opts.pubkey_plugin = NULL; svr_opts.pubkey_plugin_options = NULL; #endif + svr_opts.pass_on_env = 0; #ifndef DISABLE_ZLIB opts.compress_mode = DROPBEAR_COMPRESS_DELAYED; @@ -223,6 +225,10 @@ opts.usingsyslog = 0; break; #endif + case 'e': + svr_opts.pass_on_env = 1; + break; + #if DROPBEAR_SVR_LOCALTCPFWD case 'j': svr_opts.nolocaltcp = 1;