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,7 +128,9 @@ typedef struct svr_runopts {
char * forced_command; char * forced_command;
#if DROPBEAR_PLUGIN #if DROPBEAR_PLUGIN
/* malloced */
char *pubkey_plugin; char *pubkey_plugin;
/* points into pubkey_plugin */
char *pubkey_plugin_options; char *pubkey_plugin_options;
#endif #endif

View File

@ -449,12 +449,12 @@ void svr_getopts(int argc, char ** argv) {
#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);
char *args = strchr(svr_opts.pubkey_plugin, ',');
if (args) { if (args) {
*args='\0'; *args='\0';
++args; ++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];
@ -221,6 +221,8 @@ void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
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 */