Fix plugin argument

This broke in the re-exec changes, it was altering the argv
argument in-place, but argv was re-used later.

Fixes #194 github issue
This commit is contained in:
Matt Johnston 2022-11-09 13:10:17 +08:00
parent 9d320a73be
commit ab6ea4d697
3 changed files with 20 additions and 16 deletions

View File

@ -128,8 +128,10 @@ typedef struct svr_runopts {
char * forced_command; char * forced_command;
#if DROPBEAR_PLUGIN #if DROPBEAR_PLUGIN
char *pubkey_plugin; /* malloced */
char *pubkey_plugin_options; char *pubkey_plugin;
/* points into pubkey_plugin */
char *pubkey_plugin_options;
#endif #endif
int pass_on_env; int pass_on_env;

View File

@ -448,15 +448,15 @@ void svr_getopts(int argc, char ** argv) {
#endif #endif
#if DROPBEAR_PLUGIN #if DROPBEAR_PLUGIN
if (pubkey_plugin) { if (pubkey_plugin) {
char *args = strchr(pubkey_plugin, ','); svr_opts.pubkey_plugin = m_strdup(pubkey_plugin);
if (args) { char *args = strchr(svr_opts.pubkey_plugin, ',');
*args='\0'; if (args) {
++args; *args='\0';
} ++args;
svr_opts.pubkey_plugin = pubkey_plugin; }
svr_opts.pubkey_plugin_options = args; svr_opts.pubkey_plugin_options = args;
} }
#endif #endif
} }

View File

@ -208,7 +208,7 @@ void svr_session(int sock, int childpipe) {
} }
/* failure exit - format must be <= 100 chars */ /* cleanup and exit - format must be <= 100 chars */
void svr_dropbear_exit(int exitcode, const char* format, va_list param) { void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
char exitmsg[150]; char exitmsg[150];
char fullmsg[300]; char fullmsg[300];
@ -217,10 +217,12 @@ void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
int add_delay = 0; int add_delay = 0;
#if DROPBEAR_PLUGIN #if DROPBEAR_PLUGIN
if ((ses.plugin_session != NULL)) { if ((ses.plugin_session != NULL)) {
svr_ses.plugin_instance->delete_session(ses.plugin_session); svr_ses.plugin_instance->delete_session(ses.plugin_session);
} }
ses.plugin_session = NULL; ses.plugin_session = NULL;
svr_opts.pubkey_plugin_options = NULL;
m_free(svr_opts.pubkey_plugin);
#endif #endif
/* Render the formatted exit message */ /* Render the formatted exit message */