basho/node_package — pull request #129 by jaredmorrow (2014-04-04 22:33:17+00:00)
Title: Escape quotes passed on runner command line

This fixes an issue when passing quotes on the command line in runner or admin scripts. If quotes were passed in, they were stripped from the command causing syntax errors.

----
For example, calling:

`riak-admin bucket-type create mtype '{"props": {"n_val": 4, "allow_mult": false}}'`

would actually send
`create mtype {props: {n_val: 4, allow_mult: false}}`

instead of:

`create mtype {"props": {"n_val": 4, "allow_mult": false}}`

to the `bucket-type` command in `riak-admin`

----

The reason this was an issue is that the `exec su - $RUNNER_USER -c` would actually start a new shell and pass along the parameters by quoting them. When we used to use `sudo` it could take an list of parameters, but `su - -c` cannot, making you quote the parameters and thereby stripping any quotes inside of them.

This fix simply uses regex abuse to escape any double quotes in the command line parameters so they survive the subshell call.