here is the -e full implementation.
enjoy!

diff -Naur dropbear-2016.73.old/cli-chansession.c 
dropbear-2016.73.new/cli-chansession.c
--- 2016.73.old/cli-chansession.c       2016-03-18 15:44:43.000000000 +0100
+++ 2016.73.new/cli-chansession.c       2016-05-13 18:55:00.000000000 +0100
@@ -372,7 +372,9 @@

        if (cli_opts.wantpty) {
                cli_tty_setup();
-               channel->read_mangler = cli_escape_handler;
+               if (cli_opts.escapechar != '\0') {
+                       channel->read_mangler = cli_escape_handler;
+               }
                cli_ses.last_char = '\r';
        }       

@@ -465,13 +467,13 @@

        c = buf[0];

-       if (cli_ses.last_char == DROPBEAR_ESCAPE_CHAR) {
+       if (cli_ses.last_char == cli_opts.escapechar) {
                skip_char = do_escape(c);
                cli_ses.last_char = 0x0;
        } else {
-               if (c == DROPBEAR_ESCAPE_CHAR) {
+               if (c == cli_opts.escapechar) {
                        if (cli_ses.last_char == '\r') {
-                               cli_ses.last_char = DROPBEAR_ESCAPE_CHAR;
+                               cli_ses.last_char = cli_opts.escapechar;
                                skip_char = 1;
                        } else {
                                cli_ses.last_char = 0x0;
diff -Naur dropbear-2016.73.old/cli-runopts.c dropbear-2016.73.new/cli-runopts.c
--- 2016.73.old/cli-runopts.c   2016-03-18 15:44:43.000000000 +0100
+++ 2016.73.new/cli-runopts.c   2016-05-13 18:55:00.000000000 +0100
@@ -91,6 +91,7 @@
  #ifdef ENABLE_USER_ALGO_LIST
                                        "-c <cipher list> Specify preferred 
ciphers ('-c help' to list options)\n"
                                        "-m <MAC list> Specify preferred MACs 
for packet verification (or '-m help')\n"
+                                       "-e <char> Sets the escape character 
for sessions with a pty\n"
  #endif
                                        "-V    Version\n"
  #ifdef DEBUG_TRACE
@@ -127,6 +128,7 @@
        unsigned int cmdlen;
        char* dummy = NULL; /* Not used for anything real */

+       char* escape = NULL;
        char* recv_window_arg = NULL;
        char* keepalive_arg = NULL;
        char* idle_timeout_arg = NULL;
@@ -218,6 +220,9 @@
                                        opt = OPT_AUTHKEY;
                                        break;
  #endif
+                               case 'e': /* escape char */
+                                       next = &escape;
+                                       break;
                                case 't': /* we want a pty */
                                        cli_opts.wantpty = 1;
                                        break;
@@ -297,7 +302,6 @@
                                        break;
  #endif
                                case 'F':
-                               case 'e':
  #ifndef ENABLE_USER_ALGO_LIST
                                case 'c':
                                case 'm':
@@ -420,6 +424,14 @@
                cli_opts.remoteport = "22";
        }

+       if (escape == NULL) {
+               cli_opts.escapechar = DROPBEAR_ESCAPE_CHAR;
+       } else if (strcmp ("none", escape) == 0) {
+               cli_opts.escapechar = '\0';
+       } else {
+               cli_opts.escapechar = escape[0] & 0xff;
+       }
+
        /* If not explicitly specified with -t or -T, we don't want a pty if
         * there's a command, but we do otherwise */
        if (cli_opts.wantpty == 9) {
diff -Naur dropbear-2016.73.old/dbclient.1 dropbear-2016.73.new/dbclient.1
--- 2016.73.old/dbclient.1      2016-03-18 15:44:43.000000000 +0100
+++ 2016.73.new/dbclient.1      2016-05-13 18:55:00.000000000 +0100
@@ -147,6 +147,9 @@
  .B \-s
  The specified command will be requested as a subsystem, used for sftp. 
Dropbear doesn't implement sftp itself but the OpenSSH sftp client can be used 
eg \fIsftp -S dbclient user@host\fR
  .TP
+.B \-e \fIcharacter
+Sets the escape character for sessions with a pty (default: '~'). Setting the 
character to an empty string or "none" disables any escapes and makes the 
session fully transparent.
+.TP
  .B \-V
  Print the version

diff -Naur dropbear-2016.73.old/runopts.h dropbear-2016.73.new/runopts.h
--- 2016.73.old/runopts.h       2016-03-18 15:44:43.000000000 +0100
+++ 2016.73.new/runopts.h       2016-05-13 18:55:00.000000000 +0100
@@ -131,6 +131,7 @@
        char *username;

        char *cmd;
+       int escapechar;
        int wantpty;
        int always_accept_key;
        int no_hostkey_check;

Reply via email to