# HG changeset patch # User Matt Johnston # Date 1647398604 -28800 # Node ID 75d6a9faf9199bac612d1be3df58299484a5eb84 # Parent 81991ded740f2ea3ccb9bf83bd9971c759b17124# Parent f54451afc046259a519fe12e40d3b6a1fbe9fa99 Merge pull request #151 from HansH111/pubkeyinfo diff -r f54451afc046 -r 75d6a9faf919 cli-auth.c --- a/cli-auth.c Tue Mar 15 18:57:21 2022 +0000 +++ b/cli-auth.c Wed Mar 16 10:43:24 2022 +0800 @@ -85,31 +85,32 @@ banner = buf_getstring(ses.payload, &bannerlen); buf_eatstring(ses.payload); /* The language string */ - if (bannerlen > MAX_BANNER_SIZE) { - TRACE(("recv_msg_userauth_banner: bannerlen too long: %d", bannerlen)) - truncated = 1; - } else { - cleantext(banner); + if (cli_opts.quiet == 0) { + if (bannerlen > MAX_BANNER_SIZE) { + TRACE(("recv_msg_userauth_banner: bannerlen too long: %d", bannerlen)) + truncated = 1; + } else { + cleantext(banner); - /* Limit to 24 lines */ - linecount = 1; - for (i = 0; i < bannerlen; i++) { - if (banner[i] == '\n') { - if (linecount >= MAX_BANNER_LINES) { - banner[i] = '\0'; - truncated = 1; - break; + /* Limit to 24 lines */ + linecount = 1; + for (i = 0; i < bannerlen; i++) { + if (banner[i] == '\n') { + if (linecount >= MAX_BANNER_LINES) { + banner[i] = '\0'; + truncated = 1; + break; + } + linecount++; } - linecount++; } + fprintf(stderr, "%s\n", banner); } - fprintf(stderr, "%s\n", banner); + + if (truncated) { + fprintf(stderr, "[Banner from the server is too long]\n"); + } } - - if (truncated) { - fprintf(stderr, "[Banner from the server is too long]\n"); - } - m_free(banner); TRACE(("leave recv_msg_userauth_banner")) } diff -r f54451afc046 -r 75d6a9faf919 cli-runopts.c --- a/cli-runopts.c Tue Mar 15 18:57:21 2022 +0000 +++ b/cli-runopts.c Wed Mar 16 10:43:24 2022 +0800 @@ -62,6 +62,7 @@ "-T Don't allocate a pty\n" "-N Don't run a remote command\n" "-f Run in background after auth\n" + "-q quiet, don't show remote banner\n" "-y Always accept remote host key if unknown\n" "-y -y Don't perform any remote host key checking (caution)\n" "-s Request a subsystem (use by external sftp)\n" @@ -141,6 +142,7 @@ cli_opts.username = NULL; cli_opts.cmd = NULL; cli_opts.no_cmd = 0; + cli_opts.quiet = 0; cli_opts.backgrounded = 0; cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */ cli_opts.always_accept_key = 0; @@ -214,6 +216,9 @@ } cli_opts.always_accept_key = 1; break; + case 'q': /* quiet */ + cli_opts.quiet = 1; + break; case 'p': /* remoteport */ next = (char**)&cli_opts.remoteport; break; @@ -540,6 +545,12 @@ ret = m_malloc(len); total = 0; + if (cli_opts.quiet) + { + int written = snprintf(ret+total, len-total, "-q "); + total += written; + } + if (cli_opts.no_hostkey_check) { int written = snprintf(ret+total, len-total, "-y -y "); diff -r f54451afc046 -r 75d6a9faf919 runopts.h --- a/runopts.h Tue Mar 15 18:57:21 2022 +0000 +++ b/runopts.h Wed Mar 16 10:43:24 2022 +0800 @@ -92,7 +92,6 @@ /* whether to print the MOTD */ int domotd; #endif - int norootlogin; #ifdef HAVE_GETGROUPLIST @@ -155,6 +154,7 @@ int always_accept_key; int no_hostkey_check; int no_cmd; + int quiet; int backgrounded; int is_subsystem; #if DROPBEAR_CLI_PUBKEY_AUTH diff -r f54451afc046 -r 75d6a9faf919 test/test_dropbear.py --- a/test/test_dropbear.py Tue Mar 15 18:57:21 2022 +0000 +++ b/test/test_dropbear.py Wed Mar 16 10:43:24 2022 +0800 @@ -72,6 +72,10 @@ return f"source {venv}/bin/activate" class HandleTcp(socketserver.ThreadingMixIn, socketserver.TCPServer): + + # override TCPServer's default, avoids TIME_WAIT + allow_reuse_addr = True + """ Listens for a single incoming request, sends a response if given, and returns the inbound data. Reponse can be a queue object, in which case each item in the queue will