Bug 843354

Summary: Unable to connect to mongo shell if the password contains a "-" character
Product: OKD Reporter: Jianwei Hou <jhou>
Component: ContainersAssignee: Rob Millner <rmillner>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.xCC: mfisher
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-07 20:42:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jianwei Hou 2012-07-26 06:18:22 UTC
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:
always
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
  env|grep OPENSHIFT_NOSQL
  OPENSHIFT_NOSQL_DB_USERNAME=admin
  OPENSHIFT_NOSQL_DB_PASSWORD=-CDDdN2LmAaR
  see, there is a "-" in password string
3.set -x
4.mongo
  
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: 127.2.13.129:27017/admin
> show dbs
admin	0.03125GB
local	(empty)
perl1	0.03125GB

Comment 1 Rob Millner 2012-07-26 19:09:04 UTC
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 20:26:55 UTC
Pull request accepted.

Comment 3 Jianwei Hou 2012-07-27 04:25:02 UTC
Verified on devenv_1916

Checked pull request 282
Step:
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

Results:
successfully connected to mongodb