[SERVER-7252] Faulty command line is produced when installing as a service on Windows and using equal sign in options Created: 04/Oct/12 Updated: 11/Jul/16 Resolved: 06/Dec/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 2.0.8, 2.2.2, 2.3.1 |
| Fix Version/s: | 2.3.2 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Stefano Ricciardi | Assignee: | Andy Schwerin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 2008 |
||
| Issue Links: |
|
||||
| Operating System: | Windows | ||||
| Participants: | |||||
| Description |
|
When you try to install mongod as a service on Windows specifying any of the --serviceName, --serviceDisplayName or --serviceDescription options using an equal sign to separate the option name from the option value, the command line produced for the service may be missing options and/or have leftover text and the service may not be able to be successfully started. Steps to reproduce 1. Try to install mongod as a service with as below: 2. Issue the following command 3. Verify that the following error is reported: 4. WORKAROUND |
| Comments |
| Comment by Andy Schwerin [ 06/Dec/12 ] |
|
The altered functionality is unit tested, but there is no facility to test installation/removal of Windows services in our automated test framework. This was hand tested by following the "steps to reproduce" in the original ticket description. |
| Comment by auto [ 06/Dec/12 ] |
|
Author: {u'date': u'2012-12-05T20:40:32Z', u'email': u'schwerin@10gen.com', u'name': u'Andy Schwerin'}Message: |
| Comment by auto [ 05/Dec/12 ] |
|
Author: {u'date': u'2012-12-04T22:40:02Z', u'name': u'Andy Schwerin', u'email': u'schwerin@10gen.com'}Message: The service command line is derived from the mongod/mongos command line when Mongo is started with |
| Comment by auto [ 04/Dec/12 ] |
|
Author: {u'date': u'2012-12-04T20:15:40Z', u'name': u'Andy Schwerin', u'email': u'schwerin@10gen.com'}Message: |
| Comment by Tad Marshall [ 30/Nov/12 ] |
|
There is another issue caused by poor handling of equals signs used with options: this causes the filename parameters to be unrecognized by name, leading to a failure to re-quote them. This case does not involve the --service* parameters. For example:
produces
This will also fail to start due to the unquoted file paths. |
| Comment by Tad Marshall [ 30/Nov/12 ] |
|
I verified that this is a bug. It's been in every version since the Windows Service feature was introduced, and affects mongos as well as mongod. The bug is triggered in this example by using an equal sign between "--serviceName" and the text "My Service". Boost::program_options correctly parses this as an option with key "serviceName" and value "My Service", but our logic for constructing the command line for the service uses the original argc and argv as provided by Windows. Windows considers '--serviceName="My Service"' to be a single argument. Our logic removes all arguments that begin with "--service" or "-service" and also removes the argument that follows, which is assumed to be the value associated with the key. In this case, it removes the key "--serviceDescription". This leaves "My Service" as an "unknown" key, which is then copied verbatim into the constructed command line. Using a different example command line, this bug could produce a start-able service, but one in which important parameters are missing. Consider this case:
This command will result in this command line for the service:
The incorrect parsing of 'serviceName' caused 'dbpath' to be skipped, the incorrect parsing of 'serviceDescription' caused 'port' to be skipped and the incorrect parsing of 'serviceDisplayName' caused 'rest' to be skipped. The workaround, besides editing an incorrect registry entry, is to separate parameter keys and values with a space instead of an equal sign. |