[SERVER-12643] wrong exit code from the shell when incorrectly connecting to an authenticated database Created: 06/Feb/14 Updated: 06/Dec/22 Resolved: 19/Nov/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Security, Shell |
| Affects Version/s: | 2.4.9 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Daniel Coupal | Assignee: | Backlog - Server Tooling and Methods (STM) (Inactive) |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | move-stm | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
MacOSX, but got the same under Linux |
||
| Assigned Teams: |
Server Tooling & Methods
|
| Operating System: | ALL |
| Participants: |
| Description |
|
If you run an 'eval' query through 'mongo' on an authenticated database, you get the following: 1) providing wrong credentials MacBook-Pro:mongotools me$ mongo --quiet --host 172.16.65.202 --port 27017 --username user --password pass --eval "printjson(db.adminCommand('listDatabases').databases)" test Thu Jan 30 13:23:39.744 Error: 18 { code: 18, ok: 0.0, errmsg: "auth fails" } at src/mongo/shell/db.js:228 MacBook-Pro:mongotools me$ echo $? 2) not trying to authenticate (missing user/password) MacBook-Pro:mongotools me$ mongo --quiet --host 172.16.65.202 --port 27017 --eval "printjson(db.adminCommand('listDatabases').databases)" test MacBook-Pro:mongotools me$ echo $? In authenticating with wrong credentials (1), you get the expected error code (non-zero) from the shell. From a calling script, the result in providing no credentials or bad credentials should be the same. Apart from being coherent with Unix commands, one scenario for which it is important to report a failure is the following:
|
| Comments |
| Comment by Brooke Miller [ 19/Nov/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. Can you please start making use of mongosh and let us know if it works for you in this case? |