ceph/ceph — pull request #1210 by dachary (2014-02-10 23:49:39+00:00)
Title: common: admin socket fallback to json-pretty format (dumpling)

If the format argument to a command sent to the admin socket is not
among the supported formats ( json, json-pretty, xml, xml-pretty ) the
new_formatter function will return null and the AdminSocketHook::call
function must fall back to a sensible default.

The CephContextHook::call and HelpHook::call failed to do that and a
malformed format argument would cause the mon to crash. A check is added
to each of them and fallback to json-pretty if the format is not
recognized.

To further protect AdminSocketHook::call implementations from similar
problems the format argument is checked immediately after accepting the
command in AdminSocket::do_accept and replaced with json-pretty if it is
not known.

A test case is added for both CephContextHook::call and HelpHook::call
to demonstrate the problem exists and is fixed by the patch.

http://tracker.ceph.com/issues/7378 fixes #7378

Signed-off-by: Loic Dachary
(cherry picked from commit b9a127e14dc0871954c61c10b4ddbef3421e8e5f)