[SERVER-46007] mongo causes os shell crash if we type ctrl + c when entering password in stdin Created: 06/Feb/20  Updated: 06/Dec/22  Resolved: 03/Dec/21

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Fubang Li Assignee: Backlog - Server Tooling and Methods (STM) (Inactive)
Resolution: Won't Fix Votes: 0
Labels: rp-c
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Server Tooling & Methods
Operating System: ALL
Steps To Reproduce:

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.

Participants:

 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.



 Comments   
Comment by Billy Donahue [ 08/Mar/22 ]

I just found this old PR related to this ticket, with me as reviewer. Taking myself off of it. It is probably not relevant anymore, but left for completeness.
https://github.com/mongodb/mongo/pull/1348

Comment by Brooke Miller [ 03/Dec/21 ]

We've deprecated the mongo shell in favor of the new mongosh. Unfortunately, we aren't able to pursue improvements to the deprecated shell except in extreme cases, such as critical security fixes. Please start making use of mongosh and let us know if it works for you in this case.

Comment by Oleg Pudeyev (Inactive) [ 15/May/20 ]

ryan.timmons Per my comment in https://jira.mongodb.org/browse/SERVER-27560?focusedCommentId=3089900&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-3089900, I personally am not experiencing this issue at all and thus I disagree with the proposed PR, per https://jira.mongodb.org/browse/SERVER-46007?focusedCommentId=2982492&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-2982492.

Comment by Ryan Timmons [ 12/May/20 ]

Hi oleg.pudeyev please see Carl's comment above about PRs - can you submit a PR via Rietveld?

Comment by Oleg Pudeyev (Inactive) [ 16/Mar/20 ]

If the pull request (https://github.com/mongodb/mongo/pull/1348) indeed makes the server ignore ctrl-c when asking for password, I would think this is a much worse user experience compared to the proper fix for https://jira.mongodb.org/browse/SERVER-27560.

Comment by Carl Champain (Inactive) [ 18/Feb/20 ]

Moving this ticket to the appropriate team to review the pull request.

Comment by Dmitry Agranat [ 10/Feb/20 ]

Hi lifubang@acmcoder.com,

Thanks for the report. This issue seems similar to SERVER-27560, please let us know if this is the case and if the workaround mentioned in SERVER-27560 is acceptable.

Regards,
Dima

Comment by Fubang Li [ 07/Feb/20 ]

Sorry, I wrote something wrong in description, and I don't know how to edit the description, so I post a comment here.

The correct description is here:

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 can't input anything in user's os main shell now. 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.

Generated at Thu Feb 08 05:10:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.