1
0
mirror of https://github.com/clearml/dropbear synced 2025-04-21 14:44:56 +00:00

pass on sever process environment to child processes (option -e) ()

This commit is contained in:
Roland Vollgraf 2021-08-19 17:13:41 +02:00 committed by GitHub
parent 846d38fe43
commit 2157d52352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 6 deletions

View File

@ -35,6 +35,11 @@ Don't fork into background.
.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

View File

@ -130,6 +130,8 @@ typedef struct svr_runopts {
char *pubkey_plugin_options;
#endif
int pass_on_env;
} svr_runopts;
extern svr_runopts svr_opts;

View File

@ -943,9 +943,10 @@ static void execchild(const void *user_data) {
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();
@ -956,6 +957,7 @@ static void execchild(const void *user_data) {
}
#endif /* HAVE_CLEARENV */
#endif /* DEBUG_VALGRIND */
}
#if DROPBEAR_SVR_MULTIUSER
/* We can only change uid/gid as root ... */

View File

@ -64,6 +64,7 @@ static void printhelp(const char * progname) {
"-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 @@ void svr_getopts(int argc, char ** argv) {
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 @@ void svr_getopts(int argc, char ** argv) {
opts.usingsyslog = 0;
break;
#endif
case 'e':
svr_opts.pass_on_env = 1;
break;
#if DROPBEAR_SVR_LOCALTCPFWD
case 'j':
svr_opts.nolocaltcp = 1;