Bug 843354 - Unable to connect to mongo shell if the password contains a "-" character
Unable to connect to mongo shell if the password contains a "-" character
Product: OpenShift Origin
Classification: Red Hat
Component: Containers (Show other bugs)
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Rob Millner
libra bugs
: Triaged
Depends On:
  Show dependency treegraph
Reported: 2012-07-26 02:18 EDT by Jianwei Hou
Modified: 2015-05-14 18:57 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-08-07 16:42:41 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jianwei Hou 2012-07-26 02:18:22 EDT
Description of problem:
ssh into application and run "mongo", the connection to mongo shell will fail if the password contains a "-" character, "-" will be taken as an option

Version-Release number of selected component (if applicable):
On INT,denenv_1912

How reproducible:
note: to reproduce, you may need to update mongo password and modify /var/lib/stickshift/$UUID/.env/OPENSHIFT_NOSQL_DB_PASSWORD to make it contain a "-" character

Steps to Reproduce:
1.Create an application, embed mongodb
2.ssh into application
  see, there is a "-" in password string
3.set -x
Actual results:
ERROR: unknown option -C

MongoDB shell version: 2.0.2
usage: /usr/bin/mongo [options] [db address] [file names (ending in .js)]
file names: a list of files to run. files have to end in .js and will exit after unless --shell is specified

Expected results:
should connect to mongo shell successfully

Additional info:
I have to specify a password using -p option to connect to mongoDB
[perl1-jhou.int.rhcloud.com ~]\> mongo -u admin -p
MongoDB shell version: 2.0.2
Enter password: 
connecting to:
> show dbs
admin	0.03125GB
local	(empty)
perl1	0.03125GB
Comment 1 Rob Millner 2012-07-26 15:09:04 EDT
There doesn't seem to be a way we can keep the mongo command from treating a password starting with "-" as a new command line option.

Fixed the password generator we use to never create a password which starts with a "-".  That will prevent the problem from happening under normal use.

Crankcase pull request 282.
Comment 2 Rob Millner 2012-07-26 16:26:55 EDT
Pull request accepted.
Comment 3 Jianwei Hou 2012-07-27 00:25:02 EDT
Verified on devenv_1916

Checked pull request 282
1.ssh into devenv instance
2.Check /usr/libexec/stickshift/cartridges/abstract/info/lib/util, any password starts with a "-" will not be generated
3.Create apps, embedded mongodb
  rhc app create -a app1 -t php-5.3
  rhc app cartridge add -a app1 -c mongodb-2.0
4.ssh into application, run command mongo

successfully connected to mongodb

Note You need to log in before you can comment on or make changes to this bug.