Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27560

Ctrl-c in shell password input leaves terminal in non-echo mode

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Shell
    • Labels:
    • Environment:
      POSIX
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide
      1. Run "mongo -u u -p". There does not need to be a mongod running on the default port.
      2. At the "Enter password:" prompt, type Ctrl-c.
      3. Type a few characters, and observe that they aren't echoed.
      4. Press Enter a few times, and observe the prompt does not appear on a new line.
      5. Type stty echo<enter> or stty sane<enter> to reset the terminal state.

      kev@localhost:~$ mongo -u foobar -p
      MongoDB shell version v3.4.1
      Enter password: 2017-01-03T12:30:50.624+1100 I CONTROL  [main] shutting down with code:0
      kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ 
      

      kev@localhost:~$ /m/3.2.11/bin/mongo -u foobar -p
      MongoDB shell version: 3.2.11
      Enter password: kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ 
      

      Show
      Run " mongo -u u -p ". There does not need to be a mongod running on the default port. At the "Enter password:" prompt, type Ctrl-c. Type a few characters, and observe that they aren't echoed. Press Enter a few times, and observe the prompt does not appear on a new line. Type stty echo<enter> or stty sane<enter> to reset the terminal state. kev@localhost:~$ mongo -u foobar -p MongoDB shell version v3.4.1 Enter password: 2017-01-03T12:30:50.624+1100 I CONTROL [main] shutting down with code:0 kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ /m/3.2.11/bin/mongo -u foobar -p MongoDB shell version: 3.2.11 Enter password: kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ kev@localhost:~$ kev@localhost:~$

      Description

      If the user realises that they have accidentally provided the wrong username when using the shell with plain --password/-p to connect and prompt for the password, a very natural reaction is to hit Ctrl-C to cancel the connection attempt, so that the user can re-run the shell with the correct username.

      However, if Ctrl-C is typed while the shell is prompting for a password, the terminal is left in non-echo mode, which messes up the display from that point onwards. The expected behaviour is for the terminal mode to be normal whenever the shell exits, including if it is killed while prompting for a password.

      The workaround is the normal one in this situation, ie. the user must (blindly) type stty echo<enter> or stty sane<enter> or reset<enter>.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-stm Backlog - Server Tooling and Methods (STM)
              Reporter:
              kevin.pulo Kevin Pulo
              Participants:
              Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

                Dates

                Created:
                Updated: