]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common: admin socket fallback to json-pretty format 1207/head
authorLoic Dachary <loic@dachary.org>
Mon, 10 Feb 2014 22:42:38 +0000 (23:42 +0100)
committerLoic Dachary <loic@dachary.org>
Tue, 11 Feb 2014 08:21:35 +0000 (09:21 +0100)
commit165e76d4d03ffcc490fd3c2ba60fb37372990d0a
tree666e94f5331697545bc2ad5527bab44c2e53575c
parent39b393d7fa0e66c6e7a73ce6b5b45bbf3bb6980a
common: admin socket fallback to json-pretty format

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.

Three other instances of unsafe calls to new_formatter were found and
a fallback to json-pretty was added. All other calls have been audited
and appear to be safe.

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

Backport: emperor, dumpling
Signed-off-by: Loic Dachary <loic@dachary.org>
src/client/Client.cc
src/common/admin_socket.cc
src/common/ceph_context.cc
src/osd/OSD.cc
src/osdc/Objecter.cc
src/test/Makefile.am
src/test/admin_socket.cc
src/test/common/test_context.cc [new file with mode: 0644]