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

mongo causes os shell crash if we type ctrl + c when entering password in stdin

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Shell
    • Labels:
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      login a new linux shell, and use mongo shell:

      ```

      root@DESKTOP-UVUP1SF:/opt/mongo# build/opt/mongo/mongo localhost:14821/admin -u node -p

      ```

      Press enter key, then it will prompt us to enter password without echo in the screen:

      ```

      root@DESKTOP-UVUP1SF:/opt/mongo# build/opt/mongo/mongo localhost:14821/admin -u node -p

      Enter password:

      ```

      At that time, we input some password, but don't press enter key. Instead of it, we type `ctrl c`:

      ```

      root@DESKTOP-UVUP1SF:/opt/mongo# build/opt/mongo/mongo localhost:14821/admin -u node -p

      Enter password: 2020-02-06T12:14:21.173+0800 I CONTROL [main] shutting down with code:0
      root@DESKTOP-UVUP1SF:/opt/mongo#

      ```

      Because of SIGINT, the mongo shell closed normally, and returned to user's os main shell.

      But in user's os main shell, we can't input anything more.

      ```

       

      root@DESKTOP-UVUP1SF:/opt/mongo# build/opt/mongo/mongo localhost:14821/admin -u node -p

      Enter password: 2020-02-06T12:14:21.173+0800 I CONTROL [main] shutting down with code:0
      root@DESKTOP-UVUP1SF:/opt/mongo# root@DESKTOP-UVUP1SF:/opt/mongo# root@DESKTOP-UVUP1SF:

      ```

       

      User's os main shell is crash now.

      Show
      login a new linux shell, and use mongo shell: ``` root@DESKTOP-UVUP1SF:/opt/mongo# build/opt/mongo/mongo localhost:14821/admin -u node -p ``` Press enter key, then it will prompt us to enter password without echo in the screen: ``` root@DESKTOP-UVUP1SF:/opt/mongo# build/opt/mongo/mongo localhost:14821/admin -u node -p Enter password: ``` At that time, we input some password, but don't press enter key. Instead of it, we type `ctrl c`: ``` root@DESKTOP-UVUP1SF:/opt/mongo# build/opt/mongo/mongo localhost:14821/admin -u node -p Enter password: 2020-02-06T12:14:21.173+0800 I CONTROL [main] shutting down with code:0 root@DESKTOP-UVUP1SF:/opt/mongo# ``` Because of SIGINT, the mongo shell closed normally, and returned to user's os main shell. But in user's os main shell, we can't input anything more. ```   root@DESKTOP-UVUP1SF:/opt/mongo# build/opt/mongo/mongo localhost:14821/admin -u node -p Enter password: 2020-02-06T12:14:21.173+0800 I CONTROL [main] shutting down with code:0 root@DESKTOP-UVUP1SF:/opt/mongo# root@DESKTOP-UVUP1SF:/opt/mongo# root@DESKTOP-UVUP1SF: ```   User's os main shell is crash now.

      Description

      In linux platform:

      When we login to mongo server in shell with `-p` args but don't pass the password in the argument list, then mongo shell will prompt us `Enter password:` to enter the password from stdin. At that time, if we send `ctrl +c`(SIGINT) to stdin, the mongo shell will be closed, but at the same time, user's os shell will be crashed, and we will input nothing in the shell. We must close the whole shell session and login again to do other maintaining job.

       

      In windows platform, there is no such problem.

       

      I think we should ignore `ctrl c` when we type password in stdin, just like other database client shell, such as mysql.

        Attachments

          Activity

            People

            Assignee:
            backlog-server-stm Backlog - Server Tooling and Methods (STM)
            Reporter:
            lifubang@acmcoder.com Fubang Li
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: