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

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • Server Tooling & Methods
    • ALL
    • 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.

      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.

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

              Created:
              Updated:
              Resolved: