Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SERVER-46007 ignore SIGINT when input password in stdin #1348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lifubang
Copy link

@lifubang lifubang commented Feb 6, 2020

Problem:

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

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 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.

Step 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.

Signed-off-by: lifubang [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants